Fix Windows build: write py.typed at install time instead of copying it - #1049
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a regression introduced in #1048 that currently breaks both Windows CI jobs on
main.python/basix/py.typedis not a tracked source file — it's listed in.gitignoreand only ever exists as a build artifact generated by nanobind's stub tooling (on Unix,nanobind_add_stub's non-INSTALL_TIMEmode writes it into the source tree as part of the normal build step, before the separateinstall(FILES ...)copies it into the wheel).#1048's Windows fix assumed it was a static committed file like on Unix, and added:
On a fresh checkout that source path doesn't exist, so
file(INSTALL)hard-fails duringcmake --install, breaking the wheel build entirely on both Windows jobs (confirmed via run 30586685876):Fix
Replace the broken
install(FILES ...)with an unconditionalwhich 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'sINSTALL_TIMEimport ofbasix._basixcppsucceeding (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
install(CODE ...)construct creates the file correctly, both when the destination directory pre-exists and when it doesn't (auto-created).gersemi --diffclean.🤖 Generated with Claude Code