A command-line utility that allows you to quickly and easily copy dependencies from a Poetry pyproject.toml file to a pip requirements.txt file.
Project description
txtoml
A command-line utility that allows you to quickly and easily copy dependencies from a Poetry pyproject.toml file to a pip requirements.txt file.
Installation
$ pip install txtoml
Usage
$ txtoml [SOURCE] [OUTPUT]
where [SOURCE]
is the path to a pyproject.toml
file and [OUTPUT]
is the path to a requirements.txt
file (txtoml
will create a requirements.txt
file in the absence of one at the specified path, but the pyproject.toml
file must
already exist).
For example, this:
# pyproject.toml
[tool.poetry.dependencies]
python = "^3.9.0"
Django = "^3.1.5"
click = "^7.1.2"
toml = "^0.10.2"
pathvalidate = "^2.3.2"
path = "^15.0.1"
colorama = "^0.4.4"
dj-database-url = "^0.5.0"
after running this:
$ txtoml pyproject.toml requirements.txt
becomes this:
# requirements.txt
# Generated by txtoml on Fri Jan 29 at 15:48:43 UTC
# Dependencies
Django>=3.1.5, <4.0.0
click>=7.1.2, <8.0.0
toml>=0.10.2, <0.11.0
pathvalidate>=2.3.2, <3.0.0
path>=15.0.1, <16.0.0
colorama>=0.4.4, <0.5.0
dj-database-url>=0.5.0, <0.6.0
If you noticed the python
dependency from the pyproject.toml
file isn't present in the requirements.txt
file,
that's intended behavior. Poetry automatically includes it in pyproject.toml
files it generates, but pip will throw
an error if you include it in a requirements.txt
, so txtoml excludes it during the copying process.
Development Dependencies
You can append the --include-dev
flag to the txtoml
command to include dependencies that are listed as development
dependencies in the pyproject.toml
file.
For example, this:
# pyproject.toml
[tool.poetry.dependencies]
python = "^3.9.0"
Django = "^3.1.5"
click = "^7.1.2"
toml = "^0.10.2"
pathvalidate = "^2.3.2"
path = "^15.0.1"
colorama = "^0.4.4"
dj-database-url = "^0.5.0"
[tool.poetry.dev-dependencies]
Sphinx = "^3.4.3"
sphinx-rtd-theme = "^0.5.1"
sphinx-click = "^2.5.0"
after running this:
$ txtoml pyproject.toml requirements.txt --include-dev
becomes this:
# requirements.txt
# Generated by txtoml on Fri Jan 29 at 15:52:32 UTC
# Dependencies
Django>=3.1.5, <4.0.0
click>=7.1.2, <8.0.0
toml>=0.10.2, <0.11.0
pathvalidate>=2.3.2, <3.0.0
path>=15.0.1, <16.0.0
colorama>=0.4.4, <0.5.0
dj-database-url>=0.5.0, <0.6.0
# Development dependencies
Sphinx>=3.4.3, <4.0.0
sphinx-rtd-theme>=0.5.1, <0.6.0
sphinx-click>=2.5.0, <3.0.0
Additional notes
txtoml does not support dependencies hosted on a repository other than the Python Package Index, nor does it support more complex Poetry dependency specifications such as Python restricted dependencies or environment markers.
License
txtoml is released under the MIT License.
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.