One more roadblock. What am I doing wrong? My envi...
# general
b
One more roadblock. What am I doing wrong? My environment: Macbook Pro M1 Max BUILD root:
Copy code
poetry_requirements(
    name="poetry",
    module_mapping={
        "python-box": ["box"],
        "azure-storage-file-datalake": ["azure.storage.filedatalake.DataLakeServiceClient"]
    }
)
local_environment(
  name="local_linux",
  compatible_platforms=["linux_x86_64"],
  fallback_environment="docker_linux",
)
docker_environment(
    name="docker_linux",
    platform="linux_x86_64",
    image="python:3.11-slim",
    python_bootstrap_search_path=["<PATH>"]
)
src/streamlit/template/BUILD:
Copy code
python_sources()
pex_binary(
    name="bin",
    script="streamlit",
    dependencies=["./main.py", "//:poetry#watchdog"],
    environment="docker_linux"
)
docker_image(name="docker")
src/streamlit/template/Dockerfile:
Copy code
FROM python:3.11-slim
COPY src.streamlit.template/bin.pex /bin/streamlit
CMD /bin/streamlit
src/streamlit/template/main.py:
Copy code
import streamlit as st

st.title("My Streamlit App")
st.text("Hello, world!")
st.balloons()
root pants.toml:
Copy code
[GLOBAL]
pants_version = "2.15.0"
backend_packages = [
  "pants.backend.python",
  "pants.backend.docker"
]

[anonymous-telemetry]
enabled = false

[python]
tailor_pex_binary_targets = false
interpreter_constraints = ["CPython==3.11.2"]
enable_resolves = true

[python-bootstrap]
search_path = ["<PYENV>"]

[docker]
env_vars = ["DOCKER_CONFIG=%(homedir)s/.docker"]
default_repository = "{parent_directory}/{directory}"

[environments-preview.names]
docker_linux = "//:docker_linux"
local_linux = "//:local_linux"
Shell command:
pants run src/streamlit/template:docker
Error Output:
Copy code
09:41:51.03 [INFO] Completed: Building docker image streamlit/template:latest
Failed to find compatible interpreter on path /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.

Examined the following interpreters:
1.) /usr/local/bin/python3.11 CPython==3.11.2

No interpreter compatible with the requested constraints was found:

  Failed to resolve requirements from PEX environment @ /root/.pex/unzipped_pexes/c411c8338ca0b0531952668a33219de7ba52349e.
  Needed cp311-cp311-manylinux_2_31_aarch64 compatible dependencies for:
   1: MarkupSafe>=2.0
      Required by:
        Jinja2 3.1.2
      But this pex had no ProjectName(raw='MarkupSafe', normalized='markupsafe') distributions.
   2: numpy
      Required by:
        altair 4.2.2
        streamlit 1.19.0
      But this pex had no ProjectName(raw='numpy', normalized='numpy') distributions.
   3: pandas>=0.18
      Required by:
        altair 4.2.2
      But this pex had no ProjectName(raw='pandas', normalized='pandas') distributions.
   4: pandas>=0.25
      Required by:
        streamlit 1.19.0
      But this pex had no ProjectName(raw='pandas', normalized='pandas') distributions.
   5: pillow>=6.2.0
      Required by:
        streamlit 1.19.0
      But this pex had no ProjectName(raw='pillow', normalized='pillow') distributions.
   6: pyarrow>=4.0
      Required by:
        streamlit 1.19.0
      But this pex had no ProjectName(raw='pyarrow', normalized='pyarrow') distributions.
   7: charset-normalizer<4,>=2
      Required by:
        requests 2.28.2
      But this pex had no ProjectName(raw='charset-normalizer', normalized='charset-normalizer') distributions.
   8: numpy>=1.16.4
      Required by:
        pydeck 0.8.0
      But this pex had no ProjectName(raw='numpy', normalized='numpy') distributions.
   9: tornado>=6.0.3
      Required by:
        streamlit 1.19.0
      But this pex had no ProjectName(raw='tornado', normalized='tornado') distributions.
   10: watchdog; platform_system != "Darwin"
      Required by:
        streamlit 1.19.0
      But this pex had no ProjectName(raw='watchdog', normalized='watchdog') distributions.
   11: watchdog==2.3.0
      But this pex had no ProjectName(raw='watchdog', normalized='watchdog') distributions.
Solution: forcing the platform by changing the FROM into the dockerfile to:
Copy code
FROM --platform="linux/amd64" python:3.11-slim
Learning by failing...
🙌 1
r
Yeah even without pants, we have had such issues on M1 where people were pushing locally build docker image and it wouldn’t work because of this platform mismatch. Now by default we put it in every dockerfile. Although you’re passing
platform="linux_x86_64"
to the
docker_environment
. Maybe a bug?
b
looks like an edge case not covered. this should have been put as it's stated in the environment