Skip to content

Commit

Permalink
fix import error version.py for fedora 39 [SRE-7997]
Browse files Browse the repository at this point in the history
  • Loading branch information
rushidave committed Jan 31, 2024
1 parent 028ba9e commit 87477b8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
See LICENSE for details
"""

import imp
import importlib.util
import os
import subprocess

Expand All @@ -24,7 +24,15 @@ def save_version(new_ver, old_ver, version_file):
def get_project_version(version_file):
version_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), version_file)
try:
module = imp.load_source("verfile", version_file)
# Load the source file using SourceFileLoader
loader = importlib.machinery.SourceFileLoader("verfile", version_file)
spec = importlib.util.spec_from_loader(loader.name, loader)
module = importlib.util.module_from_spec(spec)

# Execute the module code
loader.exec_module(module)

# Access the version attribute from the module
file_ver = module.__version__
except IOError:
file_ver = None
Expand Down

0 comments on commit 87477b8

Please sign in to comment.