Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pex 2.1.56 #7

Merged
merged 2 commits into from
Dec 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
)