pex-tool / pex

A tool for generating .pex (Python EXecutable) files, lock files and venvs.
https://docs.pex-tool.org/
Apache License 2.0
2.61k stars 261 forks source link

Missing distributions in pex from lockfile #1688

Closed kaos closed 2 years ago

kaos commented 2 years ago

I've noticed issues with thrift (for unknown reasons) when Pants is creating a resolves pex file from a lock file. If I simply create a pex with thrift as the only requirement, it works.

Using pex 2.1.73

I did notice that the fingerprint seems to be identical for all variants of thrift, in case that could cause issues... ? (Added related output log from pex at the end for this)

$ PEX_VERBOSE=1 pex --output-file libs.pex --manylinux manylinux2014 --interpreter-constraint $'CPython<4,>=3.8' --layout packed --lock /private/var/folders/8j/c8jf_msj009947wyw82xvdkw0000gn/T/process-executionIAH9CA/pants.lock

yields a PEX-INFO thus:

{
  "bootstrap_hash": "eb91c46ee9bc3edc8337017cfdf9bdfcc4aedd6c",
  "build_properties": {
    "pex_version": "2.1.73"
  },
  "code_hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
  "distributions": {
    "Flask-2.0.3-py3-none-any.whl": "9ab053e2cf74b990f0f9c1584ddd78de0e7b549804d487ce05a5a8099d06d627",
    "Flask_Cors-3.0.10-py2.py3-none-any.whl": "5d3ee3d8b07427205d1e9edaf14d171558eac82acc5a3b442b07041f39b8b2b9",
    "Flask_WTF-1.0.0-py3-none-any.whl": "e7fa37c6c1c9d156ad92025f88ea729b8168a5663a84709912e99398249b1f54",
    "Jinja2-3.0.3-py3-none-any.whl": "45b86ae6d5fb93add40ef1624dd62aee1110e5047a56d7148a4bdb39a0ce72fb",
    "MarkupSafe-2.1.1-cp38-cp38-macosx_10_9_x86_64.whl": "def689d2d13f62ed3a31ef0a1bd8311d92d1e04ce1ea1a4d68c987eb2f9e4726",
    "MarkupSafe-2.1.1-cp39-cp39-macosx_10_9_x86_64.whl": "f378b1cda23e25a8fec4e1a21d57ad78ef482fffa808ca8fb22cadc70b2dd93c",
    "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl": "1b645a947c41a735abee60a7ca17cfc4475d1c8736a9c9c4a5f8b2ccd5674048",
    "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl": "1a08337aaa0f63f4f94da401c57ec31408221212f19a7a4e10b32aeb82179233",
    "WTForms-3.0.1-py3-none-any.whl": "ce4319446598ba4e9cc7446834fe32de46109b9daa218ab5f3ba9c770f90c6f5",
    "Werkzeug-2.0.3-py3-none-any.whl": "411b4ec96200e5d4e5c6c5cab98333ab2b4110820da473debd1bc1e1923b06b6",
    "aniso8601-9.0.1-py2.py3-none-any.whl": "ce6d3687dc05062fee52588b5ab468ac3ecea0c42efea24db448c08ea276cf11",
    "apispec-5.1.1-py3-none-any.whl": "b93c0651967853f70680464325417eca9b38d56f15e9927108ab37bc5531a139",
    "attrs-21.4.0-py2.py3-none-any.whl": "bcdaa33e240e2cd75f56ed4b4ddfeba6e650e821485c065e57fb7d5679eac6a1",
    "backoff-1.10.0-py2.py3-none-any.whl": "84b2c08ea0ac3a8ae10aa5019dbfcd0201a6ed07a7ac021aa6355d4046591422",
    "blinker-1.4-py3-none-any.whl": "b849c7ee981fa6dc18b1687b2c779aa0d214a6149a24a0e0e8f21bd33aeab18e",
    "cachetools-4.2.4-py3-none-any.whl": "f7685dbaf3327d4a0838b5dd485d83b2b18e5491a3c11df44d2852046c5304a3",
    "certifi-2021.10.8-py2.py3-none-any.whl": "02e82efce4c552ffb862a8e09a422941e95a532fbc3e8672611f4265f3c4ec0b",
    "charset_normalizer-2.0.12-py3-none-any.whl": "02a5b56ad13945ae0116e3345ce35bc4966356a2f2d0bd99fa89cc227d5ac1e6",
    "click-8.0.4-py3-none-any.whl": "373eb555cd5d2e639713140d649cf497e5204452922d6cf8894bdadedcf2bd4a",
    "decorator-5.1.1-py3-none-any.whl": "7ed6dc469274d0b89fff2c3b5a28d1ddc0937210510a7b13016a8327fc28bc3b",
    "flasgger-0.9.5-py2.py3-none-any.whl": "45c87dd2197f2161746f160e50c5c4a9bf3aa27902f10dd6be21eb77eb8bf74b",
    "flask_restx-0.5.1-py2.py3-none-any.whl": "7db4763d34708f35f657227c6f9730936579e023d4534c3c69e487f87b3b658c",
    "flask_smorest-0.36.0-py3-none-any.whl": "1b7befd5d87439e43904619dfd83ae3d376cc9d36cdbe8399bd830c07310d7cf",
    "gevent-21.12.0-cp38-cp38-macosx_10_14_x86_64.whl": "f1ce4cd5f7b8431ff3fd0e74b3ecd70feafeae54d785ee3c84a087f777c4d947",
    "gevent-21.12.0-cp39-cp39-macosx_10_14_x86_64.whl": "ffd09bfa671f29bceff526191a5c103820631b91ead3900339b372f52583e323",
    "greenlet-1.1.2-cp38-cp38-macosx_10_14_x86_64.whl": "664f2e52caec0a57119e37ad3c9e304cf1b38293e8f515b73b9f480edf0500bc",
    "greenlet-1.1.2-cp39-cp39-macosx_10_14_x86_64.whl": "702cb15efc66b802470cef7ad6394a82e705709b5fcc35a28b6fa6c2b08edc2d",
    "idna-3.3-py3-none-any.whl": "f6618af934a714454313a29b891c03fe8cde2be7bf19e20e3abc11d26ce689ac",
    "importlib_resources-5.4.0-py3-none-any.whl": "54733a1cfb4b3029d646ae6e493505ba4c77df5cb6490bb1b1ab7958bcd350f0",
    "itsdangerous-2.1.1-py3-none-any.whl": "f194285245231dd5ee6a24cc279853f1bdcf5a4210b8b2b7584535a62c893193",
    "jsonschema-4.4.0-py3-none-any.whl": "09e62bb83af4516291a6dc090e466ef237893f9e275fa0f8c3da8d2d47acbb46",
    "kazoo-2.8.0-py2.py3-none-any.whl": "218d389d5e77fb171d659f90b84928771465765e1066a2fa8df9c435a00e628e",
    "marshmallow-3.15.0-py3-none-any.whl": "9bcab07cf141f46b56fea1bb7bf22407321075035d6f9ef9c59ef07e63f837e8",
    "memorised-1.1.0-py3-none-any.whl": "c4cef391dd278be586265b21a98b74191cca8d425a5f4ac91dffeffd13ac3727",
    "mistune-2.0.2-py2.py3-none-any.whl": "82bba1f50196033096d73f065d412550aba9b9401ea7b1040e5924e8bb65b269",
    "packaging-21.3-py3-none-any.whl": "a728bb5d35998463aee41e8a69df75fe81e027553b019f51236950d765d9f132",
    "pyparsing-3.0.7-py3-none-any.whl": "030156a7e7dfe588b5952bfc95545aa5a23dbcee943e60c3a1e578fa6a408846",
    "pyrsistent-0.18.1-cp38-cp38-macosx_10_9_universal2.whl": "587491e11a6ce5cb5cc6474c33b07ab52789f838f0b53c15490566edde9eb1b8",
    "pyrsistent-0.18.1-cp39-cp39-macosx_10_9_universal2.whl": "1a813b5bebc8a0c55028a9717f2d7a68ee0c322c3a06e59acfad3418334e9343",
    "python3_memcached-1.51-py3-none-any.whl": "d26cf4912c6deafbb2188da3a26b8f3976cb7fd1c62f730bbbaa0ec1f84c8f5f",
    "pytz-2022.1-py2.py3-none-any.whl": "633585911661f98acb98500c229da55509b62d4c7dc2df56b2a8a0ade5efc005",
    "requests-2.27.1-py2.py3-none-any.whl": "00cb4036ab1c06a925a45af8823822d15b344d52c6d466a268510e80f2211438",
    "setuptools-60.10.0-py3-none-any.whl": "4d4757c96295cbf4264d11dc9a49e2e6873ee063ee49413110739ea6c44a248c",
    "six-1.16.0-py2.py3-none-any.whl": "430f383ecbfc71b6dd7ab8cecb2809b0de38efe5df9687cf38c5734bbb94ae3c",
    "statsd-3.3.0-py2.py3-none-any.whl": "d079052d9775f285e836ba8bcc5b6bec52517aee473cbdb045448d5cf5264c5c",
    "y_cdi_server-6.18.11-py3-none-any.whl": "5d35f2bcaa4c654e9111f673b5ef8937cdeae056de7e1220f7285bf38c5dd632",
    "y_configuration-3.3.2-py3-none-any.whl": "b666e6043f99719c4f3352fc0b3d7cb86df75d45e6038dfed27ebc5a6df446a4",
    "y_logging-2.1.1-py3-none-any.whl": "979ed43ea397375058082a1e33ace9d24dbb60d8182a8721ce55f2e6e48086d8",
    "y_stats-2.0.2-py3-none-any.whl": "8446477ad35393a8076a90819e1b0d712e8ade7d90a062353cac2bcc7b09ecf0",
    "y_utils-4.25.1-py3-none-any.whl": "6c0eb8b529e1963a456fdca58b9af66273c087e85bb5b2230f435fda6a6310ff",
    "thrift-0.15.0-cp39-cp39-macosx_12_0_x86_64.whl": "5e93ad036c14375b0c1e58119da48368a15710141dd3922bc9ebf0c83cf7272b",
    "urllib3-1.26.9-py2.py3-none-any.whl": "1cffa65f9d80c2567a6faa650cfd7078661fb5baaa40bede362246d2e5c70c72",
    "webargs-8.1.0-py3-none-any.whl": "ac4684877c4c54f520a9e5cff2cc6f5d5ee6f89fee6f9fd63480f3aa072bda87",
    "zipp-3.7.0-py3-none-any.whl": "8c49a5976fc9b4bdaeb3536c1aa1717f1d380e6b08f5524d37ecd0d0d2e0f968",
    "zope.event-4.5.0-py2.py3-none-any.whl": "79cd54f217bcb91e848161c7bd78250bff60d87178eaced0ca73ada715805495",
    "zope.interface-5.4.0-cp38-cp38-macosx_10_14_x86_64.whl": "679d076cb20140748f9bd575f953da632c6e79bab9264469d3c3b6cba833a4b8",
    "zope.interface-5.4.0-cp39-cp39-macosx_10_14_x86_64.whl": "c9869e14c29327f3662f9ce77f2ccc4d8aff946bd4ce6d7481b9f86148d15b4d"
  },
  "emit_warnings": true,
  "ignore_errors": false,
  "includes_tools": false,
  "inherit_path": "false",
  "interpreter_constraints": [
    "CPython<4,>=3.8"
  ],
  "pex_hash": "f2f670c3be0e11485452a74e83319bed2c7859b6",
  "pex_path": null,
  "requirements": [
    "y-cdi-server<7.0.0,>=6.18.10",
    "y-logging<3.0.0,>=2.1.1"
  ],
  "strip_pex_env": true,
  "venv": false,
  "venv_bin_path": "false",
  "venv_copies": false,
  "venv_site_packages_copies": false
}

