Skip to main content

test package build with poetry

Comparing to setuptools, poetry is all-in-one shop and with less manual configuration in python package development cycle. For example, pyproject.toml is created by poetry with format of PEP 518 package specs with poetry new command.

pyenv shell 3.9.11
python -m venv ./venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install poetry

package initialization

Use poetry to initialzes a package under project root:

poetry new test_pkg_poetry_binlecode

Use poetry to add dependencies, they are added to pyproject.toml by poetry automatically.

# add pytest as dev dependency
poetry add pytest --dev
# show dependency tree
poetry show --tree
# generate lock file
poetry lock

# The install command reads the pyproject.toml file from the current project,
# resolves the dependencies, and installs them.
# If poetry.lock exists, the lock file is used instead of resolving dependencies.
poetry install

poetry export --output requirements.txt

testing with pytest

Run pytest at project root level, it will scan tests folder and test scripts.

poetry run pytest

source code formatting with black

poetry run black .

build distribution and publish

Check package and build distribution. Poetry builds both source and wheel distributions.

poetry check
poetry build

To publish to pypi, config api token first.

poetry config pypi-token.pypi <my-token>

Poetry can use token to publish:

poetry publish

Publishing test-pkg-poetry-binlecode (0.1.0) to PyPI
 - Uploading test-pkg-poetry-binlecode-0.1.0.tar.gz 100%
 - Uploading test_pkg_poetry_binlecode-0.1.0-py3-none-any.whl 100%

Metadata

Release files for test-pkg-poetry-binlecode 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for test-pkg-poetry-binlecode 0.1.5
File Size Uploaded Provenance
test_pkg_poetry_binlecode-0.1.5.tar.gz 2.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for test-pkg-poetry-binlecode 0.1.5
File Interpreter ABI Platform
test_pkg_poetry_binlecode-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 4.3 kB

Release files / test_pkg_poetry_binlecode-0.1.5.tar.gz

Download URL test_pkg_poetry_binlecode-0.1.5.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b11cc5c761097cc6a96ff05bcb4a9bbba72008186c5509ae7c5ce6b6dc331ad8
BLAKE2b-256 checksum
How to use checksums
0d6a0caa4064a687874b3339e1cec302b05fbcfd9a8f90e8c02912639ca64c44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.9.14 Linux/5.15.0-1020-azure

Release files / test_pkg_poetry_binlecode-0.1.5-py3-none-any.whl

Download URL test_pkg_poetry_binlecode-0.1.5-py3-none-any.whl
Size 2.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57dad15230435f6270b88483a56e49f00f06b83fafa7f9268620806d69b23040
BLAKE2b-256 checksum
How to use checksums
a1bb006806359e92ca4c851ca72cfd3eed63919d61289beaa597b7baf188e59e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.9.14 Linux/5.15.0-1020-azure

Security for test-pkg-poetry-binlecode 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page