11#!/usr/bin/env python
22
33from setuptools import setup
4- from subprocess import Popen , PIPE
54import os
6-
7- def call_git_describe ():
8- try :
9- p = Popen (['git' , 'describe' , '--tags' , '--dirty' , '--always' ],
10- stdout = PIPE , stderr = PIPE )
11- p .stderr .close ()
12- line = p .stdout .readlines ()[0 ]
13- return line .strip ()
14- except :
15- return None
16-
17- def read_release_version ():
18- try :
19- f = open (os .path .join (os .path .dirname (__file__ ), 'RELEASE-VERSION' ), "r" )
20- try :
21- version = f .readlines ()[0 ]
22- return version .strip ()
23- finally :
24- f .close ()
25- except :
26- return None
27-
28- def write_release_version (version ):
29- f = open (os .path .join (os .path .dirname (__file__ ), 'RELEASE-VERSION' ), "w" )
30- f .write ("%s\n " % version )
31- f .close ()
32-
33- def pep386adapt (version ):
34- if version is not None and '-' in version :
35- # adapt git-describe version to be in line with PEP 386
36- # Break PEP 386 a bit here and append the Git hash
37- parts = version .split ('-' )
38- if len (parts ) > 2 :
39- version = '%s.post%s-%s' % (
40- parts [0 ], parts [1 ],
41- '-' .join (parts [2 :])
42- )
43- return version
44- else :
45- return version
46-
47- def get_git_version ():
48- # Read in the version that's currently in RELEASE-VERSION.
49- release_version = read_release_version ()
50-
51- # First try to get the current version using 'git describe'.
52- version = call_git_describe ()
53-
54- # Take off the leading if present.
55- if version [0 ] == 'v' :
56- version = version [1 :]
57-
58- #adapt to PEP 386 compatible versioning scheme
59- version = pep386adapt (version )
60-
61- # If that doesn't work, fall back on the value that's in
62- # RELEASE-VERSION.
63- if version is None :
64- version = release_version
65-
66- # If we still don't have anything, that's an error.
67- if version is None :
68- raise ValueError ("Cannot find the version number!" )
69-
70- # If the current version is different from what's in the
71- # RELEASE-VERSION file, update the file to be current.
72- if version != release_version :
73- write_release_version (version )
74-
75- # Finally, return the current version.
76- return version
77-
78- VERSION = get_git_version ()
5+ from sbp .version import VERSION
796
807CLASSIFIERS = [
818 'Intended Audience :: Developers' ,
@@ -102,6 +29,10 @@ def get_git_version():
10229 'win32' ,
10330]
10431
32+ PACKAGE_DATA = { 'sbp' : [
33+ 'RELEASE-VERSION' ,
34+ ] }
35+
10536cwd = os .path .abspath (os .path .dirname (__file__ ))
10637with open (cwd + '/README.rst' ) as f :
10738 readme = f .read ()
@@ -119,6 +50,7 @@ def get_git_version():
11950 classifiers = CLASSIFIERS ,
12051 packages = PACKAGES ,
12152 platforms = PLATFORMS ,
53+ package_data = PACKAGE_DATA ,
12254 install_requires = INSTALL_REQUIRES ,
12355 use_2to3 = False ,
12456 zip_safe = False )
0 commit comments