I have a Python project that depends on two packages moduleA and moduleB. I have the following pyproject.toml:
[project]
name = "meta-motor"
version = "3.1.0.dev"
dependencies = [
"moduleA==1.0.0"
]
[project.optional-dependencies]
dev = [
"moduleB==1.0.0"
]
with moduleA depending on moduleC>=1.0.0 and moduleB depending on moduleC==1.1.0.
I compile my requirements.txt and dev-requirements.txt like this:
$ pip-compile -o requirements.txt pyproject.toml
$ pip-compile --extra dev -o dev-requirements.txt pyproject.toml
With this, I get
requirements.txt
moduleA==1.0.0
# via pyproject.toml
moduleC==1.2.0
# via moduleA
dev-requirements.txt
moduleB==1.0.0
# via pyproject.toml
moduleA==1.0.0
# via pyproject.toml
moduleC==1.1.0
# via
# moduleB
# moduleA
As you can see, the moduleC version is different in both requirements.txt files.
How can I solve this so I have moduleC==1.1.0 in both ?
I could specify moduleC==1.1.0 in my pyproject.toml, but this is not practicable for larger project with lots of dependencies like this.
This PR #1936 introduces
-c/--constraintoption topip-compilewhich allows you to passrequirements.txtas a constraint file when compilingdev-requirements.txt, for example:This should resolve the issue.