I have a project (TreeCorr) that uses cffi. On one of my machines (CentOS Linux release 7.2.1511) I get an error at runtime when I import treecorr after pip installing it:
>>> import treecorr Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/mjarvis/lib/python2.7/site-packages/TreeCorr-3.3.6-py2.7-linux-x86_64.egg/treecorr/__init__.py", line 38, in <module> _ffi = cffi.FFI() File "/home/mjarvis/.local/lib/python2.7/site-packages/cffi/api.py", line 59, in __init__ "version mismatch, %s != %s" % (backend.__version__, __version__) AssertionError: version mismatch, 1.6.0 != 1.9.1
The workaround is to pip install the same version the backend uses. In the above case:
$ pip install cffi==1.6.0
However, I would like to not require my users to hit this problem in the first place and have to manually do the above fix.
So do you know of any programmatic way in setup.py that I can check what backend is installed on their machine and have TreeCorr depend on the correct cffi version?
Or, even better, do you think it's possible that cffi can automatically do this itself on systems that are going to have this problem? Maybe have
pip install cffi install the correct backend along with the frontend? Or at least detect the backend itself and install the correct version of the frontend? Maybe that's not possible though.