Skip to main content

Automatically create requirements.txt on every poetry lock

Project description

poetry-auto-export

Automatically export dependencies to requirements.txt on every poetry lock

This plugin enables you to keep a requirements.txt file always up to date with your poetry.lock file. This is helpful if you want to use pip to install your dependencies somewhere, e.g.

  • in CI/CD environments
  • in docker containers

Usage

Add plugin configuration to your pyproject.toml. The options follow arguments for poetry export.

[tool.poetry-auto-export]
output = "requirements.txt"
without_hashes = true
without = ["dev"]

Then, run poetry commands as usual:

poetry lock

The requirements.txt file will be updated automatically.

The supported commands are:

  • lock
  • update
  • add
  • remove

Creating multiple export files

If you need to create multiple requirements files, e.g. dev-requirements.txt and prod-requirements.txt, use the following syntax:

[[tool.poetry-auto-export.exports]]
output = "dev-requirements.txt"
without = ["prod"]

[[tool.poetry-auto-export.exports]]
output = "prod-requirements.txt"
without = ["dev"]

Installation

This is a poetry plugin, so it's meant to be installed inside the global poetry environment, not your project environment like regular pacakges. See poetry's docs.

There are three ways of doing so.

The pipx way

If you are using pipx already, that's easy:

pipx inject poetry poetry-auto-export

The pip way

Otherwise, you can use the pip that comes with poetry. The difficulty is finding that pip! It's not the same one you get with poetry run pip. Here is a best effort guess:

On Linux:

~/.local/share/pypoetry/venv/bin/pip install poetry-auto-export

On Windows:

%APPDATA%\pypoetry\venv\bin\pip install poetry-auto-export

The poetry way

For some reason, this is discouraged by poetry.

poetry self add poetry-auto-export

Roadmap and contributing

The primary goal of the project is to make it more convenient to work with poetry projects in CI/CD and docker. Contributions towards this goal are welcome!

Roadmap:

  • more unit tests for the plugin
  • integration tests for the plugin
  • proper configuration parsing (note: typed dict and dataclasses can't support the with option, since it's a python keyword)
  • schema or exhaustive documentation of the supported configuration options

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_auto_export-0.2.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

poetry_auto_export-0.2.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file poetry_auto_export-0.2.2.tar.gz.

File metadata

  • Download URL: poetry_auto_export-0.2.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1021-azure

File hashes

Hashes for poetry_auto_export-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c97d58c7d075eebd21eedc7c2f5a874f4c3410c7e7e1075f777ed18890e7552d
MD5 5464170941b46480b4ff1c72db1c8697
BLAKE2b-256 613d85560ae99cb1a6dcae21f932db22b7f62d3d96771be37a377fb8b5deb4ab

See more details on using hashes here.

File details

Details for the file poetry_auto_export-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: poetry_auto_export-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1021-azure

File hashes

Hashes for poetry_auto_export-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 96896079257d96c50001de9e28a1c0a272389e3c64bc6fcf3966b7b6960419e3
MD5 3d5281a6d0f7b2fd92c01d21120845fe
BLAKE2b-256 2426b77ca5f26366194996d634b74346aa602c2bcda9832d964dc4257a0c4f6b

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