aspect-build/rules_py

[Bug]: whl-files contained in py_binary builds (and rules_oci image builds)

betaboon opened this issue · 2 comments

What happened?

When building a py_binary target, the output contains the whl-files.
The same behavior can be observed when building a container image using rules_oci.

Version

Development (host) and target OS/architectures:

Output of bazel --version:
6.3.2

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

see this output for the symptom:

$ pwd
/home/betaboon/src/bazel/rules_py

$ bazel build //examples/django:django
INFO: Analyzed target //examples/django:django (1 packages loaded, 2 targets configured).
INFO: Found 1 target...
Target //examples/django:django up-to-date:
  bazel-bin/examples/django/django
INFO: Elapsed time: 0.412s, Critical Path: 0.02s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

$ find bazel-bin/examples/django/ -iname "*.whl"
bazel-bin/examples/django/django.runfiles/aspect_rules_py/external/pypi_asgiref/asgiref-3.7.2-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/aspect_rules_py/external/pypi_django/Django-4.2.5-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/aspect_rules_py/external/pypi_sqlparse/sqlparse-0.4.4-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/aspect_rules_py/external/pypi_typing_extensions/typing_extensions-4.7.1-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/aspect_rules_py/external/python_toolchain_x86_64-unknown-linux-gnu/lib/python3.9/ensurepip/_bundled/pip-23.0.1-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/aspect_rules_py/external/python_toolchain_x86_64-unknown-linux-gnu/lib/python3.9/ensurepip/_bundled/setuptools-58.1.0-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/pypi_asgiref/asgiref-3.7.2-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/pypi_django/Django-4.2.5-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/pypi_sqlparse/sqlparse-0.4.4-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/pypi_typing_extensions/typing_extensions-4.7.1-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/python_toolchain_x86_64-unknown-linux-gnu/lib/python3.9/ensurepip/_bundled/pip-23.0.1-py3-none-any.whl
bazel-bin/examples/django/django.runfiles/python_toolchain_x86_64-unknown-linux-gnu/lib/python3.9/ensurepip/_bundled/setuptools-58.1.0-py3-none-any.whl

$ find bazel-bin/examples/django/ -iname "django"
bazel-bin/examples/django/
bazel-bin/examples/django/django
bazel-bin/examples/django/django.runfiles/aspect_rules_py/examples/django
bazel-bin/examples/django/django.runfiles/aspect_rules_py/examples/django/django
bazel-bin/examples/django/django.venv.source/lib/python3.9/site-packages/django
bazel-bin/examples/django/django.venv.source/lib/python3.9/site-packages/django/forms/jinja2/django
bazel-bin/examples/django/django.venv.source/lib/python3.9/site-packages/django/forms/templates/django

$ ls bazel-bin/examples/django/django.venv.source/lib/python3.9/site-packages/django
 apps   conf   contrib   core   db   dispatch   forms   http   middleware   template   templatetags   test   urls   utils   views   __init__.py   __main__.py   shortcuts.py

Any other information?

When building a container-image using the example in aspect-build/bazel-examples does not exhibit the same behavior.
This seems to be due to the usage of pip.parse and thus effectively rules_python's py_libary.

A lot has changed in rules_py since this issue was opened. Can you retest on the latest and reopen if its still an issue?

yep, this seems resolved :)