`./pants export ::` only supports exporting all re...
# general
b
./pants export ::
only supports exporting all resolves, I suggest that
./pants freeze --resolve=xyz
should be supported. As a alternative, we can implement
freeze
in the following way: https://github.com/da-tubi/pants-minimal-freeze
r
https://github.com/pantsbuild/pants/issues/17398 It seems that Pants 2.15 will introduce selective exports!
b
Well, even with selective exports, I still need the feature of exporting to a specific virtual environtment.
I use pyenv, And I found pyenv managed virtual environments works well with Intellij Idea and VSCode
r
doesn't
./pants export
generate virtualenvs that can be used in VSCode?
i'm already using exported venvs for VSCode, Vim CoC, etc. without any problem..
b
But for VSCode Jupyter Plugin, the exported virtualenv does not work!
And for PyCharm, it is not very convenient to locate the exported virtual environment.
For VSCode, there a setting: https://github.com/da-tubi/pants-minimal-freeze/blob/main/.vscode/settings.json
With the setting, I do not need to select the python interpreter manually.
r
hmm.. i have no experience with VSCode Jupyter plugin yet..
maybe it has a separate interpreter path setting
sometimes the interpreter path must be an absolute path instead of a relative path starting with "dist/export/...", even depending on which Python tool you use
so I always set the interpreter/tool paths using absolute ones
h
Hi @bored-energy-25252, can you clarify what you mean by “exporting to a specific virtual environment”? As @rhythmic-morning-87313 pointed out, Pants 2.15 will have the
--resolve
flag on
export
, exactly as you suggested
b
by “exporting to a specific virtual environment”
It means, exporting to a virtual environment managed by pyenv or conda.
export
can only export to a fixed path virtualenv.
h
So “export” to an already existing virtualenv?
Yeah today Pants creates a virtualenv
b
So “export” to an already existing virtualenv?
Yes
h
That might be tricky
b
So, I suggest there should be a
pip freeze
equiv in pants.
h
Which would emit a requirements.txt or something like that?
We already have the lockfile, so we could convert that to something pip can ingest
b
We already have the lockfile, so we could convert that to something pip can ingest
A good idea!
Is there any spec on the lock file? It would be nice to have a tool like
lock
. And one could use
lock install xxx.lock
to install the dependencies in the lockfile.
Like PEX, the spec for lockfile could be independent from pants.
h
The spec for lockfile is part of PEX actually. It’s just JSON. Pants adds some front matter.
👍 1
b
Tried
pex --lock 3rdparty/python/default.lock
, it does not work well with the pants-generated lockfile.
Copy code
pex.resolve.lockfile.json_codec.ParseError: The lock file at 3rdparty/python/default.lock does not contain valid JSON: Expecting value: line 1 column 1 (char 0)
Do you think
pex --freeze 3rdparty/python/default.lock
,
pex --freeze xyz.pex
is a good idea?
With
pex --freeze
available, we can
Copy code
pip install `pex --freeze xyz.lock`
to install the necessary dependencies in a created virtualenv. Further more,
pex --export xyz.lock
should be a better command to replace `pip install `pex --freeze xyz.lock``
Copy code
pex3 lock export 3rdparty/bark.lock
Thanks! It is in PEX3. Now I just need some commandlinefu to strip the leading part of the lockfile generated by pants!
👀 1
h
Hey @bored-energy-25252, just checking if you’ve had any luck with this, or do you want/need to open a feature request ticket for it?
b
Let me open a feature request ticket for pants.
See https://github.com/pantsbuild/pants/issues/15940 there is already a issue. Let me comment there.