Replace find_version logic with exec to fix package version

Remove all the importlib trickery and use exec instead, as it was
essentially what this was doing anyway.
Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <>
parent 97b564fb
......@@ -10,8 +10,6 @@
import os
from importlib.machinery import PathFinder
from typing import Optional
from setuptools import setup
......@@ -19,32 +17,25 @@ except ImportError:
from distutils.core import setup
def find_version(load_path, name) -> Optional[str]:
"""Find module version"""
MODULE_FILE_PATH = os.path.join(
'slixmpp_omemo', ''
module = None
spec = PathFinder.find_spec(name, load_path)
module = spec.loader.load_module(name)
except (AttributeError, ImportError, SyntaxError):
return None
if module is None:
return None
def get_version() -> str:
"""Returns version by looking at slixmpp_omemo/"""
for key in dir(module):
if key != '__version__':
return getattr(module, key)
return None
version = {}
with open(MODULE_FILE_PATH) as file:
exec(, version)
if '__version__' in version:
return version['__version__']
return 'missingno'
MODULE_FILE_PATH = os.path.join(
VERSION = find_version(MODULE_FILE_PATH, 'version')
DESCRIPTION = ('Slixmpp OMEMO plugin')
VERSION = get_version()
with open('README.rst', encoding='utf8') as readme:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment