15
15
16
16
# Use this version when git data are not available, like in git zip archive.
17
17
# Update when tagging a new release.
18
- FALLBACK_VERSION = ' 2.0.4'
18
+ FALLBACK_VERSION = " 2.0.4"
19
19
20
20
# determine if we run with Python 3.
21
- PY3 = ( sys .version_info [0 ] == 3 )
21
+ PY3 = sys .version_info [0 ] == 3
22
22
23
23
# versioncfgfile holds version data for git commit hash and date.
24
24
# It must reside in the same directory as version.py.
25
25
MYDIR = os .path .dirname (os .path .abspath (__file__ ))
26
- versioncfgfile = os .path .join (MYDIR , 'src/diffpy/pdfgui/version.cfg' )
27
- gitarchivecfgfile = os .path .join (MYDIR , '.gitarchive.cfg' )
26
+ versioncfgfile = os .path .join (MYDIR , "src/diffpy/pdfgui/version.cfg" )
27
+ gitarchivecfgfile = os .path .join (MYDIR , ".gitarchive.cfg" )
28
+
28
29
29
30
def gitinfo ():
30
31
from subprocess import Popen , PIPE
32
+
31
33
kw = dict (stdout = PIPE , cwd = MYDIR , universal_newlines = True )
32
- proc = Popen ([' git' , ' describe' , ' --tags' , ' --match=v[[:digit:]]*' ], ** kw )
34
+ proc = Popen ([" git" , " describe" , " --tags" , " --match=v[[:digit:]]*" ], ** kw )
33
35
desc = proc .stdout .read ()
34
- proc = Popen ([' git' , ' log' , '-1' , ' --format=%H %ct %ci' ], ** kw )
36
+ proc = Popen ([" git" , " log" , "-1" , " --format=%H %ct %ci" ], ** kw )
35
37
glog = proc .stdout .read ()
36
38
rv = {}
37
- rv [' version' ] = ' .post' .join (desc .strip ().split ('-' )[:2 ]).lstrip ('v' )
38
- rv [' commit' ], rv [' timestamp' ], rv [' date' ] = glog .strip ().split (None , 2 )
39
+ rv [" version" ] = " .post" .join (desc .strip ().split ("-" )[:2 ]).lstrip ("v" )
40
+ rv [" commit" ], rv [" timestamp" ], rv [" date" ] = glog .strip ().split (None , 2 )
39
41
return rv
40
42
41
43
@@ -44,19 +46,19 @@ def getversioncfg():
44
46
from configparser import RawConfigParser
45
47
else :
46
48
from ConfigParser import RawConfigParser
47
- vd0 = dict (version = FALLBACK_VERSION , commit = '' , date = '' , timestamp = 0 )
49
+ vd0 = dict (version = FALLBACK_VERSION , commit = "" , date = "" , timestamp = 0 )
48
50
# first fetch data from gitarchivecfgfile, ignore if it is unexpanded
49
51
g = vd0 .copy ()
50
52
cp0 = RawConfigParser (vd0 )
51
53
cp0 .read (gitarchivecfgfile )
52
- if len (cp0 .get (' DEFAULT' , ' commit' )) > 20 :
54
+ if len (cp0 .get (" DEFAULT" , " commit" )) > 20 :
53
55
g = cp0 .defaults ()
54
- mx = re .search (r' \btag: v(\d[^,]*)' , g .pop (' refnames' ))
56
+ mx = re .search (r" \btag: v(\d[^,]*)" , g .pop (" refnames" ))
55
57
if mx :
56
- g [' version' ] = mx .group (1 )
58
+ g [" version" ] = mx .group (1 )
57
59
# then try to obtain version data from git.
58
- gitdir = os .path .join (MYDIR , ' .git' )
59
- if os .path .exists (gitdir ) or ' GIT_DIR' in os .environ :
60
+ gitdir = os .path .join (MYDIR , " .git" )
61
+ if os .path .exists (gitdir ) or " GIT_DIR" in os .environ :
60
62
try :
61
63
g = gitinfo ()
62
64
except OSError :
@@ -65,94 +67,97 @@ def getversioncfg():
65
67
cp = RawConfigParser ()
66
68
cp .read (versioncfgfile )
67
69
d = cp .defaults ()
68
- rewrite = not d or (g ['commit' ] and (
69
- g ['version' ] != d .get ('version' ) or g ['commit' ] != d .get ('commit' )))
70
+ rewrite = not d or (
71
+ g ["commit" ]
72
+ and (g ["version" ] != d .get ("version" ) or g ["commit" ] != d .get ("commit" ))
73
+ )
70
74
if rewrite :
71
- cp .set (' DEFAULT' , ' version' , g [' version' ])
72
- cp .set (' DEFAULT' , ' commit' , g [' commit' ])
73
- cp .set (' DEFAULT' , ' date' , g [' date' ])
74
- cp .set (' DEFAULT' , ' timestamp' , g [' timestamp' ])
75
- with open (versioncfgfile , 'w' ) as fp :
75
+ cp .set (" DEFAULT" , " version" , g [" version" ])
76
+ cp .set (" DEFAULT" , " commit" , g [" commit" ])
77
+ cp .set (" DEFAULT" , " date" , g [" date" ])
78
+ cp .set (" DEFAULT" , " timestamp" , g [" timestamp" ])
79
+ with open (versioncfgfile , "w" ) as fp :
76
80
cp .write (fp )
77
81
return cp
78
82
83
+
79
84
versiondata = getversioncfg ()
80
85
81
86
82
87
def dirglob (d , * patterns ):
83
88
from glob import glob
89
+
84
90
rv = []
85
91
for p in patterns :
86
92
rv += glob (os .path .join (d , p ))
87
93
return rv
88
94
89
95
90
- with open (os .path .join (MYDIR , ' README.rst' )) as fp :
96
+ with open (os .path .join (MYDIR , " README.rst" )) as fp :
91
97
long_description = fp .read ()
92
98
93
99
# define distribution
94
100
setup_args = dict (
95
- name = ' diffpy.pdfgui' ,
96
- version = ' 3.0.5' ,
97
- packages = find_packages (os .path .join (MYDIR , ' src' )),
98
- package_dir = { '' : ' src' },
99
- include_package_data = True ,
100
- test_suite = ' diffpy.pdfgui.tests' ,
101
- entry_points = {
102
- ' gui_scripts' : [
103
- ' pdfgui=diffpy.pdfgui.applications.pdfgui:main' ,
101
+ name = " diffpy.pdfgui" ,
102
+ version = " 3.0.5" ,
103
+ packages = find_packages (os .path .join (MYDIR , " src" )),
104
+ package_dir = { "" : " src" },
105
+ include_package_data = True ,
106
+ test_suite = " diffpy.pdfgui.tests" ,
107
+ entry_points = {
108
+ " gui_scripts" : [
109
+ " pdfgui=diffpy.pdfgui.applications.pdfgui:main" ,
104
110
],
105
111
},
106
- data_files = [
107
- (' icons' , dirglob (' icons' , ' *.png' , ' *.ico' )),
108
- (' doc' , dirglob (' doc' , ' *.pdf' )),
109
- (' doc/manual' , dirglob (' doc/manual' , ' *.html' , ' *.pdf' )),
110
- (' doc/manual/images' , dirglob (' doc/manual/images' , ' *.png' )),
111
- (' doc/tutorial' , dirglob (' doc/tutorial' , '*' )),
112
+ data_files = [
113
+ (" icons" , dirglob (" icons" , " *.png" , " *.ico" )),
114
+ (" doc" , dirglob (" doc" , " *.pdf" )),
115
+ (" doc/manual" , dirglob (" doc/manual" , " *.html" , " *.pdf" )),
116
+ (" doc/manual/images" , dirglob (" doc/manual/images" , " *.png" )),
117
+ (" doc/tutorial" , dirglob (" doc/tutorial" , "*" )),
112
118
],
113
119
# manual and tutorial files should not be zipped
114
- zip_safe = False ,
115
- install_requires = [
116
- ' six' ,
117
- ' diffpy.structure>=3' ,
118
- ' diffpy.pdffit2' ,
119
- ' diffpy.utils' ,
120
+ zip_safe = False ,
121
+ install_requires = [
122
+ " six" ,
123
+ " diffpy.structure>=3" ,
124
+ " diffpy.pdffit2" ,
125
+ " diffpy.utils" ,
120
126
],
121
-
122
- author = 'Simon J.L. Billinge' ,
123
- author_email = '[email protected] ' ,
124
- maintainer = 'Pavol Juhas' ,
125
- maintainer_email = '[email protected] ' ,
126
- url = 'https://github.com/diffpy/diffpy.pdfgui' ,
127
- description = "GUI for PDF simulation and structure refinement." ,
128
- long_description = long_description ,
129
- long_description_content_type = 'text/x-rst' ,
130
- license = 'BSD' ,
131
- keywords = 'PDF structure refinement GUI' ,
132
- classifiers = [
127
+ author = "Simon J.L. Billinge" ,
128
+
129
+ maintainer = "Pavol Juhas" ,
130
+ maintainer_email = "[email protected] " ,
131
+ url = "https://github.com/diffpy/diffpy.pdfgui" ,
132
+ description = "GUI for PDF simulation and structure refinement." ,
133
+ long_description = long_description ,
134
+ long_description_content_type = "text/x-rst" ,
135
+ license = "BSD" ,
136
+ keywords = "PDF structure refinement GUI" ,
137
+ classifiers = [
133
138
# List of possible values at
134
139
# http://pypi.python.org/pypi?:action=list_classifiers
135
- ' Development Status :: 5 - Production/Stable' ,
136
- ' Environment :: MacOS X' ,
137
- ' Environment :: Win32 (MS Windows)' ,
138
- ' Environment :: X11 Applications' ,
139
- ' Intended Audience :: Science/Research' ,
140
- ' License :: OSI Approved :: BSD License' ,
141
- ' Operating System :: MacOS' ,
142
- ' Operating System :: Microsoft :: Windows' ,
143
- ' Operating System :: POSIX' ,
144
- ' Programming Language :: Python :: 2.7' ,
145
- ' Programming Language :: Python :: 3.7' ,
146
- ' Programming Language :: Python :: 3.8' ,
147
- ' Programming Language :: Python :: 3.9' ,
148
- ' Programming Language :: Python :: 3.10' ,
149
- ' Programming Language :: Python :: 3.10' ,
150
- ' Topic :: Scientific/Engineering :: Chemistry' ,
151
- ' Topic :: Scientific/Engineering :: Physics' ,
140
+ " Development Status :: 5 - Production/Stable" ,
141
+ " Environment :: MacOS X" ,
142
+ " Environment :: Win32 (MS Windows)" ,
143
+ " Environment :: X11 Applications" ,
144
+ " Intended Audience :: Science/Research" ,
145
+ " License :: OSI Approved :: BSD License" ,
146
+ " Operating System :: MacOS" ,
147
+ " Operating System :: Microsoft :: Windows" ,
148
+ " Operating System :: POSIX" ,
149
+ " Programming Language :: Python :: 2.7" ,
150
+ " Programming Language :: Python :: 3.7" ,
151
+ " Programming Language :: Python :: 3.8" ,
152
+ " Programming Language :: Python :: 3.9" ,
153
+ " Programming Language :: Python :: 3.10" ,
154
+ " Programming Language :: Python :: 3.10" ,
155
+ " Topic :: Scientific/Engineering :: Chemistry" ,
156
+ " Topic :: Scientific/Engineering :: Physics" ,
152
157
],
153
158
)
154
159
155
- if __name__ == ' __main__' :
160
+ if __name__ == " __main__" :
156
161
setup (** setup_args )
157
162
158
163
# End of file
0 commit comments