Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poetry export requirements.txt produces an invalid constraint file #126

Closed
4 tasks done
shadycuz opened this issue Sep 28, 2022 · 6 comments
Closed
4 tasks done

poetry export requirements.txt produces an invalid constraint file #126

shadycuz opened this issue Sep 28, 2022 · 6 comments

Comments

@shadycuz
Copy link

  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

Before upgrading to poetry 1.2.1, I was using 1.1.4. In my CICD pipeline I had nox installing my dependencies by having poetry export a requirements.txt. This was the command nox would run.

$ poetry export --with dev --format=requirements.txt --without-hashes --output=/tmp/tmpzi691uyz

It then ran this command:

$ python -m pip install --constraint=/tmp/tmpke1yt5pq flake8 flake8-black flake8-bugbear flake8-import-order

This used to work correctly but now I get this:

$ nox > Command python -m pip install --constraint=/tmp/tmpke1yt5pq flake8 flake8-black flake8-bugbear flake8-import-order failed with exit code 1:
DEPRECATION: Constraints are only allowed to take the form of a package name and a version specifier. Other forms were originally permitted as an accident of the implementation, but were undocumented. The new implementation of the resolver no longer supports these forms. A possible replacement is replacing the constraint with a requirement. Discussion can be found at https://github.com/pypa/pip/issues/8210
ERROR: Constraints cannot have extras
nox > Session lint-3.9 failed.

When I cat the requirements file I see coverage twice (its the only dependency I have where I use an "extra").

coverage==6.4.4 ; python_version >= "3.8" and python_version < "4.0"
coverage[toml]==6.4.4 ; python_version >= "3.8" and python_version < "4.0"

I don't know why its listed twice. I do know that the generated file does install correctly from a new venv, so its only broken when used as a constraint file.

@Secrus Secrus transferred this issue from python-poetry/poetry Sep 28, 2022
@Secrus
Copy link
Member

Secrus commented Sep 28, 2022

Moved the issue to export plugin repo, as it belongs here. As far as I am aware, export produces valid requirements.txt file, not constraint file. See #125.

@dimbleby you know more about export plugin. Could you confirm?

@dimbleby
Copy link
Contributor

yeah, I think this just duplicates #125

@shadycuz
Copy link
Author

Even more surprising, I have removed all instances of coverage[toml] and replaced it with coverage and yet I still end up with the coverage[toml] in the poetry.lock file. I even removed and reinstalled my poetry virtual environment. =/

@Secrus
Copy link
Member

Secrus commented Sep 28, 2022

Even more surprising, I have removed all instances of coverage[toml] and replaced it with coverage and yet I still end up with the coverage[toml] in the poetry.lock file. I even removed and reinstalled my poetry virtual environment. =/

You have pytest-cov in your dependencies and it requires coverage[toml] itself.

@shadycuz
Copy link
Author

I will close this as its a duplicate of #125 as mentioned above. If you are trying to do what I am doing, which is to get only the dev dependencies installed then you can now use poetry --only dev, which is what I switched to in my export command poetry export --only dev. More details for nox users here.

@neersighted
Copy link
Member

Worth noting (obviously, this is also stated on the linked issues) that constraints.txt is not requirements.txt, for those that come here in the future. There are differences in what is allowed in the format, and proper support will require a new exporter. sed is a workaround in the mean time for most cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants