https://pantsbuild.org/ logo
#general
Title
# general
r

ripe-gigabyte-88964

03/31/2023, 3:39 PM
Hey, I'm trying to build a pex locally and load it into a Dockerfile not using pants. However, I am getting this error when I try and run the pex inside the container:
Copy code
A distribution for orjson could not be resolved for /usr/local/bin/python3.8.
  Found 1 distribution for orjson that do not apply:
  1.) The wheel tags for orjson 3.6.9 are cp38-cp38-macosx_11_0_arm64, cp38-cp38-macosx_10_9_universal2, cp38-cp38-macosx_10_9_x86_64 which do not match the supported tags of /usr/local/bin/python3.8:
  cp38-cp38-manylinux_2_31_x86_64
  ... 598 more ...
I'm assuming this is because I am building the pex on my Mac but the container is a linux container. Is there a way to get around this?
e

enough-analyst-54434

03/31/2023, 4:12 PM
There are 3 ways: 1. Run Pants in the container. 2. Use
pex_binary(..., complete_platforms=[...])
to specify the foreign platform (the Linux container) to build for. 3. Use Pants environments, which does 1 for you but for just specific build steps Starting with the most likely to be useful / most desirable 1st: Environments are described here: + https://www.pantsbuild.org/docs/environments + https://blog.pantsbuild.org/environments-simpler-multi-platform-workflows/ Complete Platforms are detailed here: + https://www.pantsbuild.org/docs/reference-pex_binary#codecomplete_platformscode + https://pex.readthedocs.io/en/v2.1.131/buildingpex.html#complete-platform I can personally provide more info on complete platforms if needed, but you should definitely try environments 1st.
r

ripe-gigabyte-88964

03/31/2023, 5:30 PM
Is it possible to add conditional targets per environment? I.e. if the environment is docker, here's an additional target to build.
e

enough-analyst-54434

03/31/2023, 6:20 PM
I have no clue really. Sounds unlikely, but maybe your framing could be seen from a different angle. Someone with environments experience will need to weigh in.
2 Views