File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414
1515import os
1616import sys
17+ import sysconfig
1718from distutils .ccompiler import get_default_compiler
1819from distutils .core import setup , Extension
1920
2021PYTHON_SGP4_COMPILE = os .environ .get ('PYTHON_SGP4_COMPILE' , '' )
22+
23+ USE_PY_LIMITED_API = (
24+ # Py_buffer is required
25+ sys .version_info >= (3 , 11 )
26+ # LIMITED_API is not compatible with free-threading (as of CPython 3.14)
27+ and not sysconfig .get_config_var ("Py_GIL_DISABLED" )
28+ )
29+ ABI3_TARGET_VERSION = "" .join (str (_ ) for _ in sys .version_info [:2 ])
30+ ABI3_TARGET_HEX = hex (sys .hexversion & 0xFFFF00F0 )
31+
2132ext_modules = []
33+ define_macros = []
34+
35+ if USE_PY_LIMITED_API :
36+ define_macros .append (("Py_LIMITED_API" , ABI3_TARGET_HEX ))
2237
2338if sys .version_info [0 ] == 3 and PYTHON_SGP4_COMPILE != 'never' :
2439
4459 'extension/wrapper.cpp' ,
4560 ],
4661 extra_compile_args = extra_compile_args ,
62+ define_macros = define_macros ,
63+ py_limited_api = USE_PY_LIMITED_API ,
4764 ))
4865
4966# Read the package's docstring and "__version__" without importing it.
98115 package_data = {'sgp4' : ['SGP4-VER.TLE' , 'sample*' , 'tcppver.out' ]},
99116 provides = ['sgp4' ],
100117 ext_modules = ext_modules ,
118+ options = {
119+ "bdist_wheel" : {"py_limited_api" : "cp%s" % ABI3_TARGET_VERSION }
120+ } if USE_PY_LIMITED_API else {},
101121 ** setup_kwargs ,
102122)
You can’t perform that action at this time.
0 commit comments