Would it be a good fit, if pants would provides th...
# general
f
Would it be a good fit, if pants would provides the same functionality like pip-tools? Primarily I'm thinking about the part where you specify your dependencies (either version pinned or not) in
*.in
files and
pip-compile
renders the
*.txt
requirements files. Maybe this functionality is also already implemented in pants, or it might be a good feature request ... I'm just thinking out loud to further understand pantsbuild. So, any comments appreciated 🙂
r
I have never used
pip-compile
but googling I think you are looking for the info about exact version and the transitive dependencies or something else?
e
Lockfile is the keyword you're missing in your doc search: https://www.pantsbuild.org/docs/python-lockfiles
đź’Ż 1
f
yeah, it's related to the lockfiles, also transitive dependencies - for me the advantage of the
*.in
files is that my intended dependencies are clearly stated. f.e. if I install just django, I end up with:
Copy code
asgiref==3.7.2
Django==4.2.4
sqlparse==0.4.4
in the dependencies so if I'd just do now
pip freeze > requirements.txt
I can't tell anymore if I did only
pip install django
or the also the others. with this simple example of course it's not a big deal, but with a growing code base it's really hard to determine what was the intended dependency and what wasn't.
so, that's what the
*.in
files are providing to me - I could just have
django
or of course f.e.
django==4.2.4
in it ... so, the files generated by
pip-compile
include also the origin of a dependency and it's (easily) visible what caused it
b
Pants offers this: the
python_requirement
targets (and related ones) can be used to specify the “real” dependencies, and the generated lock file includes all the transitive ones.
e
For example, look at any of the requirements txt files here (equivalent to in files) and the corresponding lock file: https://github.com/pantsbuild/pants/tree/main/3rdparty%2Fpython
The lock is information overload compared to the pip-compile output, but it's correspondingly more useful, and Pants leverages the extra info to perform lock subsetting (described in the doc I linked).
f
Ok makes sense, thx to you both
g
can also use poetry-based
pyproject.yaml
to get a very similar thing with poetry_requirements.
f
yeah true, forgot about this already (ditched poetry again a while ago)