Skip to content

feat(pex): support building PEX archives to inherit from the sys.path #619

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

plobsing
Copy link
Contributor

@plobsing plobsing commented Aug 1, 2025

By default PEX archives are built to operate fully hermetically, which is usually a good idea. However, sometimes it is necessary to use packages from the hosting environment. One such example is AWS Lambda; the recommended approach for using PEX to run on Lambda is to build in this way.1

Mapping of this flag through from the build system largely follows the equivalent feature in Pants.2


Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config):no
  • Suggested release notes appear below: no

Test plan

  • Covered by existing test cases
  • Manual testing; please provide instructions so we can reproduce:
  1. Edit //py/tests/py-pex-binary:print_modules_pex to have an explicit inherit_path of a chosen value (e.g. "prefer").
  2. bazel build //py/tests/py-pex-binary:print_modules_pex.
  3. tar xfO bazel-bin/py/tests/py-pex-binary/print_modules_pex.pex PEX-INFO | jq '.inherit_path'
  4. Expect result: "prefer".

Do above except without passing an explicit inherit_path should give "false", which confirms the default semantics are preserved.

Footnotes

  1. https://github.com/pex-tool/lambdex/blob/main/MIGRATING.md

  2. https://www.pantsbuild.org/stable/reference/targets/pex_binary#inherit_path

Copy link

aspect-workflows bot commented Aug 1, 2025

Test

All tests were cache hits

41 tests (100.0%) were fully cached saving 1m 10s.

@arrdem arrdem self-assigned this Aug 14, 2025
By default PEX archives are built to operate fully hermetically, which
is usually a good idea. However, sometimes it is necessary to use
packages from the hosting environment. One such example is AWS Lambda;
the recommended approach for using PEX to run on Lambda is to build in
this way.[^1]

Mapping of this flag through from the build system largely follows the
equivalent feature in Pants.[^2]

[^1]: https://github.com/pex-tool/lambdex/blob/main/MIGRATING.md
[^2]: https://www.pantsbuild.org/stable/reference/targets/pex_binary#inherit_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants