poetry-plugin-export
poetry-plugin-export copied to clipboard
Export always includes common dev and extras requirements
-
[x] I am on the latest Poetry version.
-
[x] I have searched the issues of this repo and believe that this is not a duplicate.
-
[x] If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: macOS Mojave 10.14.3
-
Poetry version: 1.0.5
-
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/shparki/36f5cabc9d99f10cc511eb0e186f7473
Issue
This issue seems pretty simple at the front but has caused me a bunch of grief.
TL;DR: No requirements are technically specified, and yet when I perform a basic poetry export -f requirements.txt --without-hashes > requirements.txt
the following is set in the requirements.txt:
botocore==1.15.16
docutils==0.15.2
jmespath==0.9.5
python-dateutil==2.8.1
s3transfer==0.3.3
six==1.14.0
urllib3==1.25.8; python_version != "3.4"
with the folloing pyproject.toml:
[tool.poetry]
name = "my-project"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.7"
awscli = {version = "^1.18.16", optional = true}
[tool.poetry.dev-dependencies]
boto3 = "^1.12.16"
[tool.poetry.extras]
"aws" = ["awscli"]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
I have deleted the pyproject.toml and re-performed poetry update
in an attempt to create a fresh poetry.lock, and yet it keeps outputting these requirements. After some experimenting, I believe this is due to those being common requirements between dev and extras. Although those shouldn't be included in a basic export, somehow their common requirements are included. I confirmed this by commenting out the extras and updating and then commenting out the dev requirements and updating and both times the requirements.txt is empty.
I believe this functionality is a bug rather than a feature request due to the inclusion of the --dev and --extras parameters in poetry export to specify all dev/extras requirements to be included.
Steps to Reproduce
- Create a blank project
- Define some dependencies as 'dev' and none for core dependencies(note, if you export requirements.txt at this point, it will be empty; for this step, I did boto3 in testing)
- Define some extra dependencies that have common dependencies as some of the dev dependencies. (for this step, I did awscli for testing)
- Export core requirements. It should be empty, but in reality, it will contain common dependencies between dev and extras (in testing, mine included botocore, which I knew was a common dependency for boto3 and awscli).
Yep, same behaviour here. If the poetry.lock
has been updated with optional dependencies, this dependencies will be in the requirements.txt
. Since there is a --extras
option I think it's a bug.
Another use case: I ran into this issue while trying to write some fiddly tests that inspect extras and uninstall/reinstall packages to assert about imports being tolerant to missing packages. My goal was to generate a bunch of requirements.txt
for different combinations of extras, then in a shell script loop over them and:
- uninstall everything (adapted from an SO post, if you're curious)
-
pip install
the currentrequirements.txt
- try to import my package
I ended up having to inspect pyproject.toml and poetry.lock myself to generate those requirements.txt
s. I didn't end up using export
at all. :(
I'm having trouble with this as well.
Since we can't define extras using dev-dependencies, I also put these dependencies as optional, but then poetry export always adds these optional dependencies to the requirements output. I tried using -E ""
to tell poetry not to include any extras, but it doesn't accept an empty value.
Related / duplicated of python-poetry/poetry#1989
export today is empty as expected, this is fixed.