Change Pex cache dir from ~/.pex to another location

718 views
Skip to first unread message

Ashish Vidyarthi

unread,
Sep 18, 2014, 2:30:25 PM9/18/14
to pants...@googlegroups.com, Ashish Vidyarthi
Hello Folks,

I see that when I use pex to create a executable, it creates a cache directory in user home (~/.pex).

pex -r sphinx -e sphinx:main -o sphinx.pex

I would like to isolate this per project. Is there an environmental variable that can be used to affect the location where the pex cache directory is created?

Regards,
Ashish

John Sirois

unread,
Sep 18, 2014, 2:39:32 PM9/18/14
to Ashish Vidyarthi, pants-devel
Yes - `PEX_ROOT`.  See here:

And - for example:
jsirois@gill ~/dev/3rdparty/pants (master) $ rm -rf pants.pex ~/.pex
jsirois@gill ~/dev/3rdparty/pants (master) $ PEX_ROOT=/tmp/pex_root ./pants
...
jsirois@gill ~/dev/3rdparty/pants (master) $ ls ~/.pex
ls: cannot access /home/jsirois/.pex: No such file or directory
jsirois@gill ~/dev/3rdparty/pants (master) $ ls /tmp/pex_root/
install
jsirois@gill ~/dev/3rdparty/pants (master) $ ls -1 /tmp/pex_root/install | head
ansicolors-1.0.2-py2-none-any.whl.4452225625be802319a1e1ca440bf01b18621b6f
antlr_python_runtime-3.1.3-py2-none-any.whl.5339272f968cce224cceea611988dcf4b1bfeeac
argparse-1.2.1-py2-none-any.whl.f1be776ab1f64c6f7d964c931ed4e39f6d57460e
cov_core-1.14.0-py2-none-any.whl.35f108534cfb7d13414b745a3ffbcd22b2cca19c
coverage-3.7.1-py2.6-linux-x86_64.egg.03796ae00d9c388b3aef80a0dfa8887564a46cb9
coverage-3.7.1-py2.6-macosx-10.4-x86_64.egg.7c995f1e974b1c58be32ccc9703d70724a33894a
lockfile-0.9.1-py2-none-any.whl.b8138aa273924bb02232730efa0ce4838bde143f
Markdown-2.1.1-py2-none-any.whl.9cf8ebb68d6f65cc752e7c94fccd13a291eb4ab7
pex-0.7.0-py2.py3-none-any.whl.1528dd6e325a4178651c50d45cba558709e6df75
psutil-1.1.3-py2.6-linux-x86_64.egg.7e211e03eee41bea90d3daf3c78e46e16e2df252

But beware - the root will revert to default if you run the pex w/o PEX_ROOT:
jsirois@gill ~/dev/3rdparty/pants (master) $ ./pants.pex
...
jsirois@gill ~/dev/3rdparty/pants (master) $ ls ~/.pex
install

Andy Reitz

unread,
Sep 18, 2014, 3:52:37 PM9/18/14
to John Sirois, Ashish Vidyarthi, pants-devel
Should we add PEX_ROOT to this doc?


If so, I'll file an issue.

-Andy.

John Sirois

unread,
Sep 22, 2014, 12:35:35 AM9/22/14
to Andy Reitz, Ashish Vidyarthi, pants-devel
I think it would be better to add a pointer over to pantsbuild/pex [1][2], there are alot of env vars and it seems like a losing battle to try document them in pants land at all:
jsirois@gill ~/dev/3rdparty/pex (master) $ find pex/ -name "*.py" | xargs grep PEX_ | sed -r -e "s|.*\b(PEX_[-_A-Z]+)\b.*|\1|" | sort -u
PEX_ALWAYS_CACHE
PEX_COVERAGE
PEX_FORCE_LOCAL
PEX_INHERIT_PATH
PEX_INTERPRETER
PEX_MODULE
pex/pex.py:      for key in filter(lambda key: key.startswith('PEX_'), os.environ):
PEX_PROFILE
PEX_PROFILE_ENTRIES
PEX_PROFILE_SORT
PEX_ROOT
PEX_TEARDOWN_VERBOSE
PEX_VERBOSE

Larry Hosken

unread,
Sep 22, 2014, 12:11:29 PM9/22/14
to John Sirois, Andy Reitz, Ashish Vidyarthi, pants-devel
Filed an issue against pex project: https://github.com/pantsbuild/pex/issues/13

Andy Reitz

unread,
Sep 23, 2014, 2:34:18 AM9/23/14
to Larry Hosken, John Sirois, Ashish Vidyarthi, pants-devel
Thanks Larry.

-Andy.
Reply all
Reply to author
Forward
0 new messages