comparison 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
comparison
equal deleted inserted replaced
541:25b61f0a1958 542:f71d34dda19f
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 import re 4 import re
5 import os 5 import os
6 import platform
6 import sys 7 import sys
7 try: 8 try:
8 from setuptools import setup 9 from setuptools import setup
9 except ImportError: 10 except ImportError:
10 from distutils.core import setup 11 from distutils.core import setup
41 all_requirements = [] 42 all_requirements = []
42 all_requirements.extend(aws_requirements) 43 all_requirements.extend(aws_requirements)
43 all_requirements.extend(yaml_requirements) 44 all_requirements.extend(yaml_requirements)
44 all_requirements.extend(toml_requirements) 45 all_requirements.extend(toml_requirements)
45 46
47
48 cmdclass = {}
49 ext_modules = []
50
51 #
52 # Handle the optinal C-extension for Python3.7+ and CPython only.
53 # PyPy does not need this.
54 #
55
56 if (platform.python_implementation() == "CPython"
57 and (sys.version_info[0] > 3
58 or (sys.version_info[0] == 3 and sys.version_info[1] >= 7))):
59
60 py_limited_api = False
61
62 if py_limited_api:
63 define_macros = [("Py_LIMITED_API", "0x03070000")]
64 else:
65 define_macros = []
66
67 try:
68 from setuptools import Extension
69 except ImportError:
70 from distutils.core import Extension
71
72 ext_modules = [
73 Extension(
74 name="configmix._speedups",
75 sources=["configmix/_speedups.c"],
76 define_macros=define_macros,
77 py_limited_api=py_limited_api,
78 optional=True
79 ),
80 ]
81
82 if py_limited_api:
83 #
84 # Build a wheel that is properly named using the stable API
85 #
86 try:
87 import wheel.bdist_wheel
88 except ImportError:
89 cmdclass = {}
90 else:
91 class BDistWheel(wheel.bdist_wheel.bdist_wheel):
92 def finalize_options(self):
93 # Synchronize this with Py_LIMITED_API
94 self.py_limited_api = 'cp37'
95 super().finalize_options()
96
97 cmdclass = {'bdist_wheel': BDistWheel}
98
46 setup( 99 setup(
47 name="ConfigMix", 100 name="ConfigMix",
48 version=version, 101 version=version,
49 author="Franz Glasner", 102 author="Franz Glasner",
50 license='BSD 3-Clause "New" or "Revised" License', 103 license='BSD 3-Clause "New" or "Revised" License',
67 "Programming Language :: Python :: 2.7", 120 "Programming Language :: Python :: 2.7",
68 "Programming Language :: Python :: 3", 121 "Programming Language :: Python :: 3",
69 "Topic :: Software Development :: Libraries :: Python Modules" 122 "Topic :: Software Development :: Libraries :: Python Modules"
70 ], 123 ],
71 python_requires=">=2.6", 124 python_requires=">=2.6",
125 ext_modules=ext_modules,
126 cmdclass=cmdclass,
72 extras_require={ 127 extras_require={
73 "aws" : aws_requirements, 128 "aws" : aws_requirements,
74 "toml": toml_requirements, 129 "toml": toml_requirements,
75 "yaml": yaml_requirements, 130 "yaml": yaml_requirements,
76 "all" : all_requirements, 131 "all" : all_requirements,
77 }, 132 },
78 tests_require=all_requirements, 133 tests_require=all_requirements,