Hey, I'm trying to build a pex locally and load it...
# general
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:
  ... 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?
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.
Is it possible to add conditional targets per environment? I.e. if the environment is docker, here's an additional target to build.
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.