Note that there is no thrift for cp38 here. (when running from the pants sandbox, I get the inverse, where the cp39 is missing instead. guessing it is the same issue only with some circumstances swapped)

While

$ PEX_VERBOSE=1 pex --output-file thrift.pex --manylinux manylinux2014 --interpreter-constraint $'CPython<4,>=3.8' --layout packed thrift==0.15.0

gives me:

{
  "bootstrap_hash": "eb91c46ee9bc3edc8337017cfdf9bdfcc4aedd6c",
  "build_properties": {
    "pex_version": "2.1.73"
  },
  "code_hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
  "distributions": {
    "six-1.16.0-py2.py3-none-any.whl": "3e1c439c88d2e7681372427bab751b3fc99969891e95a714fed9604bf7710213",
    "thrift-0.15.0-cp38-cp38-macosx_11_0_x86_64.whl": "7310e52c0a64d5c75e3dba1dc25840d55f89c28c81a5d33e5540473fbe5411cf",
    "thrift-0.15.0-cp39-cp39-macosx_12_0_x86_64.whl": "bbdd2d56b93db93f3dac964392687b7658fabf6e4cca00f50d506cb51f10cea7"
  },
  "emit_warnings": true,
  "ignore_errors": false,
  "includes_tools": false,
  "inherit_path": "false",
  "interpreter_constraints": [
    "CPython<4,>=3.8"
  ],
  "pex_hash": "0157af13552815724cd605501d69764a303d488b",
  "pex_path": null,
  "requirements": [
    "thrift==0.15.0"
  ],
  "strip_pex_env": true,
  "venv": false,
  "venv_bin_path": "false",
  "venv_copies": false,
  "venv_site_packages_copies": false
}

