Hi friends, how would you generally resolve pants ...
# general
c
Hi friends, how would you generally resolve pants build error No matching distribution found for XXX? For example, right now I’m facing the error
Copy code
ERROR: Could not find a version that satisfies the requirement gitpython==3.1.29
ERROR: No matching distribution found for gitpython==3.1.29
However, there is clearly such version available and it has a very loose python version requirement
Requires: Python >=3.7
. On my pants project, I have set the interpreter_constraints to
"['CPython==3.10.11']"
b
Can you install it outside of pants, e.g. using that interpreter, run
pip install gitpython==3.1.29
?
c
Yes, it worked perfectly fine
b
Hm. https://www.pantsbuild.org/docs/troubleshooting has a few tips that might help. I could imagine most helpful might be increasing the pex verbosity and using “keep sandboxes” to be able to play with the processes
h
A little repo on github that reproduces the problem would be super helpful
c
increasing the pex verbosity and using “keep sandboxes” to be able to play with the processes
Thanks @broad-processor-92400 , could you suggest how to “play with the process” that can help us narrow down the issue?
@happy-kitchen-89482 it’s our internal repo 😅 I wonder is there a way to make pants print out more specific errors about the missing dependency? For example, which specific python version it uses when try to locate the dependency?
h
Creating a sample repo that demonstrates the problem will force you to isolate it, which will get closer to solving it.
If you keep sandboxes you can cd into the sandbox dir and run the process in there (see __run.sh in the sandbox) see what is different between that command and a command that does work, and so on.
There is debugging you must do here.
c
update: I was able to preserve the sandbox and check the __run.sh file). I manually ran the last command in the __run.sh file and reproduced the
ERROR: Could not find a version that satisfies the requirement gitpython==3.1.29
Copy code
/Users/jayzhong/.pyenv/versions/3.10.11/bin/python ./pex --tmpdir .tmp --jobs 16 --python-path $'/Users/jayzhong/.pyenv/versions/3.10.11/bin:/Users/jayzhong/.pyenv/versions/3.7.10/bin:/Users/jayzhong/.pyenv/versions/3.7.8/bin:/Users/jayzhong/.pyenv/versions/af2/bin:/Users/jayzhong/src/pynest/.310venv/bin:/usr/local/Cellar/pyenv-virtualenv/1.2.1/shims:/Users/jayzhong/.pyenv/shims:/Users/jayzhong/go/bin:/usr/local/opt/libpq/bin:/usr/local/Caskroom/miniconda/base/bin:/usr/local/Caskroom/miniconda/base/condabin:/Users/jayzhong/.rbenv/shims:/Users/jayzhong/.pyenv/bin:/Applications/SnowSQL.app/Contents/MacOS:/Users/jayzhong/.pyenv/bin:/Users/jayzhong/.rbenv/shims:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/jayzhong/.cargo/bin:/usr/local/opt/fzf/bin' --output-file airflow2.src.python.airflow_dags.data/cb-airflow.pex --no-emit-warnings --manylinux manylinux2014 --requirements-pex local_dists.pex --interpreter-constraint $'CPython<4,==3.10.11,>=3.7' --entry-point airflow_dags.data.cb-airflow $'--sources-directory=source_files' $'MarkupSafe==2.1.2' $'anaplan-api==0.1.28' $'apache-airflow-providers-amazon==3.1.1' $'apache-airflow-providers-ftp==2.1.2' $'apache-airflow-providers-http==2.0.0' $'apache-airflow-providers-imap==2.2.3' $'apache-airflow-providers-postgres==2.0.0' $'apache-airflow-providers-sqlite==2.1.3' $'apache-airflow==2.3.4' $'argcomplete==1.12.3' $'atlasapi==0.13.2' $'atomicwrites==1.4.1' $'authlib==0.15.2' $'beautifulsoup4==4.9.2' $'boto3==1.26.11' $'botocore==1.29.11' $'cachetools==4.1.1' $'cb-amundsen-databuilder>=6.8.42' $'cb_config>=0.0.86' $'celery~=5.2.7' $'click==8.0.4' $'confluent-kafka==2.0.2' $'contentful_management==2.11.0' $'croniter==1.0.15' $'dask-gateway==0.9.0' $'dask[dataframe]==2022.2.0' $'databricks-sql-connector==2.3.0' $'datadog-api-client==2.11.0' $'datadog>=0.38.0' $'db-dtypes==1.0.5' $'dbt-snowflake==1.4.2' $'delighted==1.1.2' $'distributed==2022.2.0' $'duckdb==0.6.1' $'duo_client==4.4.0' $'elasticsearch==7.13.4' $'eth-rlp==0.2.0' $'ethereum-etl==1.11.2' $'fastavro==1.7.1' $'flask-openid==1.3.0' $'flask==2.2.3' $'flower==1.0.0' $'fqs_configurator==0.0.10' $'future==0.18.2' $'getuseragent==0.0.7' $'gitpython==3.1.29' $'google-api-python-client==2.65.0' $'google-cloud-bigquery==2.34.0' $'googleapis-common-protos~=1.57.0' $'gremlinpython==3.6.1' $'grpcio-health-checking==1.39.0; python_version == "3.7"' $'grpcio-health-checking==1.42.0; python_version == "3.10"' $'grpcio-reflection==1.39.0; python_version == "3.7"' $'grpcio-reflection==1.42.0; python_version == "3.10"' $'grpcio-status==1.42.0; python_version == "3.10"' $'grpcio-tools==1.39.0; python_version == "3.7"' $'grpcio-tools==1.42.0; python_version == "3.10"' $'grpcio==1.42.0; python_version == "3.10"' $'gspread==4.0.0' $'hologram==0.0.15' $'html5lib==1.1' $'httplib2==0.18.1' $'httpretty==1.1.4' $'importlib-metadata==4.11.3; python_version == "3.7"' $'importlib-metadata==4.11.4; python_version == "3.10"' $'importlib-resources==5.7.0' $'jeepney==0.7.1' $'jinja2==3.1.2' $'jira==3.2.0' $'jms-client==0.2.1' $'looker-sdk==22.20.0' $'matplotlib==3.5.3' $'mysql-connector-python==8.0.32' $'networkx==2.6.3' $'nostradamus==0.3.2' $'numpy==1.21.1; python_version == "3.7"' $'numpy==1.23.4; python_version == "3.10"' $'oauth2client==4.1.3' $'okta==2.3.1' $'omniduct==1.1.17' $'openpyxl==3.0.10' $'orjson>=3.8.5' $'pandas==1.3.5' $'paramiko==2.7.2' $'pendulum==2.1.2' $'proto-plus<=1.22.1,>1.19' $'protobuf>=3.19.4' $'psycopg2-binary==2.9.5' $'psycopg[binary,pool]==3.1.8' $'pyarrow==10.0.1' $'pycryptodome==3.9.1' $'pydantic==1.9.0' $'pygithub==1.44.1' $'pyhocon==0.3.59' $'pymongo>=4.0.1' $'pymysql==1.0.2' $'pyodbc==4.0.35' $'python-dateutil==2.8.2' $'python-gnupg==0.4.5' $'python-json-logger==2.0.2' $'python-levenshtein==0.12.0' $'pytrends==4.9.2' $'pyyaml==6.0' $'redis==3.5.3' $'requests-oauthlib==1.3.1' $'requests<3,>=2.2' $'s3-encryption==0.1.3' $'salesforce-bulk==2.1.0' $'sanpy==0.8.7' $'schema==0.7.1' $'scikit-learn==0.24.0' $'scipy==1.7.1; python_version == "3.7"' $'scipy==1.8.0; python_version == "3.10"' $'secretstorage==3.3.1' $'setuptools<67.0,>=59.1.1' $'simple-salesforce==1.0.0' $'simplejson==3.18.3' $'sklearn==0.0' $'slackclient==1.1.2' $'snowflake-connector-python[secure-local-storage]==3.0.3' $'snowflake-sqlalchemy==1.4.7' $'sqlalchemy==1.4.9' $'sqlfluff==1.2.1' $'sqlglot>=10.5.0' $'syrupy==2.3.0' $'tabulate==0.9.0' $'tenacity==6.2.0' $'tornado==6.1' $'types-Flask==1.1.3' $'types-PyMySQL==1.0.19' $'types-PyYAML==5.4.6' $'types-cachetools==4.2.0' $'types-paramiko==0.1.9' $'types-pytz==2022.7.1' $'types-requests==2.25.6' $'types-setuptools<67,>=58' $'unidecode==1.3.3' $'werkzeug==2.2.3' $'xlrd==2.0.1' $'xlwt==1.3.0' --no-pypi $'--index=<https://pypi.org/simple/>' $'--index=<https://artifactory-pypi.cbhq.net/simple/>' --resolver-version pip-2020-resolver --constraints __constraints.txt --layout zipapp
👍 1
Based on a comment by @happy-kitchen-89482,
pex now delegates resolution to pip
. So it must be pip cannot install
gitpython==3.1.29
?
b
Cool, nice that you can reproduce it. To debug further, you could look at editing that that command down to be the minimal possible (e.g. try removing all the requirements except the
gitpython
one and see if it fails), and then look at
./pex --help
because I think there's some options to increase verbosity and even have it preserve the pip log for your debugging
👀 1
c
I removed all other dependencies and still got the same error
Copy code
/Users/jayzhong/.pyenv/versions/3.10.11/bin/python ./pex --tmpdir .tmp --jobs 16 --python-path $'/Users/jayzhong/.pyenv/versions/3.10.11/bin:/Users/jayzhong/.pyenv/versions/3.7.10/bin' --output-file airflow2.src.python.airflow_dags.data/cb-airflow.pex --no-emit-warnings --manylinux manylinux2014 --requirements-pex local_dists.pex --interpreter-constraint $'CPython<4,==3.10.11,>=3.7' --entry-point airflow_dags.data.cb-airflow $'--sources-directory=source_files' $'gitpython==3.1.29' --no-pypi $'--index=<https://pypi.org/simple/>' $'--index=<https://artifactory-pypi.cbhq.net/simple/>' --resolver-version pip-2020-resolver --constraints __constraints.txt --layout zipapp
pid 56773 -> /Users/jayzhong/.pex/venvs/c9e55cc98846b062ba9676b3c1a5214512602544/4cfd0bc71c00327bb73b53d6c2fa39962519f274/bin/python -sE /Users/jayzhong/.pex/venvs/c9e55cc98846b062ba9676b3c1a5214512602544/4cfd0bc71c00327bb73b53d6c2fa39962519f274/pex --disable-pip-version-check --no-python-version-warning --exists-action a --no-input --isolated -q --cache-dir /Users/jayzhong/.pex/pip_cache --log /private/var/folders/88/yqbj2brs0w7fzdqyr32n1q400000gp/T/pants-sandbox-hD7aCc/.tmp/pex-pip-log.sqcxwlm_/pip.log download --dest /Users/jayzhong/.pex/downloads/resolver_download.7o574oto/Users.jayzhong..pyenv.versions.3.10.11.bin.python3.10 --constraint __constraints.txt gitpython==3.1.29 --index-url <https://pypi.org/simple/> --extra-index-url <https://artifactory-pypi.cbhq.net/simple/> --retries 5 --timeout 15 exited with 1 and STDERR:
ERROR: Could not find a version that satisfies the requirement gitpython==3.1.29
ERROR: No matching distribution found for gitpython==3.1.29
alright, by looking at the --log file, I see something suspicious
Copy code
2023-06-07T16:08:50,868 Given no hashes to check 0 links for project 'gitpython': discarding no candidates
 2023-06-07T16:08:50,868 ERROR: Could not find a version that satisfies the requirement gitpython==3.1.29
 2023-06-07T16:08:50,869 ERROR: No matching distribution found for gitpython==3.1.29
 2023-06-07T16:08:50,869 Exception information:
 2023-06-07T16:08:50,869 Traceback (most recent call last):
 2023-06-07T16:08:50,869   File "/Users/jayzhong/.pex/venvs/c9e55cc98846b062ba9676b3c1a5214512602544/4cfd0bc71c00327bb73b53d6c2fa39962519f274/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 171, in _merge_into_criterion
 2023-06-07T16:08:50,869     crit = self.state.criteria[name]
 2023-06-07T16:08:50,869 KeyError: 'gitpython'
I found the issue, the gitpython version that specified in the command line parameter (
$'gitpython==3.1.29'
) is different from the one in the
--constraints __constraints.txt
file (
gitpython==3.1.31
). How come that can happen 🤔
b
Weird. Does your repository list multiple versions (e.g.
git grep gitpython
)?
c
gitpython is a transitive dependency, and my project does not explicitly codify gitpython in requirements.txt. Instead, we use
pip compile
to generate a constraints file (taking all the requirements.txt files as input).
I think it’s probably pants inferred version of gitpython is different from the version generated by
pip compile
? I solved the problem by pining gitpython version on requirements.txt
Thanks @broad-processor-92400 and @happy-kitchen-89482
👍 1
h
Where does that constraints file come from? Pants doesn't use one by default unless you configure it to
So next step would be to figure out that part perhaps
c
the constraints file is generated using
pip compile
and take all requirements.txt files as input
@happy-kitchen-89482 just to confirm: if somewhere in code we have
import oss_package
, but
oss_package
is not in any of the requirements.txt files, would pants automatically infer oss_package as a dependency?
I think that was what happened in my case
h
If you
import oss_package
but nothing provides that package, Pants will error
Or warn
depending on your config