From: Oleg Broytman Date: Mon, 18 Feb 2019 18:04:40 +0000 (+0300) Subject: Build(setup): Use exec[file] to get version from __version__.py X-Git-Tag: 0.3.0~27 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=4b4ec0649ddc551d2c12950b200a97371b6025bb;p=sqlconvert.git Build(setup): Use exec[file] to get version from __version__.py Use exec[file] instead of imp/importlib. --- diff --git a/setup.py b/setup.py index f8fb216..6de1e21 100755 --- a/setup.py +++ b/setup.py @@ -4,28 +4,21 @@ from os.path import abspath, dirname, join from setuptools import setup import sys +versionpath = join(abspath(dirname(__file__)), 'sqlconvert', '__version__.py') +sqlconvert_version = {} + if sys.version_info[:2] == (2, 7): - from imp import load_source + execfile(versionpath, sqlconvert_version) elif sys.version_info >= (3, 4): - from importlib.machinery import SourceFileLoader - import types - - def load_source(fullname, path): - loader = SourceFileLoader(fullname, path) - loaded = types.ModuleType(loader.name) - loader.exec_module(loaded) - return loaded + exec(open(versionpath, 'rU').read(), sqlconvert_version) else: raise ImportError("sqlconvert requires Python 2.7 or 3.4+") -versionpath = join(abspath(dirname(__file__)), 'sqlconvert', '__version__.py') -sqlconvert_version = load_source('sqlconvert_version', versionpath) - setup( name='sqlconvert', - version=sqlconvert_version.__version__, + version=sqlconvert_version['__version__'], description='Broytman sqlconvert', long_description=open('README.rst', 'rU').read(), long_description_content_type="text/x-rst", @@ -37,7 +30,7 @@ setup( 'Documentation': 'https://phdru.name/Software/Python/sqlconvert/docs/', 'Download': 'https://pypi.org/project/sqlconvert/%s/' - % sqlconvert_version.__version__, + % sqlconvert_version['__version__'], 'Git repo': 'https://git.phdru.name/sqlconvert.git/', 'Github repo': 'https://github.com/phdru/sqlconvert', 'Issue tracker': 'https://github.com/phdru/sqlconvert/issues',