python-cffi / cffi

A Foreign Function Interface package for calling C libraries from Python.
https://cffi.readthedocs.io/en/latest/
Other
131 stars 42 forks source link

Pip check on PyPy mistakenly fails due to missing pycparser #128

Closed Zeitsperre closed 2 months ago

Zeitsperre commented 2 months ago

I've noticed on some builds using PyPy that pip check seems to report that pycparser is missing. After looking at the setup.py, I'm not sure how that could be the case, but all the same, I'm getting build failures:

pypy310: install_deps> python -I -m pip install -r /home/runner/work/cookiecutter-pypackage/cookiecutter-pypackage/requirements_dev.txt
.pkg: install_requires> python -I -m pip install 'setuptools>=40.8.0' wheel
.pkg: _optional_hooks> python /opt/hostedtoolcache/PyPy/3.10.14/x64/lib/pypy3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_sdist> python /opt/hostedtoolcache/PyPy/3.10.14/x64/lib/pypy3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_wheel> python /opt/hostedtoolcache/PyPy/3.10.14/x64/lib/pypy3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: freeze> python -m pip freeze --all
.pkg: cffi==1.17.0,greenlet==0.4.13,hpy==0.9.0,pip==24.1,readline==6.2.4.1,setuptools==70.1.0,wheel==0.43.0
.pkg: prepare_metadata_for_build_wheel> python /opt/hostedtoolcache/PyPy/3.10.14/x64/lib/pypy3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: build_sdist> python /opt/hostedtoolcache/PyPy/3.10.14/x64/lib/pypy3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
pypy310: install_package> python -I -m pip install --force-reinstall --no-deps /home/runner/work/cookiecutter-pypackage/cookiecutter-pypackage/.tox/.tmp/package/1/cookiecutter_pypackage-0.1.0.tar.gz
pypy310: freeze> python -m pip freeze --all
pypy310: alabaster==1.0.0,arrow==1.3.0,backports.tarfile==1.2.0,binaryornot==0.4.4,build==1.2.1,cachetools==5.5.0,certifi==2024.8.30,cffi==1.17.0,cfgv==3.4.0,chardet==5.2.0,charset-normalizer==3.3.2,click==8.1.7,colorama==0.4.6,cookiecutter==2.6.0,cookiecutter-pypackage==0.1.0,coverage==7.6.1,cryptography==43.0.1,distlib==0.3.8,docutils==0.21.2,exceptiongroup==1.2.2,filelock==3.15.4,flit==3.9.0,flit_core==3.9.0,greenlet==0.4.13,hpy==0.9.0,identify==2.6.0,idna==3.8,importlib_metadata==8.4.0,iniconfig==2.0.0,jaraco.classes==3.4.0,jaraco.context==6.0.1,jaraco.functools==4.0.2,jeepney==0.8.0,Jinja2==3.1.4,keyring==25.3.0,markdown-it-py==3.0.0,MarkupSafe==2.1.5,mdurl==0.1.2,more-itertools==10.4.0,nh3==0.2.18,nodeenv==1.9.1,packaging==24.1,pip==24.2,pkginfo==1.10.0,platformdirs==4.2.2,pluggy==1.5.0,pre-commit==3.8.0,Pygments==2.18.0,pyproject-api==1.7.1,pyproject_hooks==1.1.0,pytest==8.3.2,pytest-cookies==0.7.0,python-dateutil==2.9.0.post0,python-slugify==8.0.4,PyYAML==6.0.2,readline==6.2.4.1,readme_renderer==44.0,requests==2.32.3,requests-toolbelt==1.0.0,rfc3986==2.0.0,rich==13.8.0,SecretStorage==3.3.3,setuptools==74.1.1,six==1.16.0,text-unidecode==1.3,tomli==2.0.1,tomli_w==1.0.0,tox==4.18.0,twine==5.1.1,types-python-dateutil==2.9.0.20240821,urllib3==2.2.2,virtualenv==20.26.3,watchdog==5.0.2,wheel==0.44.0,zipp==3.20.1
pypy310: commands_pre[0]> pip list
Package                Version
---------------------- --------------
alabaster              1.0.0
arrow                  1.3.0
backports.tarfile      1.2.0
binaryornot            0.4.4
build                  1.2.1
cachetools             5.5.0
certifi                2024.8.30
cffi                   1.17.0
cfgv                   3.4.0
chardet                5.2.0
charset-normalizer     3.3.2
click                  8.1.7
colorama               0.4.6
cookiecutter           2.6.0
cookiecutter-pypackage 0.1.0
coverage               7.6.1
cryptography           43.0.1
distlib                0.3.8
docutils               0.21.2
exceptiongroup         1.2.2
filelock               3.15.4
flit                   3.9.0
flit_core              3.9.0
greenlet               0.4.13
hpy                    0.9.0
identify               2.6.0
idna                   3.8
importlib_metadata     8.4.0
iniconfig              2.0.0
jaraco.classes         3.4.0
jaraco.context         6.0.1
jaraco.functools       4.0.2
jeepney                0.8.0
Jinja2                 3.1.4
keyring                25.3.0
markdown-it-py         3.0.0
MarkupSafe             2.1.5
mdurl                  0.1.2
more-itertools         10.4.0
nh3                    0.2.18
nodeenv                1.9.1
packaging              24.1
pip                    24.2
pkginfo                1.10.0
platformdirs           4.2.2
pluggy                 1.5.0
pre-commit             3.8.0
Pygments               2.18.0
pyproject-api          1.7.1
pyproject_hooks        1.1.0
pytest                 8.3.2
pytest-cookies         0.7.0
python-dateutil        2.9.0.post0
python-slugify         8.0.4
PyYAML                 6.0.2
readline               6.2.4.1
readme_renderer        44.0
requests               2.32.3
requests-toolbelt      1.0.0
rfc3986                2.0.0
rich                   13.8.0
SecretStorage          3.3.3
setuptools             74.1.1
six                    1.16.0
text-unidecode         1.3
tomli                  2.0.1
tomli_w                1.0.0
tox                    4.18.0
twine                  5.1.1
types-python-dateutil  2.9.0.20240821
urllib3                2.2.2
virtualenv             20.26.3
watchdog               5.0.2
wheel                  0.44.0
zipp                   3.20.1
pypy310: commands_pre[1]> pip check
cffi 1.17.0 requires pycparser, which is not installed.
pypy310: exit 1 (0.89 seconds) /home/runner/work/cookiecutter-pypackage/cookiecutter-pypackage> pip check pid=3436
nitzmahone commented 2 months ago

Took me a minute, but I think I see the problem... I'm betting PyPy's embedded CFFI gets "installed" during their build from CFFI's sdist, not from source. CFFI's setup.py dynamically adds pycparser only if it's running under CPython (which it is when we build our sdist)- if the way PyPy's build installs it isn't recalculating the egg-info/dist-info from setup.py, it's going to erroneously list pycparser as a required dep in the bundled metadata.

That dep should really be handled declaratively with an environment marker to exclude PyPy, rather than dynamically injected- if my guess is correct, that will automatically solve the problem everywhere once PyPy updates to a version of CFFI that does it that way.