If I wanted to have one lockfile per `pyproject.to...
# general
g
If I wanted to have one lockfile per
pyproject.toml
is there any way of doing this other than enumerating them "by hand" in
pants.toml
? I have hundreds of packages in a monorepo.
Copy code
[python]
interpreter_constraints = ['>=3.9,<3.11']
enable_resolves = true
default_resolve = "python-default"

[python.resolves]
python-default = "python-default/pants.lock" 
package-a = "package-a/pants.lock"
package-b = "other/package_b/pants.lock"
...
b
just so you’re aware (and to give a personal anecdote) - pants can support many lockfiles, but getting it to do this can be tricky. I initially went down the multiple-lockfile route in my own project, but after thinking about it (and because i don’t have that many third party dependencies in my code) i decided it was probably going to be much simpler to use a single requirements.txt (read: single lockfile) for third party dependencies across my entire repo and that’s it. some good reading on this is here: https://www.coinbase.com/nl/blog/part-2-building-a-python-ecosystem-for-efficient-and-reliable-development (part 1 is here: https://www.coinbase.com/blog/building-a-python-ecosystem-for-efficient-and-reliable-development but part 2 does a good job of outlining the pros and cons of single/multiple lockfiles in your repository)
g
@bright-monitor-59146 Thanks for the tip. I think for initial adoption of using multiple lock files and over time converging to a single lock file (wherever possible). Hopefully worst case we have 2-3 lock files. I tried resolving everything in our current mono repo to a single lockfile and there was a ton of conflicts. I came up with this for now:
Copy code
for f in ./**/pyproject.toml; do
    dir=$(dirname $f)
    package_name=$(basename $dir)
    echo "${package_name} = \"${dir#./}/pants.lock\""
done
not ideal, but I think should work nicely for day 1.
b
yeah i gotcha
g
Any particular gotchas I should look out for? I totally understand going with 100+ lock files is going to be suboptimal.
b
check the part 2 link i sent, they do a waaaay better job of explaining the pitfalls
👍 1