Skip to content

Comments

Use editable pip install to fix testing of cython packages#173

Merged
joewallwork merged 1 commit intomainfrom
fix-cython-build
Feb 23, 2026
Merged

Use editable pip install to fix testing of cython packages#173
joewallwork merged 1 commit intomainfrom
fix-cython-build

Conversation

@stephankramer
Copy link
Collaborator

In #172 the --no-build-isolation was added, needed to access to petsc etc. packages during build of cython modules, but the -e flag was dropped. It appears that the latter breaks importing a python module with a cython submodule, from the source directory of that python module itself.

E.g. if you are in the animate/ source directory, "import animate" in python, it will try to import it from the local directory, but if that module was built without the -e flag, the
numbering.cpython-312-x86_64-linux-gnu.so is not available in animate/numbering/ but only in the installed directory (/usr/local/lib/...) and therefore the import will fail on "from .cython.numbering import to_petsc_local_numbering" Therefore you can no longer run pytest within the animate/ directory.

With the -e flag, the dynamic .so is placed in animate/numbering/ and it is able to "import animate" from within the local directory, as well as from anywhere else.

In #172 the --no-build-isolation was added, needed to access to petsc
etc. packages during build of cython modules, but the -e flag was
dropped. It appears that this breaks importing a python module with a cython submodule, from the source directory of that python module itself.

E.g. if you are in the animate/ source directory, "import animate" in
python, it will try to import it from the local directory, but if that
module was built without the -e flag, the
numbering.cpython-312-x86_64-linux-gnu.so is not available in
animate/numbering/ but only in the installed directory
(/usr/local/lib/...) and therefore the import will fail on "from
.cython.numbering import to_petsc_local_numbering"
Therefore you can no longer run pytest within the animate/ directory.

With the -e flag, the dynamic .so is placed in animate/numbering/ and it
is able to "import animate" from within the local directory, as well as
from anywhere else.
Copy link
Member

@joewallwork joewallwork left a comment

Choose a reason for hiding this comment

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

Ah okay, I'd misunderstood this! Thanks for this fix.

@joewallwork joewallwork merged commit 10dc90b into main Feb 23, 2026
2 checks passed
@joewallwork joewallwork deleted the fix-cython-build branch February 23, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants