diff --git a/pyproject.toml b/pyproject.toml index b35aed7..f85a6eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -116,9 +116,6 @@ get_fw_tab_completion_script = "firewheel.cli.completion.prepare_completion_scri # Required for tox documentation building firewheel = ["firewheel.yaml"] -[tool.setuptools.dynamic] -version = {attr = "firewheel.__version__"} - [tool.setuptools_scm] [tool.doc8] diff --git a/src/firewheel/__init__.py b/src/firewheel/__init__.py index 4c907d6..dd74869 100644 --- a/src/firewheel/__init__.py +++ b/src/firewheel/__init__.py @@ -1,5 +1,3 @@ from pathlib import Path -__version__ = "2.7.0" - FIREWHEEL_PACKAGE_DIR = Path(__file__).parent diff --git a/src/firewheel/cli/firewheel_cli.py b/src/firewheel/cli/firewheel_cli.py index aa43623..498724b 100755 --- a/src/firewheel/cli/firewheel_cli.py +++ b/src/firewheel/cli/firewheel_cli.py @@ -7,12 +7,12 @@ import textwrap from math import floor from uuid import uuid4 +from importlib.metadata import version from rich.columns import Columns from rich.console import Console from rich.markdown import Markdown -import firewheel from firewheel.cli import utils from firewheel.config import Config from firewheel.lib.log import Log @@ -953,7 +953,7 @@ def do_version(self, arg): # Write to the history file. if not self.interactive: self.write_history(f"version {arg}") - print(firewheel.__version__) + print(version("firewheel")) def help_list(self): """Help message for the list command. diff --git a/src/firewheel/lib/grpc/firewheel_grpc_server.py b/src/firewheel/lib/grpc/firewheel_grpc_server.py index cec9e89..eb3529b 100644 --- a/src/firewheel/lib/grpc/firewheel_grpc_server.py +++ b/src/firewheel/lib/grpc/firewheel_grpc_server.py @@ -6,11 +6,11 @@ from typing import Iterable from datetime import datetime from concurrent import futures +from importlib.metadata import version import grpc from google.protobuf.json_format import Parse, MessageToDict -import firewheel from firewheel.config import Config from firewheel.lib.log import Log from firewheel.lib.grpc import firewheel_grpc_pb2, firewheel_grpc_pb2_grpc @@ -52,7 +52,7 @@ def __init__(self): self.log.info("Initialized FirewheelServicer log.") self.server_start_time = datetime.utcnow() - self.version = firewheel.__version__ + self.version = version("firewheel") self.cache_dir = os.path.join( config["grpc"]["root_dir"], config["grpc"]["cache_dir"] ) diff --git a/src/firewheel/tests/unit/cli/test_cli.py b/src/firewheel/tests/unit/cli/test_cli.py index ac83c16..d5be4d4 100644 --- a/src/firewheel/tests/unit/cli/test_cli.py +++ b/src/firewheel/tests/unit/cli/test_cli.py @@ -5,8 +5,8 @@ import tempfile import unittest import unittest.mock +from importlib.metadata import version -import firewheel from firewheel.config import Config from firewheel.cli.utils import HelperNotFoundError from firewheel.cli.firewheel_cli import FirewheelCLI @@ -277,7 +277,7 @@ def test_do_version(self, mock_stdout): args = "" cli.do_version(args) - self.assertEqual(mock_stdout.getvalue().strip(), firewheel.__version__) + self.assertEqual(mock_stdout.getvalue().strip(), version("firewheel")) def test_do_exit(self): cli = FirewheelCLI()