pants: Builded zip by `python_google_cloud_function` on mac os with `docker_environment` still cannot be used inside docker container on same machine

Describe the bug

Builded zip by python_google_cloud_function on mac os with docker_environment still cannot be used inside docker container on same machine.

BUILD:

__defaults__(
    all=dict(environment="local_linux"),
)

local_environment(
    name="local_linux",
    compatible_platforms=["linux_x86_64", "linux_arm64"],
    fallback_environment="local_docker",
)

docker_environment(
    name="local_docker",
    image="python:3.9",
)

python_google_cloud_function(
    name="function",
    runtime="python39",
    handler="function.py:handler",
    type="event",
)

Command ./pants package :: build zip in docker image. Next trying check that zip is working:

Dockerfile:

FROM python:3.9

RUN apt-get update && apt-get install -y unzip

WORKDIR /app

RUN pip install functions-framework

COPY function.zip function.zip

RUN unzip function.zip -d .

CMD ["functions-framework", "--target=handler", "--signature-type=event"]

Result:

Traceback (most recent call last):
  File "/usr/local/bin/functions-framework", line 8, in <module>
    sys.exit(_cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/functions_framework/_cli.py", line 36, in _cli
    app = create_app(target, source, signature_type)
  File "/usr/local/lib/python3.9/site-packages/functions_framework/__init__.py", line 353, in create_app
    spec.loader.exec_module(source_module)
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/app/main.py", line 34, in <module>
    bootstrap_pex_env(__entry_point__)
  File "/app/.bootstrap/pex/pex_bootstrapper.py", line 683, in bootstrap_pex_env
    PEXEnvironment.mount(entry_point, pex_info).activate()
  File "/app/.bootstrap/pex/environment.py", line 321, in activate
    self._activated_dists = self._activate()
  File "/app/.bootstrap/pex/environment.py", line 671, in _activate
    resolved = self.resolve()
  File "/app/.bootstrap/pex/environment.py", line 502, in resolve
    for fingerprinted_distribution in self.resolve_dists(all_reqs)
  File "/app/.bootstrap/pex/environment.py", line 526, in resolve_dists
    for qualified_req_or_not_found in self._root_requirements_iter(reqs):
  File "/app/.bootstrap/pex/environment.py", line 467, in _root_requirements_iter
    raise ResolveError(message)
pex.environment.ResolveError: A distribution for psutil could not be resolved for /usr/local/bin/python3.9.
Found 1 distribution for psutil that do not apply:
1.) The wheel tags for psutil 5.8.0 are cp39-cp39-manylinux2010_x86_64 which do not match the supported tags of /usr/local/bin/python3.9:
cp39-cp39-manylinux_2_31_aarch64
... 367 more ...

For testing all happens on same machine with same docker. Not clear why pex search for cp39-cp39-manylinux2010_x86_64, because both docker containers have same os and architecture:

"Architecture": "arm64",
"Variant": "v8",
"Os": "linux",

Pants version 2.15.0rc3

OS Mac OS Ventura 13.2 (Apple Silicon)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 23 (13 by maintainers)

Most upvoted comments

OK, can reproduce, will dig in.