Add get_version() to setup.py
# -*- coding: utf-8 -*-
-import sys
+
+import os
+
from setuptools import setup, find_packages
-sys.path.insert(0, 'src')
-import blockdiag
classifiers = [
"Development Status :: 5 - Production/Stable",
@@ -20,9 +20,21 @@ classifiers = [
]
+def get_version():
+ """Get version number of the package from version.py without importing core module."""
+ package_dir = os.path.abspath(os.path.dirname(__file__))
+ version_file = os.path.join(package_dir, 'src/blockdiag/__init__.py')
+
+ namespace = {}
+ with open(version_file, 'r') as f:
+ exec(f.read(), namespace)
+
+ return namespace['__version__']
+
+
setup(
name='blockdiag',
- version=blockdiag.__version__,
+ version=get_version(),
description='blockdiag generates block-diagram image from text',
long_description=open("README.rst").read(),
classifiers=classifiers,
