Testing poetry
Project description
This repo is just an experiment to test out poetry
Key things:
easyily turn program.py to poetryexp
runnable program that can be installed with pip install poetry-experiment
or other available pypi package name
In a new project folder (package-root):
- run
git init
orgit clone
beforehand - create README.md if missing
- propper py package
- put program.py in package folder poetry-experiment/
- create init.py (import program) inside, in poetry-experiment/
- poetry init
- add script to toml
- poetry build
- poetry config pypi-token.pypi your-api-token
- poetry publish
package-root/
README.md
poetry.toml (fix name)
poetry-experiment/
__init__.py #import program inside
program.py
.git/
To accomplish this, you can follow these steps:
-
Create a
pyproject.toml
file: Make sure you have apyproject.toml
file in your project directory. Poetry uses this file to manage project dependencies and settings. -
Add metadata to
pyproject.toml
: You'll need to define metadata such as the project name, version, and description in thepyproject.toml
file. -
Define entry points: In your
pyproject.toml
, you can define entry points for your command-line interface (CLI) using the[tool.poetry.scripts]
section. This will allow users to run your program using a specified name. -
Write your
program.py
: Write the Python script that you want to publish. -
Build your package: Use Poetry to build your package. This will generate a distributable package that can be uploaded to PyPI.
-
Publish to PyPI: Once your package is built, you can publish it to PyPI using Poetry's
publish
command.
Here's a step-by-step guide:
- Create a
pyproject.toml
file if you don't already have one. It should look something like this:
[tool.poetry]
name = "poetry_experiment"
version = "1.0.0"
description = "A description of your program"
authors = ["Your Name <your.email@example.com>"]
[tool.poetry.dependencies]
python = "^3.8"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.scripts]
poetryexp = "program:main"
- Write your
program.py
. Make sure it has a function namedmain
, which will be called when users run your program.
def main():
print("Hello, world!")
- Once you've written your script and configured your
pyproject.toml
, you can use Poetry to build your package:
poetry build
- After the build is successful, you can publish your package to PyPI:
poetry publish --build
- After publishing, users can install your package using pip:
pip install poetry_experiment
- Once installed, users can run your program using the specified entry point:
poetryexp
This will execute the main()
function defined in your program.py
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for poetry_experiment-0.1.0.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75c508e2906bbc04ecd9d2ac955955b8ae83998350fe640ba4d7faa31a669dc3 |
|
MD5 | 5b16af8b6293ad8f01b8b6dd9848b3cf |
|
BLAKE2b-256 | 7dba0c265d5d51a272ad91b6871b80cbd239776ef5f53edaa9dd725422288fd5 |
Hashes for poetry_experiment-0.1.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1140ff38b006d267cefe6d0219023d317aeae54b418414471fb97861a1a91ff |
|
MD5 | bd83a8bdd90a18b057402ad1cb334c74 |
|
BLAKE2b-256 | cd899c20c00506e5be6f17bed115ca4d8d10d4a841cf0c65dad816f9852209fe |