Skip to content

Commit

Permalink
Merge pull request #7 from avadhanij6si/pex-2.1.28
Browse files Browse the repository at this point in the history
Pex 2.1.28
  • Loading branch information
georgeliaw authored Dec 22, 2021
2 parents 5948aa3 + c0a6914 commit cc2b53f
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions pex/pex_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,13 @@ def _pex_binary_impl(ctx):
)

sources_dir = ctx.actions.declare_directory("{}.sources".format(ctx.attr.name))

pex_tmp_dir_provided = ctx.configuration.default_shell_env.get('PEX_TMP_DIR')
# Create resource directory and dump files into it
# Relocate files according to `strip_prefix` if necessary and get all files into the base resource directory
# Cleanup lingering files to prevent them from being added to the pex
# Create tmpdir for pex, if one is provided
# Add `__init__.py` files to make the modules findable by pex execution
ctx.actions.run_shell(
mnemonic = "CreateResourceDirectory",
outputs = [sources_dir],
inputs = runfiles.files.to_list(),
command = 'mkdir -p {sources_dir} && rsync -R {transitive_files} {sources_dir} \
cmd_to_run = 'mkdir -p {sources_dir} && rsync -R {transitive_files} {sources_dir} \
&& if [ "{strip_prefix}" != "" ] && [ -n "$(ls -A {sources_dir}/{strip_prefix})" ]; then cp -R {sources_dir}/{strip_prefix}/* {sources_dir}; fi \
&& if [ "{strip_prefix}" != "" ]; then rm -rf {sources_dir}/{strip_prefix}; fi \
&& if [ -d {sources_dir}/{genfiles_dir}/{strip_prefix} ] && [ -n "$(ls -A {sources_dir}/{genfiles_dir}/{strip_prefix})" ]; then cp -R {sources_dir}/{genfiles_dir}/{strip_prefix}/* {sources_dir}; fi \
Expand All @@ -182,22 +179,32 @@ def _pex_binary_impl(ctx):
transitive_files = " ".join([file.path for file in runfiles.files.to_list()]),
genfiles_dir = ctx.configuration.genfiles_dir.path,
genfiles_parent_dir = ctx.configuration.genfiles_dir.path.split("/")[0],
strip_prefix = ctx.attr.strip_prefix.strip("/"),
),
strip_prefix = ctx.attr.strip_prefix.strip("/"))
if pex_tmp_dir_provided:
cmd_to_run += " && mkdir -p {}".format(pex_tmp_dir_provided)
ctx.actions.run_shell(
mnemonic = "CreateResourceDirectory",
outputs = [sources_dir],
inputs = runfiles.files.to_list(),
command = cmd_to_run,
)

pexbuilder = ctx.executable._pexbuilder
arguments = ["setuptools==44.1.0"]

# form the arguments to pex builder
if not ctx.attr.zip_safe:
arguments += ["--not-zip-safe"]
for egg in py.transitive_eggs.to_list():
arguments += [egg.path]
for req in py.transitive_reqs.to_list():
arguments += [req]
if not ctx.attr.use_wheels:
arguments += ["--no-use-wheel"]
if ctx.attr.no_index:
arguments += ["--no-index"]
if ctx.attr.disable_cache:
arguments += ["--disable-cache"]
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 @@ -206,10 +213,6 @@ def _pex_binary_impl(ctx):
arguments += ["--requirement", req_file.path]
for repo in repos:
arguments += ["--repo", repo]
for egg in py.transitive_eggs.to_list():
arguments += [egg.path]
for req in py.transitive_reqs.to_list():
arguments += [req]
if main_pkg:
arguments += ["--entry-point", main_pkg]
elif script:
Expand Down Expand Up @@ -533,6 +536,6 @@ def pex_repositories():
http_file(
name = "pex_bin",
executable = True,
urls = ["https://github.com/pantsbuild/pex/releases/download/v2.1.28/pex"],
sha256 = "bfc0add2649bd2d76043ef4ec07edf28aa3bf2654e8ee9b8e39ff5dcffb37665",
urls = ["https://github.com/pantsbuild/pex/releases/download/v2.1.56/pex"],
sha256 = "aff02e2ef0212db4531354e9b7b0d5f61745b3eb49665bc11142f0b603a27db9",
)

0 comments on commit cc2b53f

Please sign in to comment.