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

bored-energy-25252

11/23/2022, 9:19 AM
./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

rhythmic-morning-87313

11/23/2022, 9:28 AM
https://github.com/pantsbuild/pants/issues/17398 It seems that Pants 2.15 will introduce selective exports!
b

bored-energy-25252

11/23/2022, 9:38 AM
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

rhythmic-morning-87313

11/23/2022, 9:39 AM
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

bored-energy-25252

11/23/2022, 9:40 AM
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

rhythmic-morning-87313

11/23/2022, 9:48 AM
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

happy-kitchen-89482

11/23/2022, 4:10 PM
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

bored-energy-25252

11/24/2022, 6:37 AM
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

happy-kitchen-89482

11/25/2022, 1:43 PM
So “export” to an already existing virtualenv?
Yeah today Pants creates a virtualenv
b

bored-energy-25252

11/28/2022, 3:54 PM
So “export” to an already existing virtualenv?
Yes
h

happy-kitchen-89482

11/28/2022, 4:33 PM
That might be tricky
b

bored-energy-25252

11/29/2022, 1:36 AM
So, I suggest there should be a
pip freeze
equiv in pants.
h

happy-kitchen-89482

11/29/2022, 1:43 AM
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

bored-energy-25252

11/29/2022, 1:53 AM
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

happy-kitchen-89482

11/29/2022, 4:06 AM
The spec for lockfile is part of PEX actually. It’s just JSON. Pants adds some front matter.
👍 1
b

bored-energy-25252

11/29/2022, 5:54 AM
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

happy-kitchen-89482

12/06/2022, 3:41 AM
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

bored-energy-25252

12/06/2022, 3:55 AM
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.
7 Views