Skip to content

Commit

Permalink
Merge pull request #10 from avadhanij6si/INFRA-1019-bazel-pex-optimiz…
Browse files Browse the repository at this point in the history
…ation

[INFRA-1019] Bazel pex optimization
  • Loading branch information
georgeliaw authored Nov 1, 2022
2 parents b099896 + d895180 commit 8e7d7a3
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 8e7d7a3

Please sign in to comment.