|
152 | 152 | |
153 | 153 | PYMUPDF_SETUP_PY_LIMITED_API |
154 | 154 | If not '0', we build for current Python's stable ABI. |
| 155 | + |
| 156 | + However if unset and we are on Python-3.13 or later, we do |
| 157 | + not build for the stable ABI because as of 2025-03-04 SWIG |
| 158 | + generates incorrect stable ABI code with Python-3.13 - see: |
| 159 | + https://github.com/swig/swig/issues/3059 |
155 | 160 | |
156 | 161 | PYMUPDF_SETUP_URL_WHEEL |
157 | 162 | If set, we use an existing wheel instead of building a new wheel. |
@@ -242,10 +247,16 @@ def run(command, check=1): |
242 | 247 | # Name of file that identifies that we are in a PyMuPDF sdist. |
243 | 248 | g_pymupdfb_sdist_marker = 'pymupdfb_sdist' |
244 | 249 |
|
| 250 | +python_version_tuple = tuple(int(x) for x in platform.python_version_tuple()[:2]) |
| 251 | + |
245 | 252 | PYMUPDF_SETUP_PY_LIMITED_API = os.environ.get('PYMUPDF_SETUP_PY_LIMITED_API') |
246 | 253 | assert PYMUPDF_SETUP_PY_LIMITED_API in (None, '', '0', '1'), \ |
247 | 254 | f'Should be "", "0", "1" or undefined: {PYMUPDF_SETUP_PY_LIMITED_API=}.' |
248 | | -g_py_limited_api = (PYMUPDF_SETUP_PY_LIMITED_API != '0') |
| 255 | +if PYMUPDF_SETUP_PY_LIMITED_API is None and python_version_tuple >= (3, 13): |
| 256 | + log(f'Not defaulting to Python limited api because {platform.python_version_tuple()=}.') |
| 257 | + g_py_limited_api = False |
| 258 | +else: |
| 259 | + g_py_limited_api = (PYMUPDF_SETUP_PY_LIMITED_API != '0') |
249 | 260 |
|
250 | 261 | PYMUPDF_SETUP_URL_WHEEL = os.environ.get('PYMUPDF_SETUP_URL_WHEEL') |
251 | 262 | log(f'{PYMUPDF_SETUP_URL_WHEEL=}') |
|
0 commit comments