Skip to content

Commit

Permalink
Merge pull request #137 from stephenfin/switch-to-importlib-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenfin committed Dec 7, 2022
2 parents 1f06ad8 + 5697a21 commit c5122cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"sphinx-mdinclude >= 0.5.2",
"picobox >= 2.2",
"deepmerge >= 0.1",
"importlib-metadata; python_version < '3.8'",
],
project_urls={
"Documentation": "https://sphinxcontrib-openapi.readthedocs.io/",
Expand All @@ -54,6 +55,5 @@
"Framework :: Sphinx",
"Framework :: Sphinx :: Extension",
],
namespace_packages=["sphinxcontrib"],
python_requires=">=3.7",
)
2 changes: 1 addition & 1 deletion sphinxcontrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
:license: BSD, see LICENSE for details.
"""

__import__("pkg_resources").declare_namespace(__name__)
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
10 changes: 7 additions & 3 deletions sphinxcontrib/openapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
:license: BSD, see LICENSE for details.
"""

from pkg_resources import get_distribution, DistributionNotFound
try:
from importlib.metadata import distribution, PackageNotFoundError
except ImportError: # python < 3.8
from importlib_metadata import distribution, PackageNotFoundError

from sphinxcontrib.openapi import renderers, directive

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
__version__ = distribution(__name__).version
except PackageNotFoundError:
# package is not installed
__version__ = None

Expand Down

0 comments on commit c5122cd

Please sign in to comment.