do not import petsc4py.PETSc until we really need it.#256
Merged
JHopeCollins merged 3 commits intomasterfrom Apr 21, 2026
Merged
do not import petsc4py.PETSc until we really need it.#256JHopeCollins merged 3 commits intomasterfrom
petsc4py.PETSc until we really need it.#256JHopeCollins merged 3 commits intomasterfrom
Conversation
Contributor
Author
|
@jrmaddison this doesn't change anything with the top level |
connorjward
reviewed
Apr 16, 2026
Contributor
|
Seems fine to move |
Contributor
Author
This is true, I forgot I had this old PR I didn't get around to finishing: firedrakeproject/petsctools#12 |
connorjward
approved these changes
Apr 21, 2026
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.
When pyadjoint is imported we were checking if
petsc4py.PETScwas available in theTAOSolverfile whether or not the user ever actually used theTAOSolver.The problem is that
import petsc4py.PETScwill runpetsc4py.initif it hasn't already been run, but it won't passsys.argv.This means that any PETSc options from the command line will silently be ignored. They won't even be shown by
-options_leftbecause PETSc never knew they even existed.This PR delays importing
petsc4py.PETScandpetsctoolsuntil they are actually needed so that the user has the chance to callpetsc4py.initas they see fit.