-
Notifications
You must be signed in to change notification settings - Fork 156
Migrate package resource/metadata access to stdlib importlib APIs
#359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,10 @@ | ||
| def test(): | ||
| import pytest | ||
|
|
||
| pytest.main() | ||
| from importlib.metadata import version | ||
|
|
||
|
|
||
| __version__ = version("OpenPIV") | ||
|
|
||
|
|
||
| def test(): | ||
| import pytest | ||
|
|
||
| pytest.main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from importlib.metadata import version | ||
|
|
||
| import openpiv | ||
|
|
||
|
|
||
| def test_package_version_matches_metadata(): | ||
| assert openpiv.__version__ == version("OpenPIV") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| from importlib_resources import files | ||
| from importlib.resources import files | ||
| from openpiv import windef | ||
|
|
||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,6 @@ requirements: | |
| - scipy | ||
| - natsort | ||
| - tqdm | ||
| - importlib_resources | ||
| - arm_pyart | ||
|
Comment on lines
27
to
30
|
||
|
|
||
| test: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,8 +25,7 @@ | |||||||
| 'scikit-image>=0.23.0', | ||||||||
| 'scipy>=1.11.0', | ||||||||
| 'natsort>=8.4.0', | ||||||||
| 'tqdm>=4.66.0', | ||||||||
| 'importlib_resources>=5.12.0' | ||||||||
| 'tqdm>=4.66.0' | ||||||||
| ], | ||||||||
|
||||||||
| ], | |
| ], | |
| python_requires=">=3.10", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__version__ = version("OpenPIV")runs at import time and will raiseimportlib.metadata.PackageNotFoundErrorwhen OpenPIV is imported from a source checkout (or other contexts where distribution metadata isn’t installed). That would breakimport openpivas well as tutorials/tests that importopenpivindirectly. Consider wrapping the metadata lookup in a try/except and providing a reasonable fallback (e.g., a hardcoded dev version or reading from a local version constant) so the package remains importable without installed metadata.