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 .core import setup , Extension
1819
1920PYTHON_SGP4_COMPILE = os .environ .get ('PYTHON_SGP4_COMPILE' , '' )
21+
22+ # LIMITED_API is not compatible with free-threading (as of CPython 3.14)
23+ USE_PY_LIMITED_API = (
24+ sys .version_info [0 ] == 3
25+ and not sysconfig .get_config_var ("Py_GIL_DISABLED" )
26+ )
27+ ABI3_TARGET_VERSION = "" .join (str (_ ) for _ in sys .version_info [:2 ])
28+ ABI3_TARGET_HEX = hex (sys .hexversion & 0xFFFF00F0 )
29+
2030ext_modules = []
31+ define_macros = []
32+
33+ if USE_PY_LIMITED_API :
34+ define_macros .append (("Py_LIMITED_API" , ABI3_TARGET_HEX ))
2135
2236if sys .version_info [0 ] == 3 and PYTHON_SGP4_COMPILE != 'never' :
2337
3347 'extension/SGP4.cpp' ,
3448 'extension/wrapper.cpp' ,
3549 ],
50+ define_macros = define_macros ,
51+ py_limited_api = USE_PY_LIMITED_API ,
3652
3753 # TODO: can we safely figure out how to use a pair of options
3854 # like these, adapted to as many platforms as possible, to use
89105 package_data = {'sgp4' : ['SGP4-VER.TLE' , 'sample*' , 'tcppver.out' ]},
90106 provides = ['sgp4' ],
91107 ext_modules = ext_modules ,
108+ options = {
109+ "bdist_wheel" : {"py_limited_api" : "cp%s" % ABI3_TARGET_VERSION }
110+ } if USE_PY_LIMITED_API else {},
92111)
You can’t perform that action at this time.
0 commit comments