Skip to content
This repository was archived by the owner on Nov 19, 2018. It is now read-only.

Commit 487ea9f

Browse files
committed
Add and use __version__ from main file
__version__ in main file of the package is one of the recomended by Python Packaging User Guide. See: https://packaging.python.org/guides/single-sourcing-package-version/
1 parent be514e4 commit 487ea9f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pydot_ng/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
__author__ = 'Ero Carrera'
3535
__license__ = 'MIT'
36+
__version__ = '1.0.1.dev0'
3637

3738
PY3 = not sys.version_info < (3, 0, 0)
3839

setup.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python
2+
import ast
23
import os
4+
import re
35
from codecs import open
46

57
from setuptools import setup
@@ -10,13 +12,25 @@
1012
os.environ['COPYFILE_DISABLE'] = 'true'
1113

1214

15+
CURRENT_DIR = os.path.dirname(__file__)
16+
17+
18+
def get_version():
19+
init_file = os.path.join(CURRENT_DIR, 'pydot_ng', '__init__.py')
20+
_version_re = re.compile(r'__version__\s+=\s+(?P<version>.*)')
21+
with open(init_file, 'r', encoding='utf8') as f:
22+
match = _version_re.search(f.read())
23+
version = match.group('version') if match is not None else '"unknown"'
24+
return str(ast.literal_eval(version))
25+
26+
1327
with open('README.rst', 'r', 'utf-8') as f:
1428
readme = f.read()
1529

1630

1731
setup(
1832
name='pydot_ng',
19-
version='1.0.1.dev0',
33+
version=get_version(),
2034
description='Python interface to Graphviz\'s Dot',
2135
author='Ero Carrera',
2236
author_email='ero@dkbza.org',

0 commit comments

Comments
 (0)