4
4
import re
5
5
from setuptools import setup
6
6
from setuptools .command .test import test as TestCommand
7
+ from setuptools .command .build_py import build_py as BuildCommand
7
8
8
9
def read (fname ):
9
10
with open (os .path .join (os .path .dirname (__file__ ), fname )) as fildes :
10
11
return fildes .read ()
11
12
12
- def get_version ():
13
- with open ('vhdeps/__init__.py' , 'r' ) as fildes :
14
- for line in fildes :
15
- match = re .match ("__version__ = '([^']+)'\n " , line )
16
- if match :
17
- return match .group (1 )
18
- raise ValueError ('Could not find package version' )
19
-
20
13
class NoseTestCommand (TestCommand ):
21
14
def finalize_options (self ):
22
15
TestCommand .finalize_options (self )
@@ -28,25 +21,37 @@ def run_tests(self):
28
21
import nose
29
22
nose .run_exit (argv = ['nosetests' ])
30
23
24
+ class BuildWithVersionCommand (BuildCommand ):
25
+ def run (self ):
26
+ if not self .dry_run :
27
+ version_fname = os .path .join (self .build_lib , 'vhdeps' , 'version.py' )
28
+ with open (version_fname , 'w' ) as fildes :
29
+ fildes .write ('__version__ = """' + self .distribution .metadata .version + '"""\n ' )
30
+
31
+ BuildCommand .run (self )
32
+
31
33
setup (
32
- name = "vhdeps" ,
33
- version = get_version (),
34
- author = "Jeroen van Straten" ,
35
- author_email = "[email protected] " ,
34
+ name = 'vhdeps' ,
35
+ version_config = {
36
+ 'version_format' : '{tag}+{sha}' ,
37
+ 'starting_version' : '0.0.1'
38
+ },
39
+ author = 'Jeroen van Straten' ,
40
+ author_email = '[email protected] ' ,
36
41
description = (
37
- " VHDL dependency analyzer and simulation driver."
42
+ ' VHDL dependency analyzer and simulation driver.'
38
43
),
39
- license = " Apache" ,
40
- keywords = " vhdl dependency analyzer simulation" ,
41
- url = " https://github.com/abs-tudelft/vhdeps" ,
44
+ license = ' Apache' ,
45
+ keywords = ' vhdl dependency analyzer simulation' ,
46
+ url = ' https://github.com/abs-tudelft/vhdeps' ,
42
47
long_description = read ('README.md' ),
43
48
long_description_content_type = 'text/markdown' ,
44
49
classifiers = [
45
- " Development Status :: 3 - Alpha" ,
46
- " Intended Audience :: Developers" ,
47
- " Topic :: Software Development :: Build Tools" ,
48
- " License :: OSI Approved :: Apache Software License" ,
49
- " Programming Language :: Python :: 3" ,
50
+ ' Development Status :: 3 - Alpha' ,
51
+ ' Intended Audience :: Developers' ,
52
+ ' Topic :: Software Development :: Build Tools' ,
53
+ ' License :: OSI Approved :: Apache Software License' ,
54
+ ' Programming Language :: Python :: 3' ,
50
55
],
51
56
project_urls = {
52
57
'Source' : 'https://github.com/abs-tudelft/vhdeps' ,
@@ -55,7 +60,14 @@ def run_tests(self):
55
60
entry_points = {'console_scripts' : ['vhdeps=vhdeps:run_cli' ]},
56
61
python_requires = '>=3' ,
57
62
install_requires = ['plumbum' ],
58
- setup_requires = ['setuptools-lint' , 'pylint' ],
63
+ setup_requires = [
64
+ 'better-setuptools-git-version' ,
65
+ 'setuptools-lint' ,
66
+ 'pylint'
67
+ ],
59
68
tests_require = ['nose' , 'coverage' ],
60
- cmdclass = {'test' : NoseTestCommand },
69
+ cmdclass = {
70
+ 'test' : NoseTestCommand ,
71
+ 'build_py' : BuildWithVersionCommand ,
72
+ },
61
73
)
0 commit comments