I am wondering what is the best way to have certai...
# general
f
I am wondering what is the best way to have certain projects in a Python monorepo declaring a different version of a 3rd party dependency when the root requirements have been resolved to a single constrains file.
So say all projects depend on
package==1.0.0
, the
requirements.txt
has been resolved to
constraints.txt
and is used with
[python-setup].requirement_constraints
. Now, we’d like to add another project that is happy with all the resolved constraints, except it needs
package==0.9.9
. To fix this for that particular project, I just have to declare an explicit dependency as per docs.
Copy code
python_requirement_library(
    name="package_0_9_9",
    requirements=["package==0.9.9"]
)

python_source(...
    dependencies=[":package_0_9_9"])
However, now I cannot use constraints any longer since there is
package==1.0.0
in the
constraints.txt
(that is,
pip
will be confused — it won’t be able to install both
package==1.0.0
and
package==0.9.9
at the same time). I could automate stripping
package
out of the constraints when it’s generated (to avoid conflict for that project), but it feels hacky. Any better ideas?
e
Have you seen the warning callout here?: https://www.pantsbuild.org/docs/python-third-party-dependencies#user-lockfile It both describes the best you can do today and links to what you can do experimentally in 2.10.x and most likely stably in 2.11.x. AKA, you're just a bit early!
1
h
See https://www.pantsbuild.org/v2.10/docs/reference-python#section-enable-resolves, it's enabled in 2.10 🙂 Only we aren't widely publicizing because of the mentioned limitations
we'd love feedback on the feature
f
thanks, @hundreds-father-404! I’ll see how fast we’d be able to upgrade from 2.7
❤️ 1