I have one project I'd like to publish as packages targeting two Python versions (3.6 and 3.8).
What I understand:
- How to install and activate different python versions using
pyenv
. - How to get
poetry
to create virtual environments that correspond to the chosen Python version. - How to setup
pyproject.toml
to specify the python version, manage dependencies, and publish a package using this configuration.
What I do not understand: how can I publish the same package for more than one Python version? I can't be the only one with this use-case right?
- Does need two
pyproject.toml
files? (one for each python version and set of corresponding dependencies...) - Are there established ways of doing this with Poetry, or are other tools/workflows necessary?
Edit
Doing a bit more digging, I found this https://python-poetry.org/docs/versions/#multiple-constraints-dependencies which looks like it might be relevant.
Here's the example at the link above.
[tool.poetry.dependencies]
foo = [
{version = "<=1.9", python = "^2.7"},
{version = "^2.0", python = "^3.4"}
]
I've also found you can specify the Python version using poetry add
like this...
poetry add cleo --python 3.6.10
Which adds dependencies in pyproject.toml
like this...
cleo = {version = "^0.8.1", python = "3.6.10"}
Going to experiment and see if this works.
question from:https://stackoverflow.com/questions/65945929/poetry-how-to-publish-project-packages-targeting-multiple-python-versions