diff --git a/fastwsgi.py b/fastwsgi.py index 96ac2f8..53c90b6 100644 --- a/fastwsgi.py +++ b/fastwsgi.py @@ -4,9 +4,9 @@ import importlib import click import _fastwsgi -from pkg_resources import get_distribution +import importlib.metadata -__version__ = get_distribution("fastwsgi").version +__version__ = importlib.metadata.version("fastwsgi") LL_DISABLED = 0 LL_FATAL_ERROR = 1 @@ -121,7 +121,7 @@ def import_from_string(import_str): # ------------------------------------------------------------------------------------- @click.command() -@click.version_option(version=get_distribution("fastwsgi").version, message="%(version)s") +@click.version_option(version=__version__, message="%(version)s") @click.option("--host", help="Host the socket is bound to.", type=str, default=server.host, show_default=True) @click.option("-p", "--port", help="Port the socket is bound to.", type=int, default=server.port, show_default=True) @click.option("-l", "--loglevel", help="Logging level.", type=int, default=server.loglevel, show_default=True) diff --git a/tests/test_cli.py b/tests/test_cli.py index 60fabfc..fc7855c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,5 +1,5 @@ +import importlib.metadata from click.testing import CliRunner -from pkg_resources import get_distribution from fastwsgi import run_from_cli @@ -23,9 +23,9 @@ def test_help(self): def test_version(self): result = call_fastwsgi(parameters=["--version"]) assert result.exit_code == 0 - assert result.output.strip() == get_distribution("fastwsgi").version + assert result.output.strip() == importlib.metadata.version(("fastwsgi") def test_run_from_cli_invalid_module(self): result = call_fastwsgi(arguments=["module:wrong"]) assert result.exit_code == 1 - assert result.output.strip() == "Error importing WSGI app: No module named 'module'" \ No newline at end of file + assert result.output.strip() == "Error importing WSGI app: No module named 'module'"