With thrift for both cp38 and cp39.

The thrift library itself is a sdist only.

The (redacted) pants.lock file used above is: pants.lock-redacted.txt

When running from the sandbox, pex outputs these lines mentioning thrift (and see for both cp38 and cp39 but only one of them ends up in the pex file):

  BuildRequest(target=LocalInterpreter(id='Users.x..pyenv.versions.3.8.11.bin.python3.8', platform=Platform(platform='macosx_12_0_x86_64', impl='cp', version='3.8.11', version_info=(3, 8, 11), abi='cp38'), marker_environment=MarkerEnvironment(implementation_name='cpython', implementation_version='3.8.11', os_name='posix', platform_machine='x86_64', platform_python_implementation='CPython', platform_release='21.4.0', platform_system='Darwin', platform_version='Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64', python_full_version='3.8.11', python_version='3.8', sys_platform='darwin'), interpreter=PythonInterpreter('/Users/x/.pyenv/versions/3.8.11/bin/python3.8', PythonIdentity('/Users/x/.pyenv/versions/3.8.11/bin/python3.8', 'cp38', 'cp38', 'macosx_12_0_x86_64', (3, 8, 11)))), source_path='/Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz', fingerprint='25690654033451dd03d9db33437752b7b4785523')
  BuildRequest(target=LocalInterpreter(id='Users.x..pyenv.versions.3.9.7.bin.python3.9', platform=Platform(platform='macosx_12_0_x86_64', impl='cp', version='3.9.7', version_info=(3, 9, 7), abi='cp39'), marker_environment=MarkerEnvironment(implementation_name='cpython', implementation_version='3.9.7', os_name='posix', platform_machine='x86_64', platform_python_implementation='CPython', platform_release='21.4.0', platform_system='Darwin', platform_version='Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64', python_full_version='3.9.7', python_version='3.9', sys_platform='darwin'), interpreter=PythonInterpreter('/Users/x/.pyenv/versions/3.9.7/bin/python3.9', PythonIdentity('/Users/x/.pyenv/versions/3.9.7/bin/python3.9', 'cp39', 'cp39', 'macosx_12_0_x86_64', (3, 9, 7)))), source_path='/Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz', fingerprint='25690654033451dd03d9db33437752b7b4785523')
  BuildRequest(target=LocalInterpreter(id='usr.local.Cellar.python@3.9.3.9.10.Frameworks.Python.framework.Versions.3.9.bin.python3.9', platform=Platform(platform='macosx_12_0_x86_64', impl='cp', version='3.9.10', version_info=(3, 9, 10), abi='cp39'), marker_environment=MarkerEnvironment(implementation_name='cpython', implementation_version='3.9.10', os_name='posix', platform_machine='x86_64', platform_python_implementation='CPython', platform_release='21.4.0', platform_system='Darwin', platform_version='Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64', python_full_version='3.9.10', python_version='3.9', sys_platform='darwin'), interpreter=PythonInterpreter('/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/bin/python3.9', PythonIdentity('/usr/local/opt/python@3.9/bin/python3.9', 'cp39', 'cp39', 'macosx_12_0_x86_64', (3, 9, 10)))), source_path='/Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz', fingerprint='25690654033451dd03d9db33437752b7b4785523')
  BuildRequest(target=LocalInterpreter(id='Applications.Xcode.app.Contents.Developer.Library.Frameworks.Python3.framework.Versions.3.8.bin.python3.8', platform=Platform(platform='macosx_12_0_x86_64', impl='cp', version='3.8.9', version_info=(3, 8, 9), abi='cp38'), marker_environment=MarkerEnvironment(implementation_name='cpython', implementation_version='3.8.9', os_name='posix', platform_machine='x86_64', platform_python_implementation='CPython', platform_release='21.4.0', platform_system='Darwin', platform_version='Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64', python_full_version='3.8.9', python_version='3.8', sys_platform='darwin'), interpreter=PythonInterpreter('/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/bin/python3.8', PythonIdentity('/Applications/Xcode.app/Contents/Developer/usr/bin/python3', 'cp38', 'cp38', 'macosx_12_0_x86_64', (3, 8, 9)))), source_path='/Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz', fingerprint='25690654033451dd03d9db33437752b7b4785523')
