Skip to content

Make apigen.py work with editable hooks#7647

Merged
stefanv merged 1 commit intoscikit-image:mainfrom
lagru:fix-apigen-editable-install
Jan 8, 2025
Merged

Make apigen.py work with editable hooks#7647
stefanv merged 1 commit intoscikit-image:mainfrom
lagru:fix-apigen-editable-install

Conversation

@lagru
Copy link
Member

@lagru lagru commented Jan 4, 2025

Description

apigen.py in the previous form wasn't able to deal with skimage if it was installed in editable mode using a _scikit-image_editable_loader hook. In that case root_module.__path__[-1] would point to an invalid directory.

This fix aims to (a) account for this by falling back to the file attribute and (b) adds some defensive checks so we are not suprised in the future when something breaks.

Longterm this part of our tooling could probably use some love, it seems a bit brittle.

Checklist

Release note

For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.

...

apigen.py in the previous form wasn't able to deal with skimage if it
was installed in editable mode using a _scikit-image_editable_loader
hook. In that case `root_module.__path__[-1]` would point to an invalid
directory.

This fix aims to (a) account for this by falling back to the __file__
attribute and (b) adds some defensive checks so we are not suprised in
the future when something breaks.

Longterm this part of our tooling could probably use some love, it seems
a bit brittle.
@lagru
Copy link
Member Author

lagru commented Jan 5, 2025

@stefanv
Copy link
Member

stefanv commented Jan 8, 2025

I recall that importlib.metadata was recommended somewhere; could that work for both scenarios?

EDIT: Played around with it, and I don't immediately know how to apply it, so will merge this to get things working.

@stefanv stefanv merged commit 42f334a into scikit-image:main Jan 8, 2025
23 checks passed
@stefanv stefanv added this to the 0.25.1 milestone Jan 8, 2025
@lagru lagru deleted the fix-apigen-editable-install branch January 9, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 type: Infrastructure CI, packaging, tools and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants