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

nice-florist-55958

07/14/2022, 4:52 PM
The
export
goal is confusing me a bit. It accepts an (undocumented?)
python_requirement(s)
target as its first argument, and then prints a message suggesting it is building a venv from only the requirements specifically owned by that target, with versions obtained from the resolve it too references. But then it proceeds to export the entire resolve in dist/export/python/virtualenvs. Exporting the entire resolve is what I'm after, but it means as the cmd works now, you can get that behavior by exporting any
python_requirement
target that references the resolve. By chance do resolves themselves have implicitly defined targets that I can refer to instead (for clarity in shell scripts)? The reason I am bringing this up at all is because if I
./pants export
without any target, it only exports virtualenvs for the toolset (mypy, black, etc.), so seems I need to do it this way (as an aside: it proceeds to export all the tool venvs anyway, but at least I get the resolve's venv I wanted 🙂 it just takes a little extra time 😞 )
c

curved-television-6568

07/14/2022, 7:29 PM
There's
./pants export ::
if export for all your resolves are ok. Also, to not export venv for tools, theres a option per tool, like
[black].export = false
n

nice-florist-55958

07/14/2022, 8:41 PM
Thank you Andreas, didn't know about those options. The reason for having to write the lockfile to disk (for
generate-lockfiles
) is because Pex would try to resolve it from PyPI instead of internal repo (there is some thread about it, not sure if it's even relevant anymore in v2.13). I assume this option only applies to
export
goal and not
generate-lockfiles
Regarding the first point, I'm still confused about what Pants is actually trying to do. When you supply a target, it prints a message indicating it will only export the subset of the resolve that is directly referenced by the
python_requirements
target, but then it writes the entire resolve (which is a good thing, but it's confusing because 1) the contradictory info msg and 2) if you have multiple
python_requirements
participating in a resolve, then you have to make a conscious choice of which one to "export" (either will do, as either leads to the resolve being exported), which is a bit odd feeling.
h

happy-kitchen-89482

07/17/2022, 12:42 AM
Hey, yeah,
export
may be a bit of a mess, or at least, poorly documented. As far as I can tell from the code (I wrote this but don't remember all the details)
./pants export <targets>
will export the requirements needed (directly or indirectly) by those targets. They don't have to be
python_requirements
targets.
Are you setting
[python].run_against_entire_lockfile = True
? That might explain why you're actually getting the entire lockfile
Possibly
export
should be reworked to take the lockfile name(s) as an argument. The reason is doesn't is that currently
export
is modeled as a generic mechanism that takes targets and exports whatever a backend thinks is appropriate. In the python case that is virtualenvs, but it could include generated code (the idea is for this to supersede export-codegen) or any other thing for which the concept of "export" makes sense.
But since lockfiles are a fairly general concept, possibly we should have an
export-lockfiles
goal that does just that, and takes resolve names
h

hundreds-father-404

07/17/2022, 1:47 PM
Possibly export should be reworked to take the lockfile name(s) as an argument.
Yes, it should. Behave like generate-lockfiles. It's way too hard to quickly on the CLI say you only want one specific lockfile exported
export
was added before lockfiles were fully a thing, so the CLI semantics weren't optimized for it
3 Views