Using cffi while building a wheel causes a version mismatch on Ubuntu 22.04
Hello, I'm not quite sure this is the correct project to report this too, but otherwise I'm not sure what the proper venue would be.
When trying to install a package from pypi uisng pip on Ubuntu 22.04, which has cffi
in it's dependency chain, it causes a Version mismatch
in cffi during the build of a wheel: Exception: Version mismatch: this is the 'cffi' package version 1.15.1, located in '/tmp/pip-build-env-_4tu4y4u/overlay/local/lib/python3.10/dist-packages/cffi/api.py'. When we import the top-level '_cffi_backend' extension module, we get version 1.15.0, located in '/us r/lib/python3/dist-packages/_cffi_backend.cpython-310-s390x-linux-gnu.so'. The two versions should be equal; check your installation.
- Python Version:
Python 3.10.4
- pip Version:
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
- cffi Version:
1.15.1
Here is snipped of what I did:
~ $ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
~ $ pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
~ $ pip -vvv --log-file b4-install.log install --user --no-clean b4
...
Collecting pynacl
Created temporary directory: /tmp/pip-unpack-aibp462d
Looking up "https://files.pythonhosted.org/packages/a7/22/27582568be639dfe22ddb3902225f91f2f17ceff88ce80e4db396c8986da/PyNaCl-1.5.0.tar.gz" in the cache
Current age based on date: 2671
Ignoring unknown cache-control directive: immutable
Freshness lifetime from max-age: 365000000
The response is "fresh", returning cached response
365000000 > 2671
Using cached PyNaCl-1.5.0.tar.gz (3.4 MB)
Added pynacl from https://files.pythonhosted.org/packages/a7/22/27582568be639dfe22ddb3902225f91f2f17ceff88ce80e4db396c8986da/PyNaCl-1.5.0.tar.gz#sha256=8ac7448f09ab85811607bdd21ec2464495ac8b7c66d146bf545b0f08fb9220ba (from patatt<2.0,>=0.5->b4) to build tracker '/tmp/pip-req-tracker-syjs4u43'
Created temporary directory: /tmp/pip-build-env-5jjmcsm5
Created temporary directory: /tmp/pip-standalone-pip-7o3gt3cl
Running command pip subprocess to install build dependencies
Using pip 22.0.2 from /tmp/pip-standalone-pip-7o3gt3cl/__env_pip__.zip/pip (python 3.10)
Collecting setuptools>=40.8.0
Using cached setuptools-63.1.0-py3-none-any.whl (1.2 MB)
Collecting wheel
Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Collecting cffi>=1.4.1
Using cached cffi-1.15.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (446 kB)
Collecting pycparser
Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Installing collected packages: wheel, setuptools, pycparser, cffi
Creating /tmp/pip-build-env-5jjmcsm5/overlay/local/bin
changing mode of /tmp/pip-build-env-5jjmcsm5/overlay/local/bin/wheel to 755
Successfully installed cffi-1.15.1 pycparser-2.21 setuptools-63.1.0 wheel-0.37.1
Installing build dependencies ... done
Running command Getting requirements to build wheel
Getting requirements to build wheel ... done
Created temporary directory: /tmp/pip-modern-metadata-j_moqc6m
Running command Preparing metadata (pyproject.toml)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 174, in prepare_metadata_for_build_wheel
self.run_setup()
File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 158, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 202, in <module>
setup(
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 109, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 459, in __init__
_Distribution.__init__(
File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 293, in __init__
self.finalize_options()
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 837, in finalize_options
ep(self)
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 858, in _finalize_setup_keywords
ep.load()(self, ep.name, value)
File "/tmp/pip-build-env-5jjmcsm5/overlay/local/lib/python3.10/dist-packages/cffi/setuptools_ext.py", line 219, in cffi_modules
add_cffi_module(dist, cffi_module)
File "/tmp/pip-build-env-5jjmcsm5/overlay/local/lib/python3.10/dist-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "/tmp/pip-build-env-5jjmcsm5/overlay/local/lib/python3.10/dist-packages/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "src/bindings/build.py", line 35, in <module>
ffi = FFI()
File "/tmp/pip-build-env-5jjmcsm5/overlay/local/lib/python3.10/dist-packages/cffi/api.py", line 54, in __init__
raise Exception("Version mismatch: this is the 'cffi' package version %s, located in %r. When we import the top-level '_cffi_backend' extension module, we get version %s, located in %r. The two versions should be equal; check your installation." % (
Exception: Version mismatch: this is the 'cffi' package version 1.15.1, located in '/tmp/pip-build-env-5jjmcsm5/overlay/local/lib/python3.10/dist-packages/cffi/api.py'. When we import the top-level '_cffi_backend' extension module, we get version 1.15.0, located in '/usr/lib/python3/dist-packages/_cffi_backend.cpython-310-s390x-linux-gnu.so'. The two versions should be equal; check your installation.
...
Here is the full log: b4-install.log
The problem seem to be that during the building of the wheel the build doesn't link against the cffi
library that was installed as dependency in the temporary build directory: /tmp/pip-build-env-5jjmcsm5/overlay/local/lib/python3.10/dist-packages/_cffi_backend.cpython-310-s390x-linux-gnu.so
, but instead it links against the library that is part of the base systems: /usr/lib/python3/dist-packages/_cffi_backend.cpython-310-s390x-linux-gnu.so
. That causes the version mismatch.
Installing the cffi package explicitly before the wheel is build (pip install --user cffi
) doesn't help; during the build it will still download it's own version of the package, and the same thing happens as above.