diff --git a/.gitignore b/.gitignore index f1fde8a..3dc85bd 100644 --- a/.gitignore +++ b/.gitignore @@ -51,8 +51,4 @@ coverage.xml # Sphinx documentation doc/build/ - -# pbr stuff -AUTHORS -ChangeLog -.eggs +src/doc8/_version.py diff --git a/doc/requirements.txt b/doc/requirements.txt index 86ac8a4..ecfdea5 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,3 +1,2 @@ -pbr # Apache sphinx>=1.8.0 # BSD sphinx_rtd_theme>=0.4.0 # MIT diff --git a/pyproject.toml b/pyproject.toml index fafb74a..f03d865 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,9 +7,6 @@ requires = [ ] build-backend = "setuptools.build_meta" -[tool.setuptools_scm] -local_scheme = "no-local-version" - [project] name = "doc8" description = "Style checker for Sphinx (or other) RST documentation" @@ -75,7 +72,7 @@ filterwarnings = [ [[tool.mypy.overrides]] module = [ - "pbr", + "doc8._version", "restructuredtext_lint", "stevedore", ] @@ -91,7 +88,6 @@ disable = [ "missing-class-docstring", "missing-function-docstring", "missing-module-docstring", - "no-self-use", "too-few-public-methods", "too-many-arguments", "too-many-branches", @@ -117,3 +113,7 @@ license-files = ["LICENSE"] [tool.setuptools.packages.find] where = ["src"] namespaces = false + +[tool.setuptools_scm] +local_scheme = "no-local-version" +write_to = "src/doc8/_version.py" diff --git a/src/doc8/__init__.py b/src/doc8/__init__.py index 75f40db..bfb66eb 100644 --- a/src/doc8/__init__.py +++ b/src/doc8/__init__.py @@ -1 +1,7 @@ -from .main import doc8 # noqa +"""doc8 - A docutils linter.""" +from __future__ import annotations +from doc8.version import __version__ +from doc8.main import doc8 # noqa + + +__all__ = ("__version__",) diff --git a/src/doc8/main.py b/src/doc8/main.py index 7aa80d6..2dfe85f 100644 --- a/src/doc8/main.py +++ b/src/doc8/main.py @@ -522,7 +522,7 @@ def main(): ) args = vars(parser.parse_args()) if args.get("version"): - print(version.version_string) + print(version.__version__) return 0 result = doc8(args) diff --git a/src/doc8/version.py b/src/doc8/version.py index 5ceb9fa..fe71aec 100644 --- a/src/doc8/version.py +++ b/src/doc8/version.py @@ -14,13 +14,18 @@ # License for the specific language governing permissions and limitations # under the License. +"""doc8 version information.""" try: - from pbr import version as pbr_version + from ._version import version as __version__ +except ImportError: # pragma: no branch - _version_info = pbr_version.VersionInfo("doc8") - version_string = _version_info.version_string() -except ImportError: - import pkg_resources + try: + import pkg_resources - _version_info = pkg_resources.get_distribution("doc8") - version_string = _version_info.version + __version__ = pkg_resources.get_distribution("doc8").version + except Exception: # pylint: disable=broad-except + # this is the fallback SemVer version picked by setuptools_scm when tag + # information is not available. + __version__ = "0.1.dev1" + +__all__ = ("__version__",)