Repository navigation
Fix PyPy dependency marker - #280
Conversation
|
PyPy ships its own version of cffi which cannot be replaced by one from pip at all. I wonder if there is a way to error out entirely if the pyproject.toml is ever run on PyPy. |
|
there doesn't seem to be a standard project-level marker for excluding PyPy since
diff --git a/setup.py b/setup.py
index 50b487ea..151717aa 100644
--- a/setup.py
+++ b/setup.py
@@ -168,29 +168,18 @@ if forced_extra_objs:
if __name__ == '__main__':
- from setuptools import setup, Distribution, Extension
+ from setuptools import setup, Extension
- class CFFIDistribution(Distribution):
- def has_ext_modules(self):
- # Event if we don't have extension modules (e.g. on PyPy) we want to
- # claim that we do so that wheels get properly tagged as Python
- # specific. (thanks dstufft!)
- return True
-
- # On PyPy, cffi is preinstalled and it is not possible, at least for now,
- # to install a different version. We work around it by making the setup()
- # arguments mostly empty in this case.
- cpython = ('_cffi_backend' not in sys.builtin_module_names)
+ if '_cffi_backend' in sys.builtin_module_names:
+ raise RuntimeError(
+ 'CFFI backend is built into this interpreter and cannot be replaced')
setup(
- packages=['cffi'] if cpython else [],
+ packages=['cffi'],
package_dir={"": "src"},
package_data={'cffi': ['_cffi_include.h', 'parse_c_type.h',
- '_embedding.h', '_cffi_errors.h']}
- if cpython else {},
+ '_embedding.h', '_cffi_errors.h']},
zip_safe=False,
-
- distclass=CFFIDistribution,
ext_modules=[Extension(
name='_cffi_backend',
include_dirs=include_dirs,
@@ -201,5 +190,5 @@ if __name__ == '__main__':
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
extra_objects=forced_extra_objs,
- )] if cpython else [],
+ )],
) |
|
My point is that this PR might as well drop the PyPy-specific part of the dependency entirely, since it should never be hit. |
|
pypy/pypy#5306 shows why this exclusion exists. PyPy vendors a later CFFI sync therefore brought upstream dependency metadata back, and current PyPy 3.11 again carries CFFI's |
|
OK, let's go with this. Thanks @doe1080 |
implementation_namemaps tosys.implementation.name, whose value is guaranteed to be lowercase, so the marker should usepypyhttps://packaging.python.org/en/latest/specifications/dependency-specifiers/#defined-environment-marker-fields
https://docs.python.org/3/library/sys.html#sys.implementation