Skip to content

Commit

Permalink
Enabled a means to proper pex caching so that future builds can be sped
Browse files Browse the repository at this point in the history
up.
  • Loading branch information
Avadhani Jonnavithula committed Nov 1, 2022
1 parent b099896 commit d895180
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pex/pex_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,11 @@ def _pex_binary_impl(ctx):
arguments += ["--no-index"]
if ctx.attr.disable_cache:
arguments += ["--disable-cache"]
else:
arguments += ["--pex-root", "~/.pex"]
if pex_tmp_dir_provided:
arguments += ["--tmpdir", pex_tmp_dir_provided]

for interpreter in ctx.attr.interpreters:
arguments += ["--python", interpreter]
for platform in ctx.attr.platforms:
Expand All @@ -217,15 +220,14 @@ def _pex_binary_impl(ctx):
arguments += ["--entry-point", main_pkg]
elif script:
arguments += ["--script", script]

arguments += [
# TODO set `--tmpdir` option within the build work dir so we stop putting temp files under `/tmp` and filling up root
"--sources-directory",
"{sources_dir}".format(
sources_dir = sources_dir.path,
strip_prefix = ctx.attr.strip_prefix.strip("/"),
),
"--pex-root",
"$(mktemp -d)" if ctx.attr.disable_cache else ".pex", # So pex doesn't try to unpack into $HOME/.pex
"--output-file",
ctx.outputs.executable.path,
]
Expand Down

0 comments on commit d895180

Please sign in to comment.