Skip to content

Commit

Permalink
fix: update version detection to work in build environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewcasale committed Dec 14, 2024
1 parent fe72e7c commit de225fa
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@
import re

def get_version():
init_path = os.path.join("repominify", "__init__.py")
with open(init_path, "r") as f:
content = f.read()
version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']', content, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Cannot find version string.")
# Try both the source directory and the package directory
possible_paths = [
os.path.join("repominify", "__init__.py"),
os.path.join("repominify", "repominify", "__init__.py"),
]

for init_path in possible_paths:
try:
with open(init_path, "r") as f:
content = f.read()
version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']', content, re.M)
if version_match:
return version_match.group(1)
except FileNotFoundError:
continue

raise RuntimeError("Cannot find version string in __init__.py")

setup(
name="repominify",
Expand Down

0 comments on commit de225fa

Please sign in to comment.