Skip to content

Fix Windows build: write py.typed at install time instead of copying it - #1049

Merged
garth-wells merged 1 commit into
mainfrom
garth/fix-windows-py-typed
Jul 31, 2026
Merged

Fix Windows build: write py.typed at install time instead of copying it#1049
garth-wells merged 1 commit into
mainfrom
garth/fix-windows-py-typed

Conversation

@garth-wells

Copy link
Copy Markdown
Member

Summary

Fixes a regression introduced in #1048 that currently breaks both Windows CI jobs on main.

python/basix/py.typed is not a tracked source file — it's listed in .gitignore and only ever exists as a build artifact generated by nanobind's stub tooling (on Unix, nanobind_add_stub's non-INSTALL_TIME mode writes it into the source tree as part of the normal build step, before the separate install(FILES ...) copies it into the wheel).

#1048's Windows fix assumed it was a static committed file like on Unix, and added:

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/basix/py.typed DESTINATION basix)

On a fresh checkout that source path doesn't exist, so file(INSTALL) hard-fails during cmake --install, breaking the wheel build entirely on both Windows jobs (confirmed via run 30586685876):

CMake Error at .../cmake_install.cmake:48 (file):
  file INSTALL cannot find "D:/a/basix/basix/python/basix/py.typed": File
  exists.

Fix

Replace the broken install(FILES ...) with an unconditional

install(CODE "file(WRITE \"${CMAKE_INSTALL_PREFIX}/basix/py.typed\" \"\")")

which writes the (empty, per PEP 561) marker directly at the install destination — no dependency on any pre-existing source file, and no dependency on nanobind_add_stub's INSTALL_TIME import of basix._basixcpp succeeding (that import is what can fail on the Windows split build per the existing code comment, which is the actual root cause of the original, silently-tolerated "missing py.typed marker" mypy note this was trying to fix).

Test plan

  • Verified standalone with a minimal CMake project that this exact install(CODE ...) construct creates the file correctly, both when the destination directory pre-exists and when it doesn't (auto-created).
  • gersemi --diff clean.
  • Windows CI (this PR) — both jobs should build successfully again.

🤖 Generated with Claude Code

python/basix/py.typed is not a tracked source file - it's gitignored
and only ever created as a build artifact by nanobind's stub tooling.
The previous fix (merged in #1048) added
install(FILES \${CMAKE_CURRENT_SOURCE_DIR}/basix/py.typed DESTINATION
basix) to the Windows branch, assuming it was a static committed file
like on Unix. On a fresh checkout that source path doesn't exist, so
file(INSTALL) hard-fails during `cmake --install`, breaking both
Windows CI jobs (confirmed via run 30586685876: "CMake Error ...
file INSTALL cannot find ... py.typed: File exists.").

Replace it with an unconditional install(CODE "file(WRITE ...)")
that writes the (empty, per PEP 561) marker directly at the install
destination. This has no dependency on any pre-existing source file
or on nanobind_add_stub's INSTALL_TIME import of basix._basixcpp
succeeding (which is the import that can fail on Windows per the
comment above). Verified standalone that this exact construct creates
the file correctly, including when the destination directory doesn't
already exist.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@garth-wells
garth-wells enabled auto-merge July 31, 2026 05:48
@garth-wells
garth-wells added this pull request to the merge queue Jul 31, 2026
Merged via the queue into main with commit ce3db44 Jul 31, 2026
30 checks passed
@garth-wells
garth-wells deleted the garth/fix-windows-py-typed branch July 31, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant