Skip to content

Commit 86c9025

Browse files
committed
Update version scheme
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
1 parent 6d72dc8 commit 86c9025

4 files changed

Lines changed: 44 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ jobs:
1919
./packages/python/bin/python3 -m pip install wheel twine
2020
./packages/python/bin/python3 -m pip install pip setuptools --upgrade
2121
rm -rf dist build *.egg-info src/*.egg-info
22-
sed -i -e "s/version = \"\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)\"/version = \"\1.${GITHUB_RUN_ID}\"/" pyproject.toml
23-
grep "^version = " pyproject.toml
24-
export BUILD_NUM=$GITHUB_RUN_ID
25-
echo "BUILD_NUM=${BUILD_NUM}"
22+
sed -i -e "s/^SUFFIX = \"\"$/SUFFIX = \".${GITHUB_RUN_ID}\"/" src/ucis/__version__.py
23+
grep "^SUFFIX = " src/ucis/__version__.py
2624
./packages/python/bin/python3 setup.py bdist_wheel --universal
2725
- name: Run Tests
2826
run: |

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["setuptools>=61.0", "setuptools-scm"]
2+
requires = ["setuptools>=61.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pyucis"
7-
version = "0.1.5"
7+
dynamic = ["version"]
88
authors = [
99
{name = "Matthew Ballance", email = "matt.ballance@gmail.com"},
1010
]
@@ -53,6 +53,9 @@ Issues = "https://github.com/fvutils/pyucis/issues"
5353
pyucis = "ucis.__main__:main"
5454
pyucis-mcp-server = "ucis.mcp.server:main"
5555

56+
[tool.setuptools.dynamic]
57+
version = {attr = "ucis.__version__._pkg_version"}
58+
5659
[tool.setuptools]
5760
package-dir = {"" = "src"}
5861

src/ucis/__main__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,12 @@ def _launch_tui(args):
305305
app.run()
306306

307307
def main():
308+
# Handle --version/-V before the subcommand parser (which requires a subcommand)
309+
if len(sys.argv) == 2 and sys.argv[1] in ("--version", "-V"):
310+
from ucis.__version__ import get_version
311+
print(get_version())
312+
return
313+
308314
# Print skill information at the start
309315
print_skill_info()
310316
print()

src/ucis/__version__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
BASE = "0.1.5"
3+
SUFFIX = ""
4+
5+
__version__ = (BASE, SUFFIX)
6+
7+
# Package version string used by pyproject.toml dynamic versioning
8+
_pkg_version = BASE + SUFFIX
9+
10+
11+
def get_version():
12+
"""Return the full version string, querying git when running from source."""
13+
base, suffix = __version__
14+
if suffix:
15+
return "%s%s" % (base, suffix)
16+
# Try to append git commit info when running from a source tree
17+
try:
18+
import subprocess, os
19+
src_dir = os.path.dirname(os.path.dirname(os.path.dirname(
20+
os.path.abspath(__file__))))
21+
out = subprocess.check_output(
22+
["git", "describe", "--tags", "--dirty", "--always"],
23+
cwd=src_dir,
24+
stderr=subprocess.DEVNULL,
25+
).decode().strip()
26+
# If the tag matches BASE exactly, no suffix needed
27+
if out != base:
28+
return "%s+%s" % (base, out)
29+
except Exception:
30+
pass
31+
return base

0 commit comments

Comments
 (0)