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

No importlib metadata #1178

Merged
merged 6 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### 38.0.1 [#1178](https://github.com/openfisca/openfisca-core/pull/1178)

#### Technical changes

- Remove use of `importlib_metadata`.

# 38.0.0 [#989](https://github.com/openfisca/openfisca-core/pull/989)

#### New Features
Expand Down
18 changes: 11 additions & 7 deletions openfisca_core/taxbenefitsystems/tax_benefit_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import functools
import glob
import importlib
import importlib_metadata
import inspect
import logging
import os
import pkg_resources
import sys
import traceback
import typing
Expand Down Expand Up @@ -457,9 +457,8 @@ def get_package_metadata(self) -> Dict[str, str]:
package_name = module.__package__.split('.')[0]

try:
distribution = importlib_metadata.distribution(package_name)

except importlib_metadata.PackageNotFoundError:
distribution = pkg_resources.get_distribution(package_name)
except pkg_resources.DistributionNotFound:
return fallback_metadata

source_file = inspect.getsourcefile(module)
Expand All @@ -470,12 +469,17 @@ def get_package_metadata(self) -> Dict[str, str]:
else:
location = ""

metadata = distribution.metadata
home_page_metadatas = [
metadata.split(':', 1)[1].strip(' ')
for metadata in distribution._get_metadata(distribution.PKG_INFO) # type: ignore
if 'Home-page' in metadata
]
repository_url = home_page_metadatas[0] if home_page_metadatas else ''

return {
'name': metadata["Name"].lower(),
'name': distribution.key,
'version': distribution.version,
'repository_url': metadata["Home-page"],
'repository_url': repository_url,
'location': location,
}

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

setup(
name = 'OpenFisca-Core',
version = '38.0.0',
version = '38.0.1',
author = 'OpenFisca Team',
author_email = '[email protected]',
classifiers = [
Expand Down