Skip to content

Commit

Permalink
Remove use of importlib_metadata (#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
eraviart authored Dec 19, 2022
2 parents 441adac + 2eac703 commit f7529a2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
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.2 [#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.2',
author = 'OpenFisca Team',
author_email = '[email protected]',
classifiers = [
Expand Down

0 comments on commit f7529a2

Please sign in to comment.