Skip to content

Commit bf97fb8

Browse files
Update version to 2.0.3 and enhance version retrieval in CLI
- Bumped the project version to 2.0.3 in pyproject.toml. - Refactored the version retrieval method in the CLI to use the __version__ attribute from the module, improving reliability and maintainability. - Added import handling for compatibility with Python versions below 3.8.
1 parent e1a1da3 commit bf97fb8

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "Gen3SchemaDev"
3-
version = "2.0.2"
3+
version = "2.0.3"
44
description = "Tool for data modelling in Gen3"
55
authors = [
66
{name = "JoshuaHarris391",email = "[email protected]"}

src/gen3schemadev/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,15 @@
33
from .validators import *
44
from .cli import *
55
from .utils import *
6-
from .converter import *
6+
from .converter import *
7+
from .ddvis import *
8+
9+
try:
10+
from importlib.metadata import version, PackageNotFoundError
11+
except ImportError:
12+
from importlib_metadata import version, PackageNotFoundError # for Python<3.8
13+
14+
try:
15+
__version__ = version("gen3schemadev")
16+
except PackageNotFoundError:
17+
__version__ = "unknown"

src/gen3schemadev/cli.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,11 @@
2020

2121

2222
def get_version():
23-
"""
24-
Returns the version string from pyproject.toml, or 'unknown' if not found.
25-
"""
26-
current_dir = os.path.dirname(os.path.abspath(__file__))
27-
root_dir = os.path.abspath(os.path.join(current_dir, "..", ".."))
28-
pyproject_path = os.path.join(root_dir, "pyproject.toml")
2923
try:
30-
with open(pyproject_path, "r", encoding="utf-8") as f:
31-
for line in f:
32-
if line.strip().startswith("version"):
33-
parts = line.split("=")
34-
if len(parts) == 2:
35-
return parts[1].strip().strip('"').strip("'")
36-
except Exception:
37-
pass
38-
return "unknown"
24+
from . import __version__
25+
return __version__
26+
except ImportError:
27+
return "unknown"
3928

4029

4130
def main():

0 commit comments

Comments
 (0)