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

feat: implement --build_python_zip pex #324

Merged
merged 26 commits into from
Sep 4, 2024
Merged

feat: implement --build_python_zip pex #324

merged 26 commits into from
Sep 4, 2024

Conversation

thesayyn
Copy link
Member

@thesayyn thesayyn commented Apr 2, 2024

Type of change

Test plan

  • New test cases added

MODULE.bazel Outdated Show resolved Hide resolved
@thesayyn thesayyn changed the title Build python zip feat: implement --build_python_zip pex May 21, 2024
@thesayyn thesayyn force-pushed the build_python_zip branch 2 times, most recently from db0db35 to 3391a90 Compare May 21, 2024 22:45
@thesayyn thesayyn marked this pull request as ready for review May 21, 2024 22:46
py/private/py_pex.bzl Outdated Show resolved Hide resolved
py/private/py_binary.bzl Outdated Show resolved Hide resolved
py/private/py_binary.bzl Outdated Show resolved Hide resolved
py/private/py_library.bzl Outdated Show resolved Hide resolved
py/private/py_pex.bzl Outdated Show resolved Hide resolved
py/private/py_pex.bzl Outdated Show resolved Hide resolved
py/private/py_pex.bzl Outdated Show resolved Hide resolved
py/private/py_pex.bzl Outdated Show resolved Hide resolved
py/private/py_binary.bzl Outdated Show resolved Hide resolved
py/tools/pex/BUILD.bazel Outdated Show resolved Hide resolved
@thesayyn thesayyn requested a review from mattem May 31, 2024 22:36
py/tools/pex/BUILD.bazel Outdated Show resolved Hide resolved
py/tools/pex/BUILD.bazel Outdated Show resolved Hide resolved
py/tools/pex/BUILD.bazel Outdated Show resolved Hide resolved
@dizzy57
Copy link

dizzy57 commented Jun 12, 2024

I was unable to make it work with bzlmod, here's a minimal repro: https://github.com/dizzy57/bazel_py_minimal

bazel_py_minimal % bazel build //cli_tool --build_python_zip
INFO: Analyzed target //cli_tool:cli_tool (0 packages loaded, 0 targets configured).
ERROR: /work/bazel_py_minimal/cli_tool/BUILD.bazel:4:10: Building PEX binary //cli_tool:cli_tool failed: (Exit 2): release_pex failed: error executing PyPex command (from target //cli_tool:cli_tool) bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_py~/py/tools/pex/release_pex ... (remaining 1382 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
usage: main.py [-h] [-o PEX_NAME] --python PYTHON --python-shebang
               PYTHON_SHEBANG [--executable EXECUTABLE]
               [--dependency DEPENDENCIES] [--distinfo DISTINFOS]
               [--source SOURCES] [--inject-env INJECT_ENV]
main.py: error: unrecognized arguments: external/rules_python~~python~python_3_9_aarch64-apple-darwin/lib/python3.9/site-packages/pip external/rules_python~~python~python_3_9_aarch64-apple-darwin/lib/python3.9/site-packages/pkg_resources external/rules_python~~python~python_3_9_aarch64-apple-darwin/lib/python3.9/site-packages/setuptools-69.1.0.dist-info external/rules_python~~python~python_3_9_aarch64-apple-darwin/lib/python3.9/site-packages/setuptools
Target //cli_tool:cli_tool failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 3.131s, Critical Path: 2.94s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully

examples/py_pex_binary/BUILD.bazel Outdated Show resolved Hide resolved
py/private/py_pex_binary.bzl Show resolved Hide resolved
py/private/py_pex_binary.bzl Outdated Show resolved Hide resolved
py/repositories.bzl Outdated Show resolved Hide resolved
py/repositories.bzl Outdated Show resolved Hide resolved
@thesayyn
Copy link
Member Author

Also, CPython=={major}.{minor}.* should be the default constraint.

@thesayyn thesayyn requested a review from mattem September 3, 2024 17:18
@thesayyn
Copy link
Member Author

thesayyn commented Sep 3, 2024

@mattem I have removed some unrelated diff from my failed attempt before using PEX. Now diff should be smaller and easier to understand.

py/private/py_pex_binary.bzl Show resolved Hide resolved
py/private/py_pex_binary.bzl Show resolved Hide resolved
py/private/py_pex_binary.bzl Outdated Show resolved Hide resolved
@thesayyn thesayyn requested a review from mattem September 4, 2024 18:48
@thesayyn thesayyn merged commit 7a9e4b2 into main Sep 4, 2024
14 checks passed
@thesayyn thesayyn deleted the build_python_zip branch September 4, 2024 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants