From 9c31a60a37ef53cb7339a84bb5f647e19f15c9e8 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 30 Jun 2020 22:08:59 +0000 Subject: [PATCH] Don't use pkg_resources. This package is deprecated and introduces a massive amount of startup latency. On my machine with 264 installed Python packages, it reduces the time required to `import nmigen` from ~100ms to ~200ms. --- nmigen/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nmigen/__init__.py b/nmigen/__init__.py index 5646c6d..78a8dec 100644 --- a/nmigen/__init__.py +++ b/nmigen/__init__.py @@ -1,8 +1,8 @@ -import pkg_resources try: - __version__ = pkg_resources.get_distribution(__name__).version -except pkg_resources.DistributionNotFound: - pass + from importlib import metadata as importlib_metadata # py3.8+ stdlib +except ImportError: + import importlib_metadata # py3.7- shim +__version__ = importlib_metadata.version(__package__) from .hdl import * -- 2.30.2