Skip to content

Commit 506d48a

Browse files
committed
Get the version dynamically from __init__.py
1 parent 5562b40 commit 506d48a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "py-gcode-metadata"
7-
version = "0.2.0dev"
87
description = "Python library for extraction of metadata from g-code files"
98
readme = {file = "README.md", content-type="text/markdown"}
109
license = {text = "LGPLv2+"}
@@ -31,6 +30,10 @@ classifiers = [
3130
"Topic :: Software Development :: Libraries :: Python Modules",
3231
]
3332

33+
dynamic = [
34+
"version",
35+
]
36+
3437
[project.urls]
3538
"Homepage" = "https://github.com/prusa3d/gcode-metadata"
3639
"Bug Tracker" = "https://github.com/prusa3d/gcode-metadata/issues"

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Setup of PrusaConnect SDK for Printer."""
2+
import re
3+
24
from setuptools import setup # type: ignore
35

46

@@ -7,10 +9,14 @@ def doc():
79
with open('README.md', 'r', encoding="utf-8") as readme:
810
return readme.read().strip()
911

12+
METADATA = {}
13+
with open("gcode_metadata/__init__.py", "r", encoding="utf-8") as info:
14+
METADATA = dict(re.findall(r'__([a-z_]+)__ = "([^"]+)"', info.read()))
15+
1016

1117
setup(
1218
name='py-gcode-metadata',
13-
version='0.2.0dev',
19+
version=METADATA["version"],
1420
packages=['gcode_metadata'],
1521
url='https://github.com/prusa3d/gcode-metadata',
1622
license='LGPLv2+',

0 commit comments

Comments
 (0)