Repository navigation
JIT build: pass PETSc's include directories to the generated setup.py - #829
Merged
Merged
Conversation
#813 made the generated callback header include <petscsystypes.h>, so callbacks use PETSc's configured integer width. The generated setup.py passes no PETSc include directory, so the build works only where PETSc's headers are on the compiler's default path: a conda-forge PETSc in the environment, as in CI. With a custom PETSc build every JIT compile failed with "'petscsystypes.h' file not found". _petsc_include_dirs() reads PETSC_DIR/PETSC_ARCH from petsc4py and adds $PETSC_DIR/include and $PETSC_DIR/$PETSC_ARCH/include (petscconf.h). test_0021 checks that the headers are found and that a JIT solve compiles. Underworld development team with AI support from Claude Code
…etup.py petsc4py is a hard dependency and conda's petsc4py has get_config(), so the try/except around it guarded a state that cannot occur (Charter §5), and PETSC_DIR is always in the configuration. PETSC_ARCH stays optional: it is empty for a prefix install. The test checked the helper's return value and a solve that compiles wherever the headers sit on the compiler's default path, as they do in CI's conda-forge PETSc, so it could not fail on CI. It now captures the setup.py the JIT generates and asserts that it carries PETSc's include directories, read independently from petsc4py. Underworld development team with AI support from Claude Code
Member
Author
Adversarial reviewThis branch was reviewed together with #830, which is stacked on it. Two findings, both fixed in 5cb3072:
Checked and sound:
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Solver/JIT tests are incorrectly included in the level-1 selection reserved for checks without solving.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes custom-PETSc JIT compilation failures introduced by #813 by supplying PETSc’s configured header directories.
Changes:
- Adds existing PETSc include directories to generated
setup.py, also incorporating them into the cache key. - Adds regression checks for header availability, generated include paths, and solver convergence.
| File | Description |
|---|---|
tests/test_0021_jit_finds_petsc_headers.py |
Tests PETSc header discovery and JIT compilation. |
src/underworld3/utilities/_jitextension.py |
Adds PETSc include directories from petsc4py configuration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| import underworld3 as uw | ||
|
|
||
| pytestmark = [pytest.mark.level_1, pytest.mark.tier_a] |
lmoresi
added a commit
to gthyagi/underworld3
that referenced
this pull request
Oct 12, 2026
…o picard-warmup-791 Conflicts: up_G2/up_G3 keep underworldcode#794's F1_for_up (newton_pressure_coupling) and differentiate it with tier 1's diff_wrt_field; the reviews index keeps both rows. The linearity check's top-level derivative also goes through diff_wrt_field (the solver census in test_0023). Underworld development team with AI support from Claude Code
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.

Fixes #828.
Since #813, the generated JIT header includes
<petscsystypes.h>, but the generatedsetup.pypassed no PETSc include directory. That works only where PETSc's headers are on the compiler's default path (a conda-forge PETSc, as in CI). With a custom PETSc build, every JIT compile failed with'petscsystypes.h' file not found, so no solver ran.Change
_petsc_include_dirs()readsPETSC_DIR/PETSC_ARCHfrompetsc4py.get_config()and returns$PETSC_DIR/includeand$PETSC_DIR/$PETSC_ARCH/include(forpetscconf.h), keeping only the directories that exist. A prefix install has no arch directory. The generatedsetup.pyappends these to its include dirs. Becausesetup.pyis hashed into the JIT cache key, the key now also follows the PETSc installation, which #813's integer-width change needs.Tests
tests/test_0021_jit_finds_petsc_headers.pycaptures thesetup.pythat a Poisson solve generates. It asserts that the file carries PETSc's include directories, read independently from petsc4py, so it fails ondevelopmenteverywhere, including CI. It also checks that those directories hold the headers the callbacks include, and that a JIT solve compiles and converges.The adversarial review, run with the #823 branch stacked on this one, found two defects here. Both are fixed on this branch:
try/exceptguarded the hard dependency petsc4py (Charter §5).Underworld development team with AI support from Claude Code