Created
April 21, 2025 15:53
-
-
Save ngoldbaum/ea251bb5abb10c1b46fc6bceca8ac606 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/setup.py b/setup.py | |
index 4029e9e..c855180 100644 | |
--- a/setup.py | |
+++ b/setup.py | |
@@ -3,6 +3,9 @@ import os | |
import sys | |
from setuptools import Extension, setup | |
+from Cython.Build import cythonize | |
+from Cython.Compiler.Version import version as cython_version | |
+from packaging.version import Version | |
PYPY = hasattr(sys, "pypy_version_info") | |
@@ -18,7 +21,7 @@ if not PYPY and not os.environ.get("MSGPACK_PUREPYTHON"): | |
ext_modules.append( | |
Extension( | |
"msgpack._cmsgpack", | |
- sources=["msgpack/_cmsgpack.c"], | |
+ sources=["msgpack/_cmsgpack.pyx"], | |
libraries=libraries, | |
include_dirs=["."], | |
define_macros=macros, | |
@@ -26,7 +29,18 @@ if not PYPY and not os.environ.get("MSGPACK_PUREPYTHON"): | |
) | |
del libraries, macros | |
+compiler_directives = { | |
+ "cdivision": True, | |
+ "embedsignature": True, | |
+ "boundscheck": False, | |
+ "wraparound": False, | |
+} | |
+ | |
+ | |
+if Version(cython_version) >= Version("3.1.0a0"): | |
+ compiler_directives["freethreading_compatible"] = True | |
+ | |
setup( | |
- ext_modules=ext_modules, | |
+ ext_modules=cythonize(ext_modules, compiler_directives = compiler_directives), | |
packages=["msgpack"], | |
-) | |
+) | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment