hatch-ziglang 0.2.0__tar.gz → 0.2.1__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.4
2
2
  Name: hatch-ziglang
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A Hatch build hook that compiles a Zig extension into the wheel.
5
5
  Author-email: Marcelo Trylesinski <marcelotryle@gmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -39,9 +39,12 @@ def _windows_python_link() -> dict[str, str]:
39
39
  if sys.platform != "win32":
40
40
  return {}
41
41
  libdir = os.path.join(sys.base_prefix, "libs")
42
- # e.g. (3, 14) -> "python314"; free-threaded builds use "python314t".
43
- abiflags = sysconfig.get_config_var("abiflags") or ""
44
- libname = f"python{sys.version_info.major}{sys.version_info.minor}{abiflags}"
42
+ # e.g. (3, 14) -> "python314"; free-threaded builds use "python314t". The `t`
43
+ # comes from `abi_thread`, not `abiflags`: the latter is empty on Windows
44
+ # (there is no `sys.abiflags` there), which would link a free-threaded
45
+ # extension against the GIL import library and fail to resolve it.
46
+ abi_thread = sysconfig.get_config_var("abi_thread") or ""
47
+ libname = f"python{sys.version_info.major}{sys.version_info.minor}{abi_thread}"
45
48
  return {"HATCH_ZIG_PYTHON_LIBDIR": libdir, "HATCH_ZIG_PYTHON_LIB": libname}
46
49
 
47
50
 
@@ -163,19 +163,35 @@ def test_windows_python_link_non_windows(monkeypatch: pytest.MonkeyPatch) -> Non
163
163
  assert _windows_python_link() == {}
164
164
 
165
165
 
166
+ def _fake_config_vars(monkeypatch: pytest.MonkeyPatch, **values: str | None) -> None:
167
+ """Stub sysconfig.get_config_var so it answers per name, not for every lookup -
168
+ otherwise a test passes no matter which variable the plugin reads."""
169
+ monkeypatch.setattr("hatch_ziglang.plugin.sysconfig.get_config_var", lambda name: values.get(name))
170
+
171
+
166
172
  def test_windows_python_link(monkeypatch: pytest.MonkeyPatch) -> None:
167
173
  monkeypatch.setattr("hatch_ziglang.plugin.sys.platform", "win32")
168
174
  monkeypatch.setattr("hatch_ziglang.plugin.sys.base_prefix", r"C:\Python314")
169
175
  monkeypatch.setattr("hatch_ziglang.plugin.sys.version_info", SimpleNamespace(major=3, minor=14))
170
- monkeypatch.setattr("hatch_ziglang.plugin.sysconfig.get_config_var", lambda name: "t")
176
+ _fake_config_vars(monkeypatch, abi_thread="t", abiflags="t")
171
177
  env = _windows_python_link()
172
178
  assert env["HATCH_ZIG_PYTHON_LIB"] == "python314t"
173
179
  assert env["HATCH_ZIG_PYTHON_LIBDIR"].endswith("libs")
174
180
 
175
181
 
176
- def test_windows_python_link_no_abiflags(monkeypatch: pytest.MonkeyPatch) -> None:
182
+ def test_windows_python_link_no_abi_thread(monkeypatch: pytest.MonkeyPatch) -> None:
177
183
  monkeypatch.setattr("hatch_ziglang.plugin.sys.platform", "win32")
178
184
  monkeypatch.setattr("hatch_ziglang.plugin.sys.base_prefix", r"C:\Python313")
179
185
  monkeypatch.setattr("hatch_ziglang.plugin.sys.version_info", SimpleNamespace(major=3, minor=13))
180
- monkeypatch.setattr("hatch_ziglang.plugin.sysconfig.get_config_var", lambda name: None)
186
+ _fake_config_vars(monkeypatch)
181
187
  assert _windows_python_link()["HATCH_ZIG_PYTHON_LIB"] == "python313"
188
+
189
+
190
+ def test_windows_python_link_free_threaded_without_abiflags(monkeypatch: pytest.MonkeyPatch) -> None:
191
+ # Windows has no sys.abiflags, so sysconfig reports it empty even on a
192
+ # free-threaded interpreter; only abi_thread carries the `t`.
193
+ monkeypatch.setattr("hatch_ziglang.plugin.sys.platform", "win32")
194
+ monkeypatch.setattr("hatch_ziglang.plugin.sys.base_prefix", r"C:\Python314")
195
+ monkeypatch.setattr("hatch_ziglang.plugin.sys.version_info", SimpleNamespace(major=3, minor=14))
196
+ _fake_config_vars(monkeypatch, abi_thread="t", abiflags="")
197
+ assert _windows_python_link()["HATCH_ZIG_PYTHON_LIB"] == "python314t"
File without changes
File without changes
File without changes
File without changes