Skip to content

Commit

Permalink
set py_limited_api=False for free-threaded CPython
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Aug 2, 2024
1 parent fb12b7e commit e9eb136
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import platform
import sys
import sysconfig

from setuptools import setup

Expand All @@ -14,7 +15,11 @@

class BDistWheel(wheel.bdist_wheel.bdist_wheel):
def finalize_options(self):
self.py_limited_api = f"cp3{sys.version_info[1]}"
# free-threaded CPython doesn't support limited API
if sysconfig.get_config_var("Py_GIL_DISABLED"):
self.py_limited_api = False
else:
self.py_limited_api = f"cp3{sys.version_info[1]}"
wheel.bdist_wheel.bdist_wheel.finalize_options(self)

cmdclass["bdist_wheel"] = BDistWheel
Expand Down
3 changes: 3 additions & 0 deletions src/_argon2_cffi_bindings/_ffi_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import platform
import sysconfig

from pathlib import Path

Expand Down Expand Up @@ -48,6 +49,7 @@ def _get_target_platform(arch_flags, default):
"_ffi",
"#include <argon2.h>",
libraries=["argon2"],
py_limited_api=not sysconfig.get_config_var("Py_GIL_DISABLED"),
)
else:
lib_base = Path("extras") / "libargon2" / "src"
Expand All @@ -56,6 +58,7 @@ def _get_target_platform(arch_flags, default):
"#include <argon2.h>",
extra_compile_args=["-msse2"] if (optimized and not windows) else None,
include_dirs=[os.path.join("extras", "libargon2", "include")],
py_limited_api=not sysconfig.get_config_var("Py_GIL_DISABLED"),
sources=[
str(lib_base / path)
for path in [
Expand Down

0 comments on commit e9eb136

Please sign in to comment.