diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 861e42d..01ee7f7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -94,7 +94,7 @@ jobs: setup.py - name: Install dependencies - run: python -m pip install -e ".[dev]" -e ".[docs]" + run: python -m pip install -e ".[dev,docs]" - name: Run mypy run: mypy . diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 91b025b..d99b2e0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,6 +24,18 @@ Install documentation dependencies with: pip install -e ".[docs]" ``` +Install runtime dependencies with: + +```bash +pip install -e . +``` + +All dependencies can be installed at once with: + +```bash +pip install -e ".[dev,docs]" +``` + ### Running the Tests Run the following command to run the [Tox](https://github.com/tox-dev/tox) test script which will verify that the tested functionality is still working. diff --git a/pyproject.toml b/pyproject.toml index 9db538c..7b8a95a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,8 +5,8 @@ build-backend = "setuptools.build_meta" [project] name = "table2ascii" +version = "1.1.0" authors = [{name = "Jonah Lawrence", email = "jonah@freshidea.com"}] -dynamic = ["version"] description = "Convert 2D Python lists into Unicode/ASCII tables" readme = "README.md" requires-python = ">=3.7" @@ -39,6 +39,7 @@ classifiers = [ ] dependencies = [ "typing-extensions>=3.7.4; python_version<'3.8'", + "importlib-metadata<5,>=1; python_version<'3.8'", "wcwidth<1", ] diff --git a/setup.py b/setup.py index 5fbf35d..d32b777 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,4 @@ # /usr/bin/env python -import re - from setuptools import setup - -def version(): - version = "" - with open("table2ascii/__init__.py") as f: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE) - if not version: - raise RuntimeError("version is not set") - return version.group(1) - - -setup(name="table2ascii", version=version()) +setup() diff --git a/table2ascii/__init__.py b/table2ascii/__init__.py index 19fa31a..a86dc02 100644 --- a/table2ascii/__init__.py +++ b/table2ascii/__init__.py @@ -1,6 +1,8 @@ """ table2ascii - Library for converting 2D Python lists to fancy ASCII/Unicode tables """ +import sys +from typing import TYPE_CHECKING from .alignment import Alignment from .merge import Merge @@ -8,7 +10,12 @@ from .table_style import TableStyle from .table_to_ascii import table2ascii -__version__ = "1.0.4" +if TYPE_CHECKING or sys.version_info >= (3, 8): + from importlib import metadata +else: + import importlib_metadata as metadata + +__version__ = metadata.version(__name__) __all__ = [ "Alignment", diff --git a/table2ascii/annotations.py b/table2ascii/annotations.py index 241e787..60a4e3d 100644 --- a/table2ascii/annotations.py +++ b/table2ascii/annotations.py @@ -2,14 +2,11 @@ from abc import abstractmethod from typing import TYPE_CHECKING -if sys.version_info >= (3, 8): +if TYPE_CHECKING or sys.version_info >= (3, 8): from typing import Protocol, runtime_checkable else: from typing_extensions import Protocol, runtime_checkable -if TYPE_CHECKING: - from typing import Protocol - @runtime_checkable class SupportsStr(Protocol):