Created
September 2, 2021 17:51
-
-
Save sethmlarson/cb35db612d80136da7a523a14d8fc1d4 to your computer and use it in GitHub Desktop.
Diff between brotlipy 0.7.0 tag and the source for building the abi3 compatible wheels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/setup.py b/setup.py | |
index f804932..12ae724 100644 | |
--- a/setup.py | |
+++ b/setup.py | |
@@ -1,11 +1,43 @@ | |
#!/usr/bin/env python | |
+import platform | |
+import sys | |
from setuptools import find_packages, setup | |
+from setuptools.command.build_ext import build_ext | |
long_description = ( | |
open("README.rst").read() + '\n\n' + open("HISTORY.rst").read() | |
) | |
+class BuildClibBeforeExt(build_ext): | |
+ """ Setuptools `develop` command (used by `pip install -e .`) only calls | |
+ `build_ext`, unlike `install` which calls `build` and all its related | |
+ sub-commands. Linking the CFFI extension with the libbrotli static library | |
+ fails since the `build_clib` command is not called in the former case. | |
+ This custom `build_ext` class ensures that `build_clib` command is run | |
+ before the CFFI extension module is compiled. | |
+ https://github.com/pypa/pip/issues/4523 | |
+ """ | |
+ | |
+ def run(self): | |
+ self.run_command("build_clib") | |
+ build_ext.run(self) | |
+ | |
+ | |
+cmdclass = {'build_ext': BuildClibBeforeExt} | |
+if sys.version_info > (3,) and platform.python_implementation() == "CPython": | |
+ try: | |
+ import wheel.bdist_wheel | |
+ except ImportError: | |
+ pass | |
+ else: | |
+ class BDistWheel(wheel.bdist_wheel.bdist_wheel): | |
+ def finalize_options(self): | |
+ self.py_limited_api = "cp3{}".format(sys.version_info[1]) | |
+ wheel.bdist_wheel.bdist_wheel.finalize_options(self) | |
+ cmdclass['bdist_wheel'] = BDistWheel | |
+ | |
+ | |
setup( | |
name="brotlipy", | |
version="0.7.0", | |
@@ -27,6 +59,7 @@ setup( | |
extras_require={ | |
':python_version == "2.7" or python_version == "3.3"': ['enum34>=1.0.4, <2'], | |
}, | |
+ cmdclass=cmdclass, | |
cffi_modules=["src/brotli/build.py:ffi"], | |
@@ -70,7 +103,6 @@ setup( | |
], | |
zip_safe=False, | |
classifiers=[ | |
"Programming Language :: Python :: Implementation :: CPython", | |
"Programming Language :: Python :: Implementation :: PyPy", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment