swift-dawn-80732
04/17/2022, 2:00 PMResolveError(
pex.environment.ResolveError: Failed to resolve requirements from PEX environment @ /root/.pex/unzipped_pexes/1bc1b3d05270a6cb192aecf5a51715e951da993c.
Needed cp39-cp39-manylinux_2_31_x86_64 compatible dependencies for:
1: MarkupSafe>=2.0
Required by:
FingerprintedDistribution(distribution=Jinja2 3.1.1 (/root/.pex/installed_wheels/0893af5400986fb3b6c0f06db963e45dd7e2e9be91f476133910371878af80e8/Jinja2-3.1.1-py3-none-any.whl), fingerprint='0893af5400986fb3b6c0f06db963e45dd7e2e9be91f476133910371878af80e8')
But this pex had no 'MarkupSafe' distributions.
in `pants.toml`:
[python]
interpreter_constraints = ["CPython==3.9.10"]
debug logs when running `./pants package src/app/Dockerfile --level=debug`:
10:39:20.62 [DEBUG] Completed: Find Python interpreter for constraints - Selected /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/bin/python3.8 to run PEXes with.
enough-analyst-54434
04/17/2022, 2:39 PMenough-analyst-54434
04/17/2022, 2:41 PMswift-dawn-80732
04/17/2022, 2:44 PMswift-dawn-80732
04/17/2022, 2:50 PM11:12:03.50 [DEBUG] Completed: Find interpreter for constraints: CPython==3.9.10
11:12:03.50 [DEBUG] Completed: Scheduling: Find interpreter for constraints: CPython==3.9.10
11:12:03.50 [DEBUG] Completed: Find Python interpreter for constraints - Selected /Users/demoda/.pyenv/versions/3.9.10/bin/python3.9 to run PEXes with.
11:12:03.50 [DEBUG] Completed: Hit: Local cache lookup: Determine Python imports for src/hasura_webhooks_proxy/app.py
11:12:03.50 [DEBUG] Completed: Scheduling: Determine Python imports for src/hasura_webhooks_proxy/app.py
11:12:03.51 [DEBUG] Completed: pants.backend.python.util_rules.python_sources.prepare_python_sources
11:12:03.52 [DEBUG] Completed: Hit: Local cache lookup: Building local_dists.pex
11:12:03.52 [DEBUG] Completed: Scheduling: Building local_dists.pex
11:12:03.52 [DEBUG] Completed: pants.backend.python.util_rules.pex.build_pex
11:12:03.52 [DEBUG] Completed: pants.backend.python.util_rules.python_sources.strip_python_sources
11:12:03.52 [DEBUG] Completed: pants.backend.python.util_rules.pex_from_targets.create_pex_from_targets
11:12:03.52 [DEBUG] Completed: Hit: Local cache lookup: Building src.hasura_webhooks_proxy/app.pex with 1 requirement: flask==2.1.1
11:12:03.52 [DEBUG] Completed: Scheduling: Building src.hasura_webhooks_proxy/app.pex with 1 requirement: flask==2.1.1
11:12:03.52 [DEBUG] Completed: pants.backend.python.util_rules.pex.build_pex
11:12:03.52 [DEBUG] Completed: pants.backend.python.goals.package_pex_binary.package_pex_binary
11:12:03.52 [DEBUG] Did not build any upstream Docker images
11:12:03.52 [DEBUG] Built packages for Docker image: src.hasura_webhooks_proxy/app.pex
enough-analyst-54434
04/17/2022, 2:58 PMpex_binary
target that sets platforms or complete_platforms?swift-dawn-80732
04/17/2022, 2:59 PMpex_binary(
name="app",
entry_point="app.py",
)
enough-analyst-54434
04/17/2022, 2:59 PMswift-dawn-80732
04/17/2022, 2:59 PMswift-dawn-80732
04/17/2022, 2:59 PMlinux-x86_64
swift-dawn-80732
04/17/2022, 2:59 PMenough-analyst-54434
04/17/2022, 3:00 PMenough-analyst-54434
04/17/2022, 3:05 PM/path/to/my/python -mvenv pex.venv
pex.venv/bin/pip install pex
pex.venv/bin/pex --help
In the pex --help
you're looking for the --platform
help which will have a line like:
For the current interpreter at /home/jsirois/.venv/pex/bin/python3 the full platform string is manylinux_2_35_x86_64-cp-3.10.2-cp310.
enough-analyst-54434
04/17/2022, 3:06 PMenough-analyst-54434
04/17/2022, 3:07 PMrapid-exabyte-76685
04/19/2022, 6:10 AM./pants run Dockerfile
I get a whole bunch of
pex.environment.ResolveError: A distribution for quickfix could not be resolved in this environment.Found 1 distribution for quickfix that do not apply:
1.) The wheel tags for quickfix 1.15.1 are cp310-cp310-macosx_12_0_x86_64 which do not match the supported tags of /usr/local/bin/python3.10:
cp310-cp310-manylinux_2_31_x86_64
cp310-cp310-manylinux_2_30_x86_64
cp310-cp310-manylinux_2_29_x86_64
cp310-cp310-manylinux_2_28_x86_64
which makes sense, looking for some guidance on how to resolve.rapid-exabyte-76685
04/19/2022, 6:12 AMrapid-exabyte-76685
04/19/2022, 6:15 AMPEX files may be platform-specific
If your code's requirements include distributions that include native code, then the resulting PEX file will only run on the platform it was built on.Yes, unfortunately that is the case for me 😢
enough-analyst-54434
04/19/2022, 2:04 PM[python-repos]
indexes
or `repos`: https://www.pantsbuild.org/docs/reference-python-reposenough-analyst-54434
04/19/2022, 3:00 PMcomplete_platforms
) for the associated pex_binary
target. You must use that field to tell Pants to build a multiplatform PEX file that has even a chance of running on Mac and Linux. Once you have platforms specified, the building of the PEX file will fail fast up front if it can't find wheels for every required dependency for each platform you have specified. To get the appropriate platform string for your Docker image, just do something like:
$ docker run --rm python:3.10 bash -c '
> /usr/local/bin/python3.10 -mvenv pex.venv
> pex.venv/bin/pip -q install pex
> pex.venv/bin/pex3 interpreter inspect -v -i2
> '
{
"path": "/pex.venv/bin/python3.10",
"version": "3.10.4",
"requirement": "CPython==3.10.4",
"platform": "manylinux_2_31_x86_64-cp-3.10.4-cp310",
"venv": true,
"base_interpreter": "/usr/local/bin/python3.10"
}
The key thing is to use the full path to the interpreter you want to target in the image in that 1st bash script line.rapid-exabyte-76685
04/20/2022, 12:02 AMby setting up corporate wheel-building infrastructure such that they always had pure wheels available for all machines targeted.yep, agree that's the path I will need to take.