Skip to content

Commit

Permalink
Use the built-in importlib.metadata library in Python 3.8+ (#36225)
Browse files Browse the repository at this point in the history
importlib_metadata is a backport of this library for Python 3.7 and
older.
  • Loading branch information
jefferyto committed Jun 17, 2020
1 parent b464096 commit a74e357
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Expand Up @@ -13,7 +13,7 @@ defusedxml==0.6.0
distro==1.5.0
hass-nabucasa==0.34.6
home-assistant-frontend==20200613.0
importlib-metadata==1.6.0
importlib-metadata==1.6.0;python_version<'3.8'
jinja2>=2.11.1
netdisco==2.7.0
pip>=8.0.3
Expand Down
12 changes: 11 additions & 1 deletion homeassistant/util/package.py
Expand Up @@ -8,9 +8,19 @@
from typing import Optional
from urllib.parse import urlparse

from importlib_metadata import PackageNotFoundError, version
import pkg_resources

if sys.version_info[:2] >= (3, 8):
from importlib.metadata import ( # pylint: disable=no-name-in-module,import-error
PackageNotFoundError,
version,
)
else:
from importlib_metadata import ( # pylint: disable=import-error
PackageNotFoundError,
version,
)

_LOGGER = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -6,7 +6,7 @@ attrs==19.3.0
bcrypt==3.1.7
certifi>=2020.4.5.1
ciso8601==2.1.3
importlib-metadata==1.6.0
importlib-metadata==1.6.0;python_version<'3.8'
jinja2>=2.11.1
PyJWT==1.7.1
cryptography==2.9.2
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -39,7 +39,7 @@
"bcrypt==3.1.7",
"certifi>=2020.4.5.1",
"ciso8601==2.1.3",
"importlib-metadata==1.6.0",
"importlib-metadata==1.6.0;python_version<'3.8'",
"jinja2>=2.11.1",
"PyJWT==1.7.1",
# PyJWT has loose dependency. We want the latest one.
Expand Down

0 comments on commit a74e357

Please sign in to comment.