Quick question about 3rdparty dependencies. If an ...
# general
i
Quick question about 3rdparty dependencies. If an inline requirement is defined, will this override whatever is defined in the
constraints.txt
file?
h
Hey Connor, depends on which pip resolver you're using iirc. With the old resolver, constraints.txt always no matter what overrides. With the new resolver, pip will see that constraints.txt does not match the requirement and will error
Support for "multiple lockfiles" is coming soon-ish. It's my next major project after Bash support, Poetry support, and improving some error messages. Although I'm a bit distracted working on this Pycon talk, so probably won't get to it in April realistically
i
We are still on 1.26, which I'm assuming is the older pip resolver? I believe that was when you switched from pex to pip. All of our dependencies are defined as inline and our builds break a lot when random dependencies of dependencies get updated and I'm trying to fix that. I think the constraints file is the way to go, but it doesn't look like the versions I specify are being pulled in. I don't necessarily want to convert everything to a requirements.txt/constraints.txt right off the bat and would like a more rolling update approach.
Also congrats on the Pycon talk 😄
🐍 1
❤️ 1
h
Yeah 1.26 would be using the old pip resolver Indeed, a constraints.txt file can be used incrementally. It doesn't need to be fully exhaustive, even though that's a good place to end up for better reproducibility
i
Do I need to rebuild anything once I create the constraints file and add it to the toml file? I assume not
h
Nope, only set
[python-setup].requirement_constraints
and then Pants caching logic will kick in
i
Awesome, thanks!
❤️ 1
I can't seem to get the constraints file to work. Here is what I have: requirements.txt
Copy code
utm==0.4.2
BUILD
Copy code
python_requirements()
constraints.txt
Copy code
# This is the version of the transitive dependency that I want to resolve, but 5.0.5 is still being resolved
decorator==4.4.2
pants.toml
Copy code
[python-setup]
requirement_constraints = "%(buildroot)s/3rdparty/constraints.txt"
I've also turned on debug but don't see any logs related to a constraints file or anything like that
Oh also, this is the binary I'm trying to build
Copy code
python_binary(
  name='service',
  sources=['main.py'],
  zip_safe=False,
  dependencies=[
    # utm is brought in as a dependency in :impl
    ':impl',
  ],
  tags={'default-build', 'docker-build'}
)
and the command I run
Copy code
./pants -ldebug binary services/service
h
Maybe try using
3rdparty/constraints.txt
without
%(buildroot)s
. I hope that's not it and we would error if it was, but possibly relevant
i
No luck 😕
h
Ohhhh you're still using v1 Python, right? Constraints files are a v2 only engine feature 😬 It is supported in 1.26, although better in 1.30
Note that you can still use v1 for everything else, aka "mixed mode". From the 1.30 docs https://www.pantsbuild.org/v1.30/docs/how-to-upgrade-to-the-v2-engine
i
AH. that would do it. Was just about to ask about mixed mode. Ok I'll give that a try. Thank you!
❤️ 1
h
Do feel free to ask questions if/when you run into things with switching to v2! I know it can be tricky to make changes like that
i
Yeah I ran into an issue with our custom plugin. I don't have the cycles to rewrite it currently, but I'll circle back around in a week or so. I definitely want to upgrade because there are other features in the v2 engine that we want to use.
1