https://pantsbuild.org/ logo
#general
Title
# general
a

ambitious-student-81104

01/11/2022, 2:38 AM
Hi Pants! I'm on Pants 2.8.0 and trying to onboard myself to
experimental_resolves_to_lockfiles = { default = "constraints.txt"}
. I have a few different requirements.txt files, say
**/requirements.txt
. How do I let pants auto-generate my lockfile based on the requirements files?
cc @happy-kitchen-89482
h

happy-kitchen-89482

01/11/2022, 6:06 PM
Ah, this isn't in my wheelhouse personally. Eric is the expert but he's out for a couple of days. @witty-crayon-22786, do you know this bit?
w

witty-crayon-22786

01/11/2022, 6:19 PM
hey @ambitious-student-81104! yea, not documented yet, since experimental. we’re hoping to stabilize it in
2.10.x
. to generate a lockfile once you’ve set that, you’d use
./pants generate-user-lockfile
a

ambitious-student-81104

01/11/2022, 6:34 PM
Ah, gotcha! Meanwhile what would you recommend for lockfile refresh? We aren't currently on Poetry but we know Pants has integration with Poetry. Our situation is that we have some requirements.txt files here and there, based on which we manually compile a
constraints.txt
file every now and then, no fixed refresh policy.
w

witty-crayon-22786

01/11/2022, 6:34 PM
the lockfile generated by
./pants generate-user-lockfile
replaces the need to manually create a lockfile
so, continuing to have multiple requirements files (however they get there) should be fine
a

ambitious-student-81104

01/11/2022, 6:35 PM
Copy code
❯ ./pants generate-user-lockfile
13:35:17.45 [INFO] Initializing scheduler...
13:35:17.67 [INFO] Scheduler initialized.
Unknown goal: generate-user-lockfile
Did you mean generate-lockfiles?
not supported in 2.8.0 yet right?
w

witty-crayon-22786

01/11/2022, 6:35 PM
um, lemme see.
oh: it’s in an experimental backend i expect. one sec.
yea: you need to add the
pants.backend.experimental.python
backend to
pants.toml
a

ambitious-student-81104

01/11/2022, 6:38 PM
Oh, cool! Now I'm getting
Copy code
❯ ./pants generate-user-lockfile
13:37:48.01 [INFO] Initializing scheduler...
13:37:48.23 [INFO] Scheduler initialized.
13:37:48.29 [WARN] No third-party requirements found for the transitive closure, so a lockfile will not be generated.
Where do I configure the places that it needs to look for
**/requirements.txt
?
My config is
experimental_lockfile ="constraints.txt"
tried
**/requirements.txt
which yielded the same output.
w

witty-crayon-22786

01/11/2022, 6:47 PM
the lockfile ends up used for all targets which are marked as using a resolve: in this case, you have a resolve named
default
i think that you’ll want to set the default resolve for targets as well (we’re going to make all of this easier in
2.10.x
, sorry)
…oh. whoops. i’m thinking of how it will be in the future. yea, in
2.8.x
, you actually have to specify the set of targets to include in the lockfile. so something like
./pants generate-user-lockfile ::
h

happy-kitchen-89482

01/11/2022, 6:51 PM
This is assuming you have a
python_requirements
target for each
requirements.txt
1
./pants tailor
should generate those for you if it hasn't already
a

ambitious-student-81104

01/11/2022, 6:59 PM
we have those, it's following the pattern of
Copy code
3rdparty/
   subdir/
      BUILD (with python_requirements(module_mapping={...}))
      requirements.txt
It failed on a resolver error, specifically for an internal dependency. In that particular requirements.txt file we have specified
--extra-index internal_pypi_address
already.
w

witty-crayon-22786

01/11/2022, 7:02 PM
yea: so that’s actually one of the precise reasons that this feature is experimental
this feature delegates to
poetry
, but afaik, it doesn’t support custom non-pypi indexes
before stabilizing, we’re going to switch to PEX to generate the lockfile
2
h

hundreds-father-404

01/13/2022, 9:50 PM
Hey Horus 🙂 It's confusing: there are two "user lockfile" features currently. 1.
[python].experimental_lockfile
which you can generate via
generate-user-lockfile
or manually if you'd like 2.
[python].experimental_resolve_to_lockfiles
, which is not really set up to work in Pants 2.8 and 2.9 - only some basic infrastructure was added. Hoping to stabilize in Pants 2.10
a

ambitious-student-81104

01/14/2022, 7:34 PM
Thanks Eric! Looks like we should table this until 2.10 because we will need to generate a lock file with internal dependencies.
h

hundreds-father-404

01/14/2022, 7:35 PM
Sg! What do you mean by "intenral dependencies"?
3 Views