Skip to content

Remove extra files from py_binary DefaultInfo#467

Closed
keith wants to merge 3 commits intoaspect-build:mainfrom
keith:ks/remove-extra-files-from-py_binary-defaultinfo
Closed

Remove extra files from py_binary DefaultInfo#467
keith wants to merge 3 commits intoaspect-build:mainfrom
keith:ks/remove-extra-files-from-py_binary-defaultinfo

Conversation

@keith
Copy link
Contributor

@keith keith commented Dec 5, 2024

This mirrors rules_python to ensure that users can use execpath with a
py_binary target.

Fixes #455

This mirrors rules_python to ensure that users can use `execpath` with a
py_binary target.

Fixes aspect-build#455
drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/
drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_image_layer/
-rwxr-xr-x 0 0 0 2887 Jan 1 2023 ./py/tests/py_image_layer/my_app_bin
-rwxr-xr-x 0 0 0 16 Jan 1 2023 ./py/tests/py_image_layer/main.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks to me like this will break the ability to execute a container from this image - the entry point is gone. @thesayyn do you know if we have a test here that the py_image_layer can execute? Do we need to add a TestContainers Cloud or something so we have a docker daemon to run that assertion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not affect containers, but i am afraid it might break PEX

# This is a special comment for py_pex_binary to find the python entrypoint.
# __PEX_PY_BINARY_ENTRYPOINT__ {{ENTRYPOINT}}
,

Under pex, the shell generated by py_binary is not used at all, and we invoke the main.py directly with the given interpreter. It would be good to manually test https://github.com/aspect-build/rules_py/tree/main/examples/py_pex_binary and confirm it doesn't break.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it manually, and also added a commit here which does a simple genrule/assert_contains to automate that test.

@alexeagle alexeagle enabled auto-merge (squash) January 21, 2025 00:48
@arrdem arrdem closed this Jun 9, 2025
auto-merge was automatically disabled June 9, 2025 21:48

Pull request was closed

@keith keith deleted the ks/remove-extra-files-from-py_binary-defaultinfo branch November 19, 2025 03:22
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.

[Bug]: py_binary expression expands to more than one file

4 participants

Comments