From 3022080bfb50027d307622ceb49faa77309c9111 Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 16:35:47 -0800 Subject: [PATCH 01/13] Windows build (2) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0505a98..0271e68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: - ubuntu-24.04-arm - macos-15-intel - macos-14 -# - windows-latest + - windows-latest # - windows-11-arm steps: - name: Checkout From 83a67a528958d2bc4790e516a43773b74014b9f7 Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 16:52:41 -0800 Subject: [PATCH 02/13] Windows build (2) --- build.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/build.py b/build.py index 605cd7c..011d035 100644 --- a/build.py +++ b/build.py @@ -1,5 +1,7 @@ import contextlib import shutil +import sys +import sysconfig import typing from pathlib import Path @@ -7,9 +9,23 @@ from pydust.build import build +def _ensure_ld_library() -> None: + """ + Pydust assumes LDLIBRARY is always set, but on Windows (especially in PEP 517 isolated builds) it may be None. + Provide a correct fallback. + """ + if sys.platform != "win32": + return + + if sysconfig.get_config_var("LDLIBRARY") is None: + sysconfig._CONFIG_VARS["LDLIBRARY"] = f"python{sys.version_info.major}{sys.version_info.minor}.lib" + + @contextlib.contextmanager def ensure_ffi_location() -> typing.Iterator[None]: - """For some reason, `zig translate-c` is looking for `ffi.h` in the wrong location.""" + """ + For some reason, `zig translate-c` is looking for `ffi.h` in the wrong location. + """ dst = Path("pydust/src/ffi.h") dst.parent.mkdir(parents=True, exist_ok=True) src = Path(pydust.__file__).parent / "src" / "ffi.h" @@ -18,5 +34,7 @@ def ensure_ffi_location() -> typing.Iterator[None]: shutil.rmtree(Path("pydust")) +_ensure_ld_library() + with ensure_ffi_location(): build() From 01eaa90029cab549c6aaaa7ea16d1f2d7088cdf6 Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 16:56:50 -0800 Subject: [PATCH 03/13] Windows build (2) --- build.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index 011d035..a15b7c0 100644 --- a/build.py +++ b/build.py @@ -5,9 +5,6 @@ import typing from pathlib import Path -import pydust -from pydust.build import build - def _ensure_ld_library() -> None: """ @@ -21,6 +18,13 @@ def _ensure_ld_library() -> None: sysconfig._CONFIG_VARS["LDLIBRARY"] = f"python{sys.version_info.major}{sys.version_info.minor}.lib" +_ensure_ld_library() # MUST happen before importing pydust + + +import pydust # noqa: E402 +from pydust.build import build # noqa: E402 + + @contextlib.contextmanager def ensure_ffi_location() -> typing.Iterator[None]: """ @@ -34,7 +38,5 @@ def ensure_ffi_location() -> typing.Iterator[None]: shutil.rmtree(Path("pydust")) -_ensure_ld_library() - with ensure_ffi_location(): build() From a5cffb764989481266279f5d447131a129ada600 Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 18:23:07 -0800 Subject: [PATCH 04/13] Monkeypatching buildzig --- build.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/build.py b/build.py index a15b7c0..2375cdc 100644 --- a/build.py +++ b/build.py @@ -22,8 +22,51 @@ def _ensure_ld_library() -> None: import pydust # noqa: E402 +from pydust import buildzig # noqa: E402 +from pydust import config as pydust_config # noqa: E402 from pydust.build import build # noqa: E402 +# Patch Windows path pydust bug in build.zig +if sys.platform == "win32": + + def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): + b = buildzig.Writer(fileobj) + + b.writeln('const std = @import("std");') + b.writeln('const py = @import("./pydust.build.zig");') + b.writeln() + + with b.block("pub fn build(b: *std.Build) void"): + b.write( + """ + const target = b.standardTargetOptionsQueryOnly(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const test_step = b.step("test", "Run library tests"); + + const pydust = py.addPydust(b, .{ + .test_step = test_step, + }); + """ + ) + + for ext_module in conf.ext_modules: + assert ext_module.limited_api, "Only limited_api is supported for now" + ext_module_root = str(ext_module.root).replace("\\", "/") # fix for windows + b.write( + f""" + _ = pydust.addPythonModule(.{{ + .name = "{ext_module.name}", + .root_source_file = b.path("{ext_module_root}"), + .limited_api = {str(ext_module.limited_api).lower()}, + .target = target, + .optimize = optimize, + }}); + """ + ) + + buildzig.generate_build_zig = _generate_build_zig + @contextlib.contextmanager def ensure_ffi_location() -> typing.Iterator[None]: From b931390644cc7a7d873975f149283dbfdb453d9a Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 18:32:08 -0800 Subject: [PATCH 05/13] cibuildwheel installs build dependencies in C drive while GitHub Actions checks out the repo in D --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0271e68..591ddb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,7 @@ jobs: CIBW_BUILD_VERBOSITY: 0 CIBW_TEST_COMMAND: "pip install pytest && pytest {project}/tests" CIBW_SKIP: "cp3??t-*" + CIBW_BUILD: ${{ runner.os == 'Windows' && 'D:\\cibuildwheel_build' || '' }} - name: Upload artifacts uses: actions/upload-artifact@v4 From 1f57f142c6625d1451641ed9d857f69f6b2d7242 Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 18:36:28 -0800 Subject: [PATCH 06/13] cibuildwheel installs build dependencies in C drive while GitHub Actions checks out the repo in D --- .github/workflows/ci.yml | 1 - build.py | 90 ++++++++++++++++++++++------------------ 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 591ddb9..0271e68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,6 @@ jobs: CIBW_BUILD_VERBOSITY: 0 CIBW_TEST_COMMAND: "pip install pytest && pytest {project}/tests" CIBW_SKIP: "cp3??t-*" - CIBW_BUILD: ${{ runner.os == 'Windows' && 'D:\\cibuildwheel_build' || '' }} - name: Upload artifacts uses: actions/upload-artifact@v4 diff --git a/build.py b/build.py index 2375cdc..e10cc52 100644 --- a/build.py +++ b/build.py @@ -1,4 +1,6 @@ import contextlib +import ntpath +import os import shutil import sys import sysconfig @@ -22,50 +24,58 @@ def _ensure_ld_library() -> None: import pydust # noqa: E402 -from pydust import buildzig # noqa: E402 -from pydust import config as pydust_config # noqa: E402 from pydust.build import build # noqa: E402 # Patch Windows path pydust bug in build.zig if sys.platform == "win32": - - def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): - b = buildzig.Writer(fileobj) - - b.writeln('const std = @import("std");') - b.writeln('const py = @import("./pydust.build.zig");') - b.writeln() - - with b.block("pub fn build(b: *std.Build) void"): - b.write( - """ - const target = b.standardTargetOptionsQueryOnly(.{}); - const optimize = b.standardOptimizeOption(.{}); - - const test_step = b.step("test", "Run library tests"); - - const pydust = py.addPydust(b, .{ - .test_step = test_step, - }); - """ - ) - - for ext_module in conf.ext_modules: - assert ext_module.limited_api, "Only limited_api is supported for now" - ext_module_root = str(ext_module.root).replace("\\", "/") # fix for windows - b.write( - f""" - _ = pydust.addPythonModule(.{{ - .name = "{ext_module.name}", - .root_source_file = b.path("{ext_module_root}"), - .limited_api = {str(ext_module.limited_api).lower()}, - .target = target, - .optimize = optimize, - }}); - """ - ) - - buildzig.generate_build_zig = _generate_build_zig + old_relpath = ntpath.relpath + + def safe_relpath(path, start=os.curdir): + try: + return old_relpath(path, start) + except ValueError: + # cross-drive fallback + return path.replace("\\", "/") + + ntpath.relpath = safe_relpath + + # def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): + # b = buildzig.Writer(fileobj) + # + # b.writeln('const std = @import("std");') + # b.writeln('const py = @import("./pydust.build.zig");') + # b.writeln() + # + # with b.block("pub fn build(b: *std.Build) void"): + # b.write( + # """ + # const target = b.standardTargetOptionsQueryOnly(.{}); + # const optimize = b.standardOptimizeOption(.{}); + # + # const test_step = b.step("test", "Run library tests"); + # + # const pydust = py.addPydust(b, .{ + # .test_step = test_step, + # }); + # """ + # ) + # + # for ext_module in conf.ext_modules: + # assert ext_module.limited_api, "Only limited_api is supported for now" + # ext_module_root = str(ext_module.root).replace("\\", "/") # fix for windows + # b.write( + # f""" + # _ = pydust.addPythonModule(.{{ + # .name = "{ext_module.name}", + # .root_source_file = b.path("{ext_module_root}"), + # .limited_api = {str(ext_module.limited_api).lower()}, + # .target = target, + # .optimize = optimize, + # }}); + # """ + # ) + # + # buildzig.generate_build_zig = _generate_build_zig @contextlib.contextmanager From 8099a28b5139c21d8e3a28abdac5b6d9423fad6d Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 18:40:35 -0800 Subject: [PATCH 07/13] cibuildwheel installs build dependencies in C drive while GitHub Actions checks out the repo in D --- build.py | 76 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/build.py b/build.py index e10cc52..2d6a4c7 100644 --- a/build.py +++ b/build.py @@ -24,6 +24,8 @@ def _ensure_ld_library() -> None: import pydust # noqa: E402 +from pydust import buildzig # noqa: E402 +from pydust import config as pydust_config # noqa: E402 from pydust.build import build # noqa: E402 # Patch Windows path pydust bug in build.zig @@ -39,43 +41,43 @@ def safe_relpath(path, start=os.curdir): ntpath.relpath = safe_relpath - # def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): - # b = buildzig.Writer(fileobj) - # - # b.writeln('const std = @import("std");') - # b.writeln('const py = @import("./pydust.build.zig");') - # b.writeln() - # - # with b.block("pub fn build(b: *std.Build) void"): - # b.write( - # """ - # const target = b.standardTargetOptionsQueryOnly(.{}); - # const optimize = b.standardOptimizeOption(.{}); - # - # const test_step = b.step("test", "Run library tests"); - # - # const pydust = py.addPydust(b, .{ - # .test_step = test_step, - # }); - # """ - # ) - # - # for ext_module in conf.ext_modules: - # assert ext_module.limited_api, "Only limited_api is supported for now" - # ext_module_root = str(ext_module.root).replace("\\", "/") # fix for windows - # b.write( - # f""" - # _ = pydust.addPythonModule(.{{ - # .name = "{ext_module.name}", - # .root_source_file = b.path("{ext_module_root}"), - # .limited_api = {str(ext_module.limited_api).lower()}, - # .target = target, - # .optimize = optimize, - # }}); - # """ - # ) - # - # buildzig.generate_build_zig = _generate_build_zig + def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): + b = buildzig.Writer(fileobj) + + b.writeln('const std = @import("std");') + b.writeln('const py = @import("./pydust.build.zig");') + b.writeln() + + with b.block("pub fn build(b: *std.Build) void"): + b.write( + """ + const target = b.standardTargetOptionsQueryOnly(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const test_step = b.step("test", "Run library tests"); + + const pydust = py.addPydust(b, .{ + .test_step = test_step, + }); + """ + ) + + for ext_module in conf.ext_modules: + assert ext_module.limited_api, "Only limited_api is supported for now" + ext_module_root = str(ext_module.root).replace("\\", "/") # fix for windows + b.write( + f""" + _ = pydust.addPythonModule(.{{ + .name = "{ext_module.name}", + .root_source_file = b.path("{ext_module_root}"), + .limited_api = {str(ext_module.limited_api).lower()}, + .target = target, + .optimize = optimize, + }}); + """ + ) + + buildzig.generate_build_zig = _generate_build_zig @contextlib.contextmanager From 29af27aaa945bb8261290d3c5231fbd9d2b61e11 Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 18:52:41 -0800 Subject: [PATCH 08/13] trying to set the default working-directory to the C: drive for windows-latest --- .github/workflows/ci.yml | 4 ++++ build.py | 12 ------------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0271e68..30483b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,9 @@ jobs: name: Build wheels on ${{ matrix.os }} needs: [lint] runs-on: ${{ matrix.os }} + defaults: + run: + working-directory: ${{ runner.os == 'Windows' && 'C:/secretsweeper' || '' }} strategy: fail-fast: false matrix: @@ -55,6 +58,7 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 + path: ${{ runner.os == 'Windows' && 'C:/secretsweeper' || '' }} - name: Build wheels uses: pypa/cibuildwheel@v3.3.1 diff --git a/build.py b/build.py index 2d6a4c7..2375cdc 100644 --- a/build.py +++ b/build.py @@ -1,6 +1,4 @@ import contextlib -import ntpath -import os import shutil import sys import sysconfig @@ -30,16 +28,6 @@ def _ensure_ld_library() -> None: # Patch Windows path pydust bug in build.zig if sys.platform == "win32": - old_relpath = ntpath.relpath - - def safe_relpath(path, start=os.curdir): - try: - return old_relpath(path, start) - except ValueError: - # cross-drive fallback - return path.replace("\\", "/") - - ntpath.relpath = safe_relpath def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): b = buildzig.Writer(fileobj) From 49b7374075fcb1c6eaa9794bb376fdff017f838f Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 18:54:52 -0800 Subject: [PATCH 09/13] trying to set the default working-directory to the C: drive for windows-latest --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30483b9..d33dce4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: runs-on: ${{ matrix.os }} defaults: run: - working-directory: ${{ runner.os == 'Windows' && 'C:/secretsweeper' || '' }} + working-directory: ${{ matrix.os == 'windows-latest' && 'C:/secretsweeper' || '' }} strategy: fail-fast: false matrix: From f274062558f79975fd6042d69e8fe34075eb769d Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 18:57:13 -0800 Subject: [PATCH 10/13] trying to set the default working-directory to the C: drive for windows-latest --- .github/workflows/ci.yml | 4 ---- build.py | 8 ++++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d33dce4..0271e68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,9 +40,6 @@ jobs: name: Build wheels on ${{ matrix.os }} needs: [lint] runs-on: ${{ matrix.os }} - defaults: - run: - working-directory: ${{ matrix.os == 'windows-latest' && 'C:/secretsweeper' || '' }} strategy: fail-fast: false matrix: @@ -58,7 +55,6 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 - path: ${{ runner.os == 'Windows' && 'C:/secretsweeper' || '' }} - name: Build wheels uses: pypa/cibuildwheel@v3.3.1 diff --git a/build.py b/build.py index 2375cdc..bc3612b 100644 --- a/build.py +++ b/build.py @@ -1,4 +1,5 @@ import contextlib +import os import shutil import sys import sysconfig @@ -28,6 +29,13 @@ def _ensure_ld_library() -> None: # Patch Windows path pydust bug in build.zig if sys.platform == "win32": + # patch b.path(...) to return absolute paths instead of relpath + original_b_path = pydust.buildzig.b.path + + def absolute_b_path(path): + return os.path.abspath(path).replace("\\", "/") # Zig likes forward slashes + + pydust.buildzig.b.path = absolute_b_path def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): b = buildzig.Writer(fileobj) From b14f3286b4ded5266560e2686b5934343b80a38e Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 19:01:50 -0800 Subject: [PATCH 11/13] trying to set the default working-directory to the C: drive for windows-latest --- build.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index bc3612b..a72b346 100644 --- a/build.py +++ b/build.py @@ -29,13 +29,15 @@ def _ensure_ld_library() -> None: # Patch Windows path pydust bug in build.zig if sys.platform == "win32": - # patch b.path(...) to return absolute paths instead of relpath - original_b_path = pydust.buildzig.b.path + # Save the original function + original_addPythonModule = pydust.buildzig.addPythonModule - def absolute_b_path(path): - return os.path.abspath(path).replace("\\", "/") # Zig likes forward slashes + def _addPythonModule(mod): + # Force absolute path for root_source_file + mod["root_source_file"] = os.path.abspath(mod["root_source_file"]).replace("\\", "/") + return original_addPythonModule(mod) - pydust.buildzig.b.path = absolute_b_path + pydust.buildzig.addPythonModule = _addPythonModule def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): b = buildzig.Writer(fileobj) From dc3935e00fe20c5dc28c2a88c1bf24f2452317e2 Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 19:05:28 -0800 Subject: [PATCH 12/13] revert --- build.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/build.py b/build.py index a72b346..57298b5 100644 --- a/build.py +++ b/build.py @@ -1,5 +1,4 @@ import contextlib -import os import shutil import sys import sysconfig @@ -29,16 +28,6 @@ def _ensure_ld_library() -> None: # Patch Windows path pydust bug in build.zig if sys.platform == "win32": - # Save the original function - original_addPythonModule = pydust.buildzig.addPythonModule - - def _addPythonModule(mod): - # Force absolute path for root_source_file - mod["root_source_file"] = os.path.abspath(mod["root_source_file"]).replace("\\", "/") - return original_addPythonModule(mod) - - pydust.buildzig.addPythonModule = _addPythonModule - def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): b = buildzig.Writer(fileobj) From d058ba2a094399814fd49fa0d778ed9f9e82bef3 Mon Sep 17 00:00:00 2001 From: Vitaliy Demidov Date: Sun, 1 Feb 2026 19:11:49 -0800 Subject: [PATCH 13/13] revert --- build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/build.py b/build.py index 57298b5..2375cdc 100644 --- a/build.py +++ b/build.py @@ -28,6 +28,7 @@ def _ensure_ld_library() -> None: # Patch Windows path pydust bug in build.zig if sys.platform == "win32": + def _generate_build_zig(fileobj: typing.TextIO, conf=pydust_config): b = buildzig.Writer(fileobj)