Skip to content

Commit 0b24e8c

Browse files
committed
Fix build process with dynamic version resolution
- Update setup.py to use git tags as single source of truth - Fix version resolution in isolated build environments - Update fallback version to match latest git tag (1.1.12) - Ensure released file names use correct dynamic versioning
1 parent 8a11944 commit 0b24e8c

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

route_planner/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _get_version():
2222
return result.stdout.strip().lstrip('v')
2323
except (subprocess.CalledProcessError, FileNotFoundError, ImportError):
2424
# Fallback for environments without git or in packaged distributions
25-
return "1.1.11"
25+
return "1.1.12"
2626

2727
__version__ = _get_version()
2828
__author__ = "Route Planner Development Team"

setup.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,36 @@
88
with open("requirements.txt", "r", encoding="utf-8") as f:
99
requirements = f.read().splitlines()
1010

11-
# Read version from package
11+
# Read version dynamically (same system as package)
1212
def get_version():
13-
"""Get version from route_planner/__init__.py"""
14-
import re
15-
with open("route_planner/__init__.py", "r", encoding="utf-8") as f:
16-
content = f.read()
17-
match = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', content, re.MULTILINE)
18-
if match:
19-
return match.group(1)
20-
raise RuntimeError("Unable to find version string")
13+
"""Get version using the same dynamic system as the package."""
14+
import os
15+
import subprocess
16+
from pathlib import Path
17+
18+
# Get current directory (setup.py location)
19+
current_dir = Path.cwd()
20+
21+
# Try git tags first (single source of truth)
22+
try:
23+
result = subprocess.run(
24+
['git', 'describe', '--tags', '--abbrev=0'],
25+
cwd=current_dir,
26+
capture_output=True,
27+
text=True,
28+
check=True
29+
)
30+
return result.stdout.strip().lstrip('v')
31+
except (subprocess.CalledProcessError, FileNotFoundError):
32+
pass
33+
34+
# Try environment variable
35+
version = os.getenv('VERSION')
36+
if version:
37+
return version.lstrip('v')
38+
39+
# Fallback version (must match package fallback)
40+
return "1.1.12"
2141

2242
setup(
2343
name="route-planner",

0 commit comments

Comments
 (0)