Mercurial > hgrepos > Python > libs > ConfigMix
diff setup.py @ 542:f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
This is currently for Python 3.5+.
It is tested with Python 3.7 and Python3.8 (FreeBSD 12.2 amd64, LLVM 10.0.1).
A build for the stable API ("abi3") fails because PyUnicode_New() is currently
not in the stable API.
Also includes are extended tests for unquote() and pathstr2path().
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 31 Dec 2021 21:24:16 +0100 |
| parents | eed16a1ec8f3 |
| children | 6501fe0e116c |
line wrap: on
line diff
--- a/setup.py Wed Dec 29 13:33:11 2021 +0100 +++ b/setup.py Fri Dec 31 21:24:16 2021 +0100 @@ -3,6 +3,7 @@ import re import os +import platform import sys try: from setuptools import setup @@ -43,6 +44,58 @@ all_requirements.extend(yaml_requirements) all_requirements.extend(toml_requirements) + +cmdclass = {} +ext_modules = [] + +# +# Handle the optinal C-extension for Python3.7+ and CPython only. +# PyPy does not need this. +# + +if (platform.python_implementation() == "CPython" + and (sys.version_info[0] > 3 + or (sys.version_info[0] == 3 and sys.version_info[1] >= 7))): + + py_limited_api = False + + if py_limited_api: + define_macros = [("Py_LIMITED_API", "0x03070000")] + else: + define_macros = [] + + try: + from setuptools import Extension + except ImportError: + from distutils.core import Extension + + ext_modules = [ + Extension( + name="configmix._speedups", + sources=["configmix/_speedups.c"], + define_macros=define_macros, + py_limited_api=py_limited_api, + optional=True + ), + ] + + if py_limited_api: + # + # Build a wheel that is properly named using the stable API + # + try: + import wheel.bdist_wheel + except ImportError: + cmdclass = {} + else: + class BDistWheel(wheel.bdist_wheel.bdist_wheel): + def finalize_options(self): + # Synchronize this with Py_LIMITED_API + self.py_limited_api = 'cp37' + super().finalize_options() + + cmdclass = {'bdist_wheel': BDistWheel} + setup( name="ConfigMix", version=version, @@ -69,8 +122,10 @@ "Topic :: Software Development :: Libraries :: Python Modules" ], python_requires=">=2.6", + ext_modules=ext_modules, + cmdclass=cmdclass, extras_require={ - "aws" : aws_requirements, + "aws" : aws_requirements, "toml": toml_requirements, "yaml": yaml_requirements, "all" : all_requirements,
