Skip to content

Build: every extension depends on every package header - #1196

Merged
lmoresi merged 1 commit into
developmentfrom
bugfix/setup-header-depends
Nov 15, 2026
Merged

lmoresi merged 1 commit into
developmentfrom
bugfix/setup-header-depends

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 15, 2026

Copy link
Copy Markdown
Member

What this fixes

./uw build keeps its build/ directory between builds, and setuptools recompiles an extension only when one of its sources or declared dependencies is newer than the built object. Cython declares the headers a .pyx names in cdef extern from, but not the headers those headers include. An edit to such a header therefore installed the old extension.

Two headers are reached that way:

setup.py now passes depends= to every extension, listing every .h and .hpp under src/underworld3. That is all of them rather than each extension's own, because it is simpler and cannot miss a new include. The cost is that a header edit recompiles every extension: about a minute and a half on the macOS machine.

Shown

All runs are ./uw build in one worktree, on macOS with a 12-core Apple M4. We read the object timestamps in build/temp.*.

step ckdtree.o petsc_generic_snes_solvers.o
development: touch petsc_compat.h (named in the .pyx), build recompiled
development: touch nanoflann.hpp (nested), build not recompiled not recompiled
this branch: build with no change not recompiled not recompiled
this branch: touch nanoflann.hpp, build recompiled recompiled

The dependency is by timestamp, so a touch and an edit behave the same. After the rebuild, test_0502 and test_1001 pass (29 tests).

No tests, tolerances or coordinate matches are involved. There is no issue: this is a build fix found in review.

Underworld development team with AI support from Claude Code

./uw build keeps its build directory, and setuptools recompiles an
extension only when a source or a listed dependency is newer than it.
Cython lists the headers a .pyx names, but not the headers those include,
so an edit to uw_face_orientation.h (included by petsc_compat.h) or
nanoflann.hpp (by kdtree_interface.hpp) left the old extension in place.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 15, 2026 11:02
@lmoresi

lmoresi commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

Review record, pre-PR.

  • Paths are relative to the working directory. The globs are relative to where setup.py runs. pip builds a local directory in place, from the project root, so they resolve. From anywhere else the list would be empty and the build would behave as it did before this change; it would not fail.
  • Cython keeps the dependencies. cythonize carries the template extension's depends onto the extensions it generates. The rebuild in the table shows that.
  • No spurious rebuilds. A build with no change recompiles nothing.
  • Cost. Every extension recompiles on any header edit. That is accepted as the simpler of the two options; listing each extension's own headers would need updating whenever an include changes.
  • Parallel, units, tests, CI reach. Not affected.
  • Issue state. No issue is open on this.

No findings.

Underworld development team with AI support from Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@lmoresi

lmoresi commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

#1196 at 60412d1: PASS on both checks. From H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)), with three successive builds of one worktree (pixi run -e dev build, the build ./uw runs).

  • A nested-header touch recompiles ckdtree. After touching src/underworld3/nanoflann.hpp, which reaches ckdtree.pyx only through kdtree_interface.hpp, the rebuild recompiled ckdtree. It also recompiled the other 11 extensions, all 12 of the package, because every extension now depends on every header. That is coarser than needed, but correct.
  • A rebuild with no change recompiles nothing: 0 of 12 extensions had a newer .so afterwards.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit c17d53e into development Nov 15, 2026
10 checks passed
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.

2 participants