diff --git a/tests/run_tests.py b/tests/run_tests.py index b0665ae..e7fa80f 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -1297,6 +1297,10 @@ def test_signed(self): check_call(['delvewheel', 'repair', '--add-path', 'simpleext/x64', 'simpleext/simpleext-0.0.1-0sign-cp312-cp312-win_amd64.whl']) self.assertTrue(import_simpleext_successful('0sign')) + def test_free_threaded(self): + """Free-threaded wheel can be repaired""" + check_call(['delvewheel', 'repair', '--add-path', 'simpleext/x64', 'simpleext/simpleext-0.0.1-cp313-cp313t-win_amd64.whl']) + class NeededTestCase(unittest.TestCase): """Tests for delvewheel needed""" diff --git a/tests/simpleext/build/setup.py b/tests/simpleext/build/setup.py index dbb16d3..71bf97c 100644 --- a/tests/simpleext/build/setup.py +++ b/tests/simpleext/build/setup.py @@ -5,6 +5,7 @@ py_limited_api = False # set to True and add --py-limited-api=cp3__ to command line to build with Python limited API dependent_load_flags = '0' # change to set a different /DEPENDENTLOADFLAG linker option checksum = False # change to True to set the PE checksum +free_threaded = False # change to True to support free-threading if sys.maxsize > 2**32: library_dirs = ['simpledll/x64/Release'] @@ -21,6 +22,8 @@ python_requires = f">={py_major}.{py_minor}" else: python_requires = f"=={py_major}.{py_minor}.*" +if free_threaded: + define_macros.append(('Py_GIL_DISABLED', '1')) extra_link_args = [f'/DEPENDENTLOADFLAG:{dependent_load_flags}'] if checksum: extra_link_args.append('/RELEASE') diff --git a/tests/simpleext/build/simpleext.c b/tests/simpleext/build/simpleext.c index 2a8fe7a..7637f45 100644 --- a/tests/simpleext/build/simpleext.c +++ b/tests/simpleext/build/simpleext.c @@ -30,5 +30,10 @@ static struct PyModuleDef simpleextmodule = { PyMODINIT_FUNC SIMPLEEXT_INIT(void) { - return PyModule_Create(&simpleextmodule); + PyObject *m = PyModule_Create(&simpleextmodule); + if (!m) return NULL; +#ifdef Py_GIL_DISABLED + PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED); +#endif + return m; } diff --git a/tests/simpleext/simpleext-0.0.1-cp313-cp313t-win_amd64.whl b/tests/simpleext/simpleext-0.0.1-cp313-cp313t-win_amd64.whl new file mode 100644 index 0000000..d8d2780 Binary files /dev/null and b/tests/simpleext/simpleext-0.0.1-cp313-cp313t-win_amd64.whl differ