Skip to content

Commit a4fb45c

Browse files
committed
Fixes for versioning and installation; updating the deprecated pyproject.toml stuff for building
1 parent 104c3dc commit a4fb45c

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,21 @@ build-backend = "setuptools.build_meta"
1111

1212
[project]
1313
name = "matej-libs"
14-
version = "0.12.3"
14+
version = "0.12.4"
1515
authors = [{name = "Matej Vitek", email = "matej.vitek.business@gmail.com"}]
16+
license = "GPL-3.0-or-later"
17+
license-files = ["LICENSE"]
1618
requires-python = ">=3.12"
1719
dependencies = ["numpy"]
1820
description = "Collection of Python utility libraries."
1921
readme = "README.md"
2022
classifiers = [
2123
"Programming Language :: Python :: 3",
22-
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
2324
"Operating System :: OS Independent",
2425
"Development Status :: 3 - Alpha",
2526
"Intended Audience :: Developers",
2627
]
2728

28-
[tool.setuptools] #TODO: This is needed until they fix twine packaging and uploading.
29-
license-files = [] # Try removing on next build.
30-
3129
[project.optional-dependencies]
3230
web = ["requests"]
3331
config = ["ruamel.yaml"]

src/matej/__init__.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,26 @@
2525

2626

2727
try:
28-
__version__ = importlib.metadata.version(__package__ or __name__)
28+
__version__ = importlib.metadata.version('matej-libs')
2929
except importlib.metadata.PackageNotFoundError:
3030
from pathlib import Path
3131
import re
32-
with (Path(__file__).resolve().parent.parent.parent/'pyproject.toml').open('r', encoding='utf-8') as f:
33-
__version__ = re.search(r'version\s*=\s*[\'"]?([^\'"]*)[\'"]?', f.read()).group(1)
32+
33+
_current_dir = Path(__file__).resolve().parent
34+
_toml_path = None
35+
36+
# Walk up the tree up to 4 levels looking for pyproject.toml
37+
for _ in range(4):
38+
if (_current_dir/'pyproject.toml').is_file():
39+
_toml_path = _current_dir/'pyproject.toml'
40+
break
41+
_current_dir = _current_dir.parent
42+
43+
if _toml_path:
44+
with _toml_path.open('r', encoding='utf-8') as f:
45+
__version__ = re.search(r'version\s*=\s*[\'"]?([^\'"]*)[\'"]?', f.read()).group(1)
46+
else:
47+
__version__ = 'unknown'
3448

3549

3650
@contextmanager

0 commit comments

Comments
 (0)