Skip to content

Commit 3e8b7ca

Browse files
authored
chore: Make version static in pyproject.toml (#87)
1 parent 12bab03 commit 3e8b7ca

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
setup.py
9595
9696
- name: Install dependencies
97-
run: python -m pip install -e ".[dev]" -e ".[docs]"
97+
run: python -m pip install -e ".[dev,docs]"
9898

9999
- name: Run mypy
100100
run: mypy .

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ Install documentation dependencies with:
2424
pip install -e ".[docs]"
2525
```
2626

27+
Install runtime dependencies with:
28+
29+
```bash
30+
pip install -e .
31+
```
32+
33+
All dependencies can be installed at once with:
34+
35+
```bash
36+
pip install -e ".[dev,docs]"
37+
```
38+
2739
### Running the Tests
2840

2941
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.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "table2ascii"
8+
version = "1.1.0"
89
authors = [{name = "Jonah Lawrence", email = "[email protected]"}]
9-
dynamic = ["version"]
1010
description = "Convert 2D Python lists into Unicode/ASCII tables"
1111
readme = "README.md"
1212
requires-python = ">=3.7"
@@ -39,6 +39,7 @@ classifiers = [
3939
]
4040
dependencies = [
4141
"typing-extensions>=3.7.4; python_version<'3.8'",
42+
"importlib-metadata<5,>=1; python_version<'3.8'",
4243
"wcwidth<1",
4344
]
4445

setup.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
# /usr/bin/env python
2-
import re
3-
42
from setuptools import setup
53

6-
7-
def version():
8-
version = ""
9-
with open("table2ascii/__init__.py") as f:
10-
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE)
11-
if not version:
12-
raise RuntimeError("version is not set")
13-
return version.group(1)
14-
15-
16-
setup(name="table2ascii", version=version())
4+
setup()

table2ascii/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
"""
22
table2ascii - Library for converting 2D Python lists to fancy ASCII/Unicode tables
33
"""
4+
import sys
5+
from typing import TYPE_CHECKING
46

57
from .alignment import Alignment
68
from .merge import Merge
79
from .preset_style import PresetStyle
810
from .table_style import TableStyle
911
from .table_to_ascii import table2ascii
1012

11-
__version__ = "1.0.4"
13+
if TYPE_CHECKING or sys.version_info >= (3, 8):
14+
from importlib import metadata
15+
else:
16+
import importlib_metadata as metadata
17+
18+
__version__ = metadata.version(__name__)
1219

1320
__all__ = [
1421
"Alignment",

table2ascii/annotations.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
from abc import abstractmethod
33
from typing import TYPE_CHECKING
44

5-
if sys.version_info >= (3, 8):
5+
if TYPE_CHECKING or sys.version_info >= (3, 8):
66
from typing import Protocol, runtime_checkable
77
else:
88
from typing_extensions import Protocol, runtime_checkable
99

10-
if TYPE_CHECKING:
11-
from typing import Protocol
12-
1310

1411
@runtime_checkable
1512
class SupportsStr(Protocol):

0 commit comments

Comments
 (0)