Hello again - another pex question. Is there an ea...
# general
a
Hello again - another pex question. Is there an easy way to create a venv for a pex that was built without
--include-tools
or
--venv
? I found a roundabout way to do this, is there something simpler?
Copy code
pex --include-tools -o just-tools.pex
PEX_TOOLS=1 PEX_PATH=the-pex-without-tools.pex ./just-tools.pex venv my-venv
While can build our user's newer pexes with
--include-tools
, we also need to support their older pexes which were not built with tools.
e
You can use the pex-tools console script. When you install pex in a venv you get
pex
,
pex3
and
pex-tools
. It's then
pex-tools any.pex ...
Do you use the
pex
console script or the Pex PEX?
a
ok that makes a lot more sense 🙂. we use the
pex
console script during build. i think we install
pex
in the run environment as well so
pex-tools
should be available.
e
For the Pex PEX its:
Copy code
jsirois@Gill-Windows:~ $ curl -fsLO <https://github.com/pantsbuild/pex/releases/download/v2.1.118/pex>
jsirois@Gill-Windows:~ $ chmod +x pex
jsirois@Gill-Windows:~ $ ./pex cowsay -ccowsay -ocowsay.pex
jsirois@Gill-Windows:~ $ PEX_SCRIPT=pex-tools ./pex cowsay.pex venv here
jsirois@Gill-Windows:~ $ here/pex 'Moo!'
  ____
| Moo! |
  ====
    \
     \
       ^__^
       (oo)\_______
       (__)\       )\/\
           ||----w |
           ||     ||
a
nice. looks like we do have
/usr/local/bin/pex-tools
in our runtime environment so I can just use that.
e
Great
Just think about / be careful with which Python always. If you only use one - no issues. If you use many, consider being explicit with
--python this/one/here/python
etc options when you operate using the generic tools.
The `pex-tools`script tries to do the right thing and use the
--interpreter-constraint
embedded in the PEX file you're operating against, but if you don't use
--interpreter-constraint
care may be needed depending on your environment.
a
ah ok. we use
--python=
but not
--interpreter-constraint=
. at least currently we only have one python in each runtime image and have separate images for different python versions.