Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOTFIX: update package version from file instead of loading module #172

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading