-
Notifications
You must be signed in to change notification settings - Fork 98
Fix default entrypoint handling on older Pythons #475
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
54554c4
Replace default list with dict
vyasr a815ba1
Merge branch 'main' into fix/update_default
jakirkham 1133201
Merge branch 'main' into fix/update_default
jakirkham 2ae66c8
Merge branch 'main' into fix/update_default
jakirkham cc88a87
Add 0.12.1 release note w/entrypoint bug fix
jakirkham a43ff04
Tag to issue rather than PR
vyasr e227e5d
Proper fix
vyasr a21a20a
Update release notes
vyasr fb8653b
Add a test
vyasr 9d5cbd9
Add noqa
vyasr b52d1c0
Change test to fork
vyasr 830bae9
Merge branch 'main' into fix/update_default
jakirkham 5dcc334
Remove unused import
vyasr f9a842f
Merge branch 'main' into fix/update_default
jakirkham 0dd00ed
Merge branch 'main' into fix/update_default
jakirkham 30cc25f
Merge 0.12.1 release notes
jakirkham d8d497a
Merge branch 'main' into fix/update_default
jakirkham 2ce2444
Move importlib_metadata to a separate extra
vyasr d243624
Move test to its own module
vyasr a5951d4
Clean up old test
vyasr aeef761
Apply suggestions from code review
vyasr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os.path | ||
import pkgutil | ||
import sys | ||
|
||
import pytest | ||
|
||
from multiprocessing import Process | ||
|
||
import numcodecs.registry | ||
|
||
if not pkgutil.find_loader("importlib_metadata"): # pragma: no cover | ||
pytest.skip("This test module requires importlib_metadata to be installed") | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
def get_entrypoints_with_importlib_metadata_loaded(): | ||
# importlib_metadata patches importlib.metadata, which can lead to breaking changes | ||
# to the APIs of EntryPoint objects used when registering entrypoints. Attempt to | ||
# isolate those changes to just this test. | ||
import importlib_metadata # noqa: F401 | ||
sys.path.append(here) | ||
numcodecs.registry.run_entrypoints() | ||
cls = numcodecs.registry.get_codec({"id": "test"}) | ||
assert cls.codec_id == "test" | ||
|
||
|
||
def test_entrypoint_codec_with_importlib_metadata(): | ||
p = Process(target=get_entrypoints_with_importlib_metadata_loaded) | ||
p.start() | ||
p.join() | ||
assert p.exitcode == 0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,9 @@ test = [ | |
"pytest", | ||
"pytest-cov", | ||
] | ||
test_extras = [ | ||
"importlib_metadata", | ||
] | ||
msgpack = [ | ||
"msgpack", | ||
] | ||
|
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.
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.
Would it make sense to reuse
set_path
here somehow? Should cleanupsys.path
and thenumcodecs.registry
after?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.
I thought about reusing, but I think it'd be more work than it's worth. We can't use a fixture directly because it's not supposed to affect the actual test function, we need it to affect the helper function that's run in the subprocess and that function isn't a test so pytest won't patch in fixtures. We could try and split it into a helper function like I had initially, but it's not really necessary. Since the function is running in a subprocess we don't need to clean things up, it shouldn't affect the modules in the parent process.