Skip to content

Commit

Permalink
update to read version from file instead of loading module (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
poornimaramesh authored Jun 27, 2024
1 parent 3ead328 commit ae7993f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions check_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib.util
import re

import requests

Expand All @@ -9,12 +10,20 @@ def main():
response = requests.get(url)
latest_version = response.json()["info"]["version"]

# Get the installed version number
module = importlib.util.spec_from_file_location("mosaiks", "./mosaiks/__init__.py")
mosaiks = importlib.util.module_from_spec(module)
module.loader.exec_module(mosaiks)
installed_version = mosaiks.__version__
# Get the version number from file
init_file_path = "./mosaiks/__init__.py"
version_pattern = r"^__version__ = ['\"]([^'\"]*)['\"]"

installed_version = None

with open(init_file_path, "r") as file:
for line in file:
# Search each line for the version pattern
match = re.search(version_pattern, line, re.M)
if match:
# If a match is found, extract the version number
installed_version = match.group(1)
break
# Compare the two version numbers
if latest_version != installed_version:
print(
Expand Down

0 comments on commit ae7993f

Please sign in to comment.