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

[Bug]: oci_python_image example does not copy correct prebuilt binaries #351

Open
chulkilee opened this issue Sep 5, 2024 · 2 comments
Open
Labels
bug Something isn't working untriaged Requires traige

Comments

@chulkilee
Copy link

chulkilee commented Sep 5, 2024

What happened?

See https://github.com/aspect-build/bazel-examples/compare/main...chulkilee:bazel-examples:oci-py-target?expand=1

This is to show how the current oci_python_image example does not work when building on macos.

cd oci_python_image
bazel run //hello_world:tarball

docker run --rm gcr.io/oci_python_hello_world:latest
Traceback (most recent call last):
  File "/hello_world/hello_world.runfiles/_main/hello_world/__main__.py", line 1, in <module>
    from hello_world.app import Cow
  File "/hello_world/hello_world.runfiles/_main/hello_world/app.py", line 2, in <module>
    from pydantic import BaseModel
  File "/hello_world/hello_world.runfiles/.hello_world.venv/lib/python3.9/site-packages/pydantic/__init__.py", line 404, in __getattr__
    module = import_module(module_name, package=package)
  File "/hello_world/hello_world.runfiles/rules_python~~python~python_3_9_aarch64-unknown-linux-gnu/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/hello_world/hello_world.runfiles/.hello_world.venv/lib/python3.9/site-packages/pydantic/main.py", line 27, in <module>
    import pydantic_core
  File "/hello_world/hello_world.runfiles/.hello_world.venv/lib/python3.9/site-packages/pydantic_core/__init__.py", line 6, in <module>
    from ._pydantic_core import (
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'

This is because pydantic_core's prebuilt is copied from host (macos), not for target. See the following output having darwin, not linux.

docker run --rm gcr.io/oci_python_hello_world:latest ls /hello_world/hello_world.runfiles/rules_python~~pip~pip_39_pydantic_core/site-packages/pydantic_core/

Output:

__init__.py
_pydantic_core.cpython-39-darwin.so
_pydantic_core.pyi
core_schema.py
py.typed

Interestingly, it actually did use the right python

docker run --rm gcr.io/oci_python_hello_world:latest ls /hello_world/hello_world.runfiles

Output:

_main
aspect_rules_py~~py_tools~rules_py_tools.linux_arm64
bazel_tools
rules_python~~pip~pip_39_annotated_types
rules_python~~pip~pip_39_cowsay
rules_python~~pip~pip_39_pydantic
rules_python~~pip~pip_39_pydantic_core
rules_python~~pip~pip_39_typing_extensions
rules_python~~python~python_3_9_aarch64-unknown-linux-gnu

See aarch64-unknown-linux-gnu there.

Version

Development (host) and target OS/architectures:

Output of bazel --version: 7.3.0

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

Language(s) and/or frameworks involved: python

How to reproduce

See https://github.com/aspect-build/bazel-examples/compare/main...chulkilee:bazel-examples:oci-py-target?expand=1

Any other information?

It doesn't fail the test since apparently tests are running on linux machine.

@chulkilee chulkilee added the bug Something isn't working label Sep 5, 2024
@github-actions github-actions bot added the untriaged Requires traige label Sep 5, 2024
@antspy
Copy link

antspy commented Oct 22, 2024

+1 This is exactly what I found as well! :)

@clarenceh
Copy link

+1 I am having the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Requires traige
Projects
None yet
Development

No branches or pull requests

3 participants