pact-python-ffi 0.5.12.0__tar.gz → 0.5.13.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pact-python-ffi
3
- Version: 0.5.12.0
3
+ Version: 0.5.13.0
4
4
  Summary: Python bindings for the Pact FFI library
5
5
  Project-URL: Bug Tracker, https://github.com/pact-foundation/pact-python/issues
6
6
  Project-URL: Changelog, https://github.com/pact-foundation/pact-python/blob/main/pact-python-ffi/CHANGELOG.md
@@ -28,6 +28,7 @@ Classifier: Programming Language :: Python :: 3.14
28
28
  Classifier: Programming Language :: Python :: 3.15
29
29
  Classifier: Topic :: Software Development :: Testing
30
30
  Requires-Python: >=3.11
31
+ Requires-Dist: cffi>=2.1.1; python_version >= '3.15'
31
32
  Requires-Dist: cffi~=2.0
32
33
  Description-Content-Type: text/markdown
33
34
 
@@ -12,6 +12,7 @@ import os
12
12
  import shutil
13
13
  import subprocess
14
14
  import sys
15
+ import sysconfig
15
16
  import tarfile
16
17
  import tempfile
17
18
  import urllib.request
@@ -30,6 +31,21 @@ PKG_DIR = Path(__file__).parent.resolve() / "src" / "pact_ffi"
30
31
  PACT_RELEASE_URL = "https://github.com/pact-foundation/pact-reference/releases/download/pact_ffi-v{version}"
31
32
 
32
33
 
34
+ def _stable_abi() -> str:
35
+ """
36
+ Determine the stable ABI targeted by the current interpreter.
37
+
38
+ CFFI compiles against `abi3t` on free-threaded CPython 3.15+ and against
39
+ `abi3` otherwise. Free-threaded interpreters do not load `abi3` extensions.
40
+
41
+ Returns:
42
+ Either `abi3` or `abi3t`.
43
+ """
44
+ if sysconfig.get_config_var("Py_GIL_DISABLED"):
45
+ return "abi3t"
46
+ return "abi3"
47
+
48
+
33
49
  class UnsupportedPlatformError(RuntimeError):
34
50
  """
35
51
  Custom error raised when the current platform is not supported.
@@ -199,12 +215,12 @@ class PactBuildHook(BuildHookInterface[Any]):
199
215
  # Compile the FFI extension
200
216
  extension = self._compile(lib, header)
201
217
 
202
- # Copy into the package directory, using the ABI3 marking for broad
203
- # compatibility.
218
+ # Copy into the package directory, using the stable ABI marking for
219
+ # broad compatibility.
204
220
  # NOTE: Windows does _not_ use the version infixation
205
221
  name = extension.name.split(".")[0]
206
222
  suffix = extension.suffix
207
- infix = ".abi3" if os.name != "nt" else ""
223
+ infix = f".{_stable_abi()}" if os.name != "nt" else ""
208
224
  extension_dest = f"{name}{infix}{suffix}"
209
225
  shutil.copy(extension, PKG_DIR / extension_dest)
210
226
 
@@ -474,13 +490,17 @@ class PactBuildHook(BuildHookInterface[Any]):
474
490
  """
475
491
  Infer the tag for the current build.
476
492
 
477
- The bindings are built to target ABI3, which is compatible with multiple
478
- Python versions. As a result, we generate `py{version}-abi3-{platform}`
479
- tags for the wheels.
493
+ The bindings are built to target the stable ABI, which is compatible
494
+ with multiple Python versions. As a result, we generate
495
+ `cp{version}-abi3-{platform}` tags for the wheels.
480
496
 
481
497
  While the ABI3 interface was introduced in Python 3.2, we target the
482
498
  earliest supported version of Python in the Python wrapper.
483
499
 
500
+ A free-threaded build targets `abi3t`, which requires Python 3.15. Its
501
+ wheel takes the `cp{version}-abi3.abi3t-{platform}` tag, as the
502
+ extension also loads on GIL-enabled builds.
503
+
484
504
  Returns:
485
505
  The tag for the current build.
486
506
  """
@@ -501,4 +521,5 @@ class PactBuildHook(BuildHookInterface[Any]):
501
521
  else:
502
522
  raise UnsupportedPlatformError(platform)
503
523
 
504
- return f"cp{python_version}-abi3-{platform}"
524
+ abi = "abi3.abi3t" if _stable_abi() == "abi3t" else "abi3"
525
+ return f"cp{python_version}-{abi}-{platform}"