pex: Using cached build of /Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz at /Users/x/.cache/pants/named_caches/pex_root/built_wheels/sdists/thrift-0.15.0.tar.gz/25690654033451dd03d9db33437752b7b4785523/cp38-cp38
pex: Using cached build of /Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz at /Users/x/.cache/pants/named_caches/pex_root/built_wheels/sdists/thrift-0.15.0.tar.gz/25690654033451dd03d9db33437752b7b4785523/cp39-cp39
pex: Using cached build of /Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz at /Users/x/.cache/pants/named_caches/pex_root/built_wheels/sdists/thrift-0.15.0.tar.gz/25690654033451dd03d9db33437752b7b4785523/cp39-cp39
pex: Using cached build of /Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz at /Users/x/.cache/pants/named_caches/pex_root/built_wheels/sdists/thrift-0.15.0.tar.gz/25690654033451dd03d9db33437752b7b4785523/cp38-cp38
pex: Using cached installation of thrift-0.15.0-cp38-cp38-macosx_11_0_x86_64.whl at /Users/x/.cache/pants/named_caches/pex_root/installed_wheels/8da55c99ca51ad649d8f7ddec5c442ffe65895a136ee9c88b70efea4597b68b3/thrift-0.15.0-cp38-cp38-macosx_11_0_x86_64.whl
  BuildRequest(target=LocalInterpreter(id='Users.x..pyenv.versions.3.8.11.bin.python3.8', platform=Platform(platform='macosx_12_0_x86_64', impl='cp', version='3.8.11', version_info=(3, 8, 11), abi='cp38'), marker_environment=MarkerEnvironment(implementation_name='cpython', implementation_version='3.8.11', os_name='posix', platform_machine='x86_64', platform_python_implementation='CPython', platform_release='21.4.0', platform_system='Darwin', platform_version='Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64', python_full_version='3.8.11', python_version='3.8', sys_platform='darwin'), interpreter=PythonInterpreter('/Users/x/.pyenv/versions/3.8.11/bin/python3.8', PythonIdentity('/Users/x/.pyenv/versions/3.8.11/bin/python3.8', 'cp38', 'cp38', 'macosx_12_0_x86_64', (3, 8, 11)))), source_path='/Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz', fingerprint='25690654033451dd03d9db33437752b7b4785523')
  BuildRequest(target=LocalInterpreter(id='Users.x..pyenv.versions.3.9.7.bin.python3.9', platform=Platform(platform='macosx_12_0_x86_64', impl='cp', version='3.9.7', version_info=(3, 9, 7), abi='cp39'), marker_environment=MarkerEnvironment(implementation_name='cpython', implementation_version='3.9.7', os_name='posix', platform_machine='x86_64', platform_python_implementation='CPython', platform_release='21.4.0', platform_system='Darwin', platform_version='Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64', python_full_version='3.9.7', python_version='3.9', sys_platform='darwin'), interpreter=PythonInterpreter('/Users/x/.pyenv/versions/3.9.7/bin/python3.9', PythonIdentity('/Users/x/.pyenv/versions/3.9.7/bin/python3.9', 'cp39', 'cp39', 'macosx_12_0_x86_64', (3, 9, 7)))), source_path='/Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz', fingerprint='25690654033451dd03d9db33437752b7b4785523')
  BuildRequest(target=LocalInterpreter(id='usr.local.Cellar.python@3.9.3.9.10.Frameworks.Python.framework.Versions.3.9.bin.python3.9', platform=Platform(platform='macosx_12_0_x86_64', impl='cp', version='3.9.10', version_info=(3, 9, 10), abi='cp39'), marker_environment=MarkerEnvironment(implementation_name='cpython', implementation_version='3.9.10', os_name='posix', platform_machine='x86_64', platform_python_implementation='CPython', platform_release='21.4.0', platform_system='Darwin', platform_version='Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64', python_full_version='3.9.10', python_version='3.9', sys_platform='darwin'), interpreter=PythonInterpreter('/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/bin/python3.9', PythonIdentity('/usr/local/opt/python@3.9/bin/python3.9', 'cp39', 'cp39', 'macosx_12_0_x86_64', (3, 9, 10)))), source_path='/Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz', fingerprint='25690654033451dd03d9db33437752b7b4785523')
  BuildRequest(target=LocalInterpreter(id='Applications.Xcode.app.Contents.Developer.Library.Frameworks.Python3.framework.Versions.3.8.bin.python3.8', platform=Platform(platform='macosx_12_0_x86_64', impl='cp', version='3.8.9', version_info=(3, 8, 9), abi='cp38'), marker_environment=MarkerEnvironment(implementation_name='cpython', implementation_version='3.8.9', os_name='posix', platform_machine='x86_64', platform_python_implementation='CPython', platform_release='21.4.0', platform_system='Darwin', platform_version='Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64', python_full_version='3.8.9', python_version='3.8', sys_platform='darwin'), interpreter=PythonInterpreter('/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/bin/python3.8', PythonIdentity('/Applications/Xcode.app/Contents/Developer/usr/bin/python3', 'cp38', 'cp38', 'macosx_12_0_x86_64', (3, 8, 9)))), source_path='/Users/x/.cache/pants/named_caches/pex_root/downloads/87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29/thrift-0.15.0.tar.gz', fingerprint='25690654033451dd03d9db33437752b7b4785523')
