Skip to content
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

Use importlib_metadata for <3.10 compatibility #1469

Merged
merged 2 commits into from Jul 3, 2023
Merged

Conversation

Ariana-B
Copy link
Contributor

@Ariana-B Ariana-B commented Jun 30, 2023

Reason for this pull request

#1468

Proposed changes


📚 Documentation preview 📚: https://datacube-core--1469.org.readthedocs.build/en/1469/

@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Patch coverage: 50.00% and project coverage change: -0.02 ⚠️

Comparison is base (5fed4a6) 91.77% compared to head (cef49eb) 91.76%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1469      +/-   ##
===========================================
- Coverage    91.77%   91.76%   -0.02%     
===========================================
  Files          132      132              
  Lines        14537    14540       +3     
===========================================
+ Hits         13341    13342       +1     
- Misses        1196     1198       +2     
Impacted Files Coverage Δ
datacube/drivers/driver_cache.py 93.10% <50.00%> (-6.90%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@omad
Copy link
Member

omad commented Jun 30, 2023

I've tested this on Python 3.9 and it doesn't work, that select() functional also doesn't exist yet.

image

The Compatibility Note on https://docs.python.org/3/library/importlib.metadata.html is not clearly written.

The behaviour in Python < 3.10 is to return a dictionary keyed on group, so we could use:

>>> entry_points()['datacube.plugins.index']
(EntryPoint(name='default', value='datacube.index.postgres.index:index_driver_init', group='datacube.plugins.index'), EntryPoint(name='memory', value='datacube.index.memory.index:index_driver_init', group='datacube.plugins.index'), EntryPoint(name='null', value='datacube.index.null.index:index_driver_init', group='datacube.plugins.index'), EntryPoint(name='postgis', value='datacube.index.postgis.index:index_driver_init', group='datacube.plugins.index'))

But the Compatibility Note warns that will break in the future.

I think the simplest/best option is to add an optional dependency importlib_metadata>=3.6; python_version<3.10. See Dependencies Management in Setuptools.

@omad
Copy link
Member

omad commented Jun 30, 2023

That should both be reliable in the future, and doesn't rely on adding extra code for handling different return types in different python versions/importlib.metadata versions.

@Ariana-B Ariana-B requested a review from emmaai July 3, 2023 02:08
Copy link
Contributor

@emmaai emmaai left a comment

Choose a reason for hiding this comment

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

Thanks!

@emmaai emmaai merged commit 353bb99 into develop Jul 3, 2023
25 checks passed
@emmaai emmaai deleted the fix_entry_points branch July 3, 2023 05:16
@Ariana-B Ariana-B changed the title Use entry_points selection interface for <3.10 compatibility Use importlib_metadata for <3.10 compatibility Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

python 3.8/3.9 doesn't support entry_points with either group or select
3 participants