Bring __version__
retrieval up to date. NFCI
Because `importlib.metadata.PackageNotFoundError` inherits from `ImportError`, the code did not previously work in the way that was stated in the comment. We should probably deprecate `__version__` entirely at some point.
This commit is contained in:
parent
012f12339d
commit
20e8bbdfbd
|
@ -1,12 +1,13 @@
|
||||||
|
# Extract version for this package from the environment package metadata. This used to be a lot
|
||||||
|
# more difficult in earlier Python versions, and the `__version__` field is a legacy of that time.
|
||||||
|
import importlib.metadata
|
||||||
try:
|
try:
|
||||||
from importlib import metadata as importlib_metadata
|
__version__ = importlib.metadata.version(__package__)
|
||||||
__version__ = importlib_metadata.version(__package__)
|
except importlib.metadata.PackageNotFoundError:
|
||||||
del importlib_metadata
|
# No importlib metadata for this package. This shouldn't normally happen, but some people
|
||||||
except ImportError:
|
# prefer not installing packages via pip at all. Although not recommended we still support it.
|
||||||
# No importlib_metadata. This shouldn't normally happen, but some people prefer not installing
|
|
||||||
# packages via pip at all, instead using PYTHONPATH directly or copying the package files into
|
|
||||||
# `lib/pythonX.Y/site-packages`. Although not a recommended way, we still try to support it.
|
|
||||||
__version__ = "unknown" # :nocov:
|
__version__ = "unknown" # :nocov:
|
||||||
|
del importlib
|
||||||
|
|
||||||
|
|
||||||
from .hdl import *
|
from .hdl import *
|
||||||
|
|
Loading…
Reference in a new issue