python-poetry / python-poetry/poetry-plugin-export

`poetry export --format requirements.txt …` export a commit hash of an installed repository instead of the initial used tag reference.

Open
#276 13 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
335
Forks
57
Avg merge
1h 23m
Merged PRs (30d)
3

Description

Poetry is used to build a package that will be installed in a Docker image:

# Build
$ poetry build --format wheel
$ poetry export --format requirements.txt --output constraints.txt --without-hashes

# Export the .whl and constraints.txt file (multi-stage build)

# Install
$ pip install --no-cache-dir ./$APP_NAME*.whl --constraint constraints.txt

As of today, it was working well. But we've added a new package using this (as an example) poetry add git+https://github.com/me/new-package#1.6.0 (new-package = {git = "https://github.com/me/new-package", rev = "1.6.0"} is present in the [tool.poetry.dependencies] of the pyproject.toml) and when we tried to install the generated wheel by Poetry using an exported requirements.txt, we ended up with this error:

The conflict is caused by:
    my-app 1.0.0 depends on new-package 1.6.0 (from git+https://github.com/me/new-package@1.6.0)
    The user requested (constraint) new-package
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

If we take a look at the constraints.txt file, we can see that line: new-package @ git+https://github.com/me/new-package@c3e22d63f50256f588bd1438eedcd761a1507a43 ; python_version >= "3.11" and python_version < "4.0", which doesn't match the initial git+https://github.com/me/new-package@1.6.0.

Workarounds

If we replace this line by new-package @ git+https://github.com/me/new-package@1.6.0 the problem disappear.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown poetry build and poetry export commands, using the git dependency in pyproject.toml. Inspect the generated constraints.txt and compare its commit-hash reference with the original 1.6.0 tag; done means the exported requirement preserves the usable reference and pip can install the wheel with the constraints file.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, git, python
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.