jsirois commented 2 years ago

I repro.

A bit more compact, but the key relevant fact that's not explicit in both @kaos's case and mine is the IC is ">=3.8" and we both have 3.8 and 3.9 interpreters available on the PATH (I have 3.10 as well). As such, the step creating the PEX file should include a thrift distribution built for each applicable local interpreter but does not:

$ pex -V
2.1.73
$ pex3 -V
2.1.73
$ pex-tools -V
2.1.73
$ pex3 lock create thrift==0.15.0 --style universal --interpreter-constraint ">=3.8" --indent 2 -o 1688.lock.json
$ cat 1688.lock.json 
{
  "allow_builds": true,
  "allow_prereleases": false,
  "allow_wheels": true,
  "build_isolation": true,
  "constraints": [],
  "locked_resolves": [
    {
      "locked_requirements": [
        {
          "artifacts": [
            {
              "algorithm": "sha256",
              "hash": "8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254",
              "url": "https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl"
            },
            {
              "algorithm": "sha256",
              "hash": "1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
              "url": "https://files.pythonhosted.org/packages/71/39/171f1c67cd00715f190ba0b100d606d440a28c93c7714febeca8b79af85e/six-1.16.0.tar.gz"
            }
          ],
          "project_name": "six",
          "requires_dists": [],
          "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7",
          "version": "1.16"
        },
        {
          "artifacts": [
            {
              "algorithm": "sha256",
              "hash": "87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29",
              "url": "https://files.pythonhosted.org/packages/6e/97/a73a1a62f62375b21464fa45a0093ef0b653cb14f7599cffce35d51c9161/thrift-0.15.0.tar.gz"
            }
          ],
          "project_name": "thrift",
          "requires_dists": [
            "six>=1.7.2",
            "tornado>=4.0; extra == \"all\"",
            "tornado>=4.0; extra == \"tornado\"",
            "twisted; extra == \"all\"",
            "twisted; extra == \"twisted\""
          ],
          "requires_python": null,
          "version": "0.15"
        }
      ],
      "platform_tag": [
        "cp310",
        "cp310",
        "manylinux_2_35_x86_64"
      ]
    }
  ],
  "pex_version": "2.1.73",
  "prefer_older_binary": false,
  "requirements": [
    "thrift==0.15.0"
  ],
  "requires_python": [
    ">=3.8"
  ],
  "resolver_version": "pip-legacy-resolver",
  "style": "universal",
  "transitive": true,
  "use_pep517": null
}
$ pex --interpreter-constraint ">=3.8" --lock 1688.lock.json -o 1688.pex
$ pex-tools 1688.pex info -i2
{
  "bootstrap_hash": "f8bcf3f144c35d3dddd7655fde455ab26aba89d0",
  "build_properties": {
    "pex_version": "2.1.73"
  },
  "code_hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
  "distributions": {
    "six-1.16.0-py2.py3-none-any.whl": "3e1c439c88d2e7681372427bab751b3fc99969891e95a714fed9604bf7710213",
    "thrift-0.15.0-cp38-cp38-linux_x86_64.whl": "132c47afddf05f70154b92dc4b086f870d75f078259779815def1e3a6feee8d0"
  },
  "emit_warnings": true,
  "ignore_errors": false,
  "includes_tools": false,
  "inherit_path": "false",
  "interpreter_constraints": [
    ">=3.8"
  ],
  "pex_hash": "29d1af706b72978a7a314e59720c773dd6b1d0e6",
  "pex_path": null,
  "requirements": [
    "thrift==0.15.0"
  ],
  "strip_pex_env": true,
  "venv": false,
  "venv_bin_path": "false",
  "venv_copies": false,
  "venv_site_packages_copies": false,
  "pex_root": "/home/jsirois/.pex"
}
$ python3.8 1688.pex -c 'import thrift; print(thrift.__file__)'
/home/jsirois/.pex/installed_wheels/4f1aefd59778dc830f0bbe8de3bf352aef10969f3ef112667606fa23c796f2ea/thrift-0.15.0-cp38-cp38-linux_x86_64.whl/thrift/__init__.py
$ python3.9 1688.pex -c 'import thrift; print(thrift.__file__)'
Traceback (most recent call last):
  File "/home/jsirois/.pex/unzipped_pexes/29d1af706b72978a7a314e59720c773dd6b1d0e6/.bootstrap/pex/pex.py", line 483, in execute
    self.activate()
  File "/home/jsirois/.pex/unzipped_pexes/29d1af706b72978a7a314e59720c773dd6b1d0e6/.bootstrap/pex/pex.py", line 147, in activate
    self._activated_dists = self._activate()
  File "/home/jsirois/.pex/unzipped_pexes/29d1af706b72978a7a314e59720c773dd6b1d0e6/.bootstrap/pex/pex.py", line 134, in _activate
    activated_dists.extend(env.activate())
  File "/home/jsirois/.pex/unzipped_pexes/29d1af706b72978a7a314e59720c773dd6b1d0e6/.bootstrap/pex/environment.py", line 312, in activate
    self._activated_dists = self._activate()
  File "/home/jsirois/.pex/unzipped_pexes/29d1af706b72978a7a314e59720c773dd6b1d0e6/.bootstrap/pex/environment.py", line 661, in _activate
    resolved = self.resolve()
  File "/home/jsirois/.pex/unzipped_pexes/29d1af706b72978a7a314e59720c773dd6b1d0e6/.bootstrap/pex/environment.py", line 492, in resolve
    for fingerprinted_distribution in self.resolve_dists(all_reqs)
  File "/home/jsirois/.pex/unzipped_pexes/29d1af706b72978a7a314e59720c773dd6b1d0e6/.bootstrap/pex/environment.py", line 516, in resolve_dists
    for qualified_req_or_not_found in self._root_requirements_iter(reqs):
  File "/home/jsirois/.pex/unzipped_pexes/29d1af706b72978a7a314e59720c773dd6b1d0e6/.bootstrap/pex/environment.py", line 457, in _root_requirements_iter
    raise ResolveError(message)
pex.environment.ResolveError: A distribution for thrift could not be resolved in this environment.Found 1 distribution for thrift that do not apply:
1.) The wheel tags for thrift 0.15.0 are cp38-cp38-linux_x86_64 which do not match the supported tags of /home/jsirois/.pyenv/versions/3.9.10/bin/python3.9:
cp39-cp39-manylinux_2_35_x86_64
...
py30-none-any
jsirois commented 2 years ago

It looks like lock resolves break an assumption of the wheel builder infra. That infra is normally fed 1 set of artifacts per target (since pip download ... is run once per target), but for a lock, all artifacts come centrally from a single multi-threaded download for all targets in ~/.pex/downloads. Looks like a simple fix.