python-poetry / python-poetry/poetry

Force locking a specific version without adjusting constraints in pyproject.toml

Open
#2,758 7 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

I have pyproject.toml and poetry.lock files and I'd like to be able to update the poetry.lock file so it uses a specific version of package without having to set or update an explicit constraint in the pyproject.toml file.

For example, I have the following in my pyproject.toml:

[tool.poetry.dependencies]
torch = "^1.3"

I want to update my poetry.lock file to use torch 1.5.0 but still use the ^1.3 constraint. While I can certainly run poetry update --lock torch, this will install the latest constraint compatible version of torch which would be 1.6.0.

The way I think about this is that I want to be able to set an additional constraint that would further limit which torch (and associated packages) would be considered during the poetry update --lock torch call.

Context

I'm building a docker image where I already have torch pinned at a certain version. When I install the poetry dependencies, the poetry.lock file needs to have a corresponding version as to not download torch again at a different version.

If I can run a command such as poetry update --lock torch==1.6.0 prior to poetry install, then I can easily make torch version specific images.

I also want to specify torch in the pyproject.toml file because it is a dependency of the project itself, which can be used as a package in other projects. Stating that torch is a dependency in some documentation instead of an explicit dependency isn't a great solution.

Contributor guide

Open the contributing guide

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

Start with the pyproject.toml and poetry.lock workflow described in the issue, then trace the poetry update --lock command and its package-version handling. Determine how an additional version constraint should interact with the existing ^1.3 constraint and related packages; done means the lock file selects the requested compatible version without changing pyproject.toml.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.