Skip to main content

Poetry lock package generator

Project description

Poetry lock package generator

Simple script that will take a pyproject.toml and a poetry.lock and generate a new poetry project where all the lock versions are pinned dependencies.

In theory this will allow you to transport your lock file to any system that is able to install python packages and dependencies.

After installation, the command poetry-lock-package should be run next to your pyproject.toml and poetry.lock files and will generate a subdirectory with a pyproject.toml requiring all the dependencies of the lock file.

Simply enter the subdirectory, build and publish the package and you have a '-lock' package that depends on all the exact versions from your lock file.

Example workflow

The example workflow below will add poetry-lock-package as a dev dependency, allowing poetry run to find the command.

First create a new poetry project

poetry new example-package
cd example-package

Add some dependencies, and see what we have build so far

poetry add loguru click
poetry install
poetry build
ls dist

Add poetry-lock-package to allow for poetry run to find the entry point script:

poetry add --dev poetry-lock-package

Finally build the lock package and see what we have gotten

poetry run poetry-lock-package --build
ls -al dist

You will now have two wheel files in your dist folder: one with the project code, one name example-package-lock which depends on the exact version of all the packages specified in your poetry.lock file.

Using --no-root

Default behavior is to have the lock package depend on the original package the lock was created for. If you have a private repository, this will allow you to publish both packages to the private repository and only require you to point at one package to install everything.

If you want to be able to install the dependencies, but not the package itself, you can use the --no-root command line argument to stop poetry-lock-package from adding your root project to the lock package dependencies.

Using --ignore

If you want to allow pip to have freedom in selecting a package, or you expect to deploy in an environment that already has the right version installed, you can opt to use --ignore to remove that dependency from the lock package pinned dependencies.

Because poetry-lock-package is aware of the dependency graph, it will not only skip locking the dependency but also transitive dependencies.

Contributing code

  • Open an issue

  • Create an associated PR

  • Make sure to black format the proposed change

    poetry run pre-commit install

  • Add tests where possible

License

GPLv3, use at your own risk.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poetry_lock_package-0.5.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

poetry_lock_package-0.5.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file poetry_lock_package-0.5.1.tar.gz.

File metadata

  • Download URL: poetry_lock_package-0.5.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.14

File hashes

Hashes for poetry_lock_package-0.5.1.tar.gz
Algorithm Hash digest
SHA256 9cdae3aaea6c22e05cbaec7f4d47f140cd1b0d314c7cc1714a21d963031a2a2f
MD5 33b9709aa6eac08bcc20aab6ddd13a43
BLAKE2b-256 d7632ca86994af533031eab15f7807c349b47cf75a02b8763c5dec9c2fcd7ea2

See more details on using hashes here.

File details

Details for the file poetry_lock_package-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for poetry_lock_package-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 102c0b1921d28528e37aaf62b51c6a167cf569bdd72e978e9d19c743c7fe8a53
MD5 1a7cdc0c8c5ec2c7d16838147f0889db
BLAKE2b-256 7672ce8a12cb5d823b7d8ea6983bcb9b77d2516a202abb440aec3011dfdeadfc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page