Skip to content

Commit

Permalink
Merge pull request #115 from Aiven-Open/rushidave-deprecated-version-py
Browse files Browse the repository at this point in the history
fix import error version.py for fedora 39 [SRE-7997]
  • Loading branch information
alexole committed Feb 5, 2024
2 parents 5c6f31f + 87477b8 commit acb4edf
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 acb4edf

Please sign in to comment.