1515
1616# Use this version when git data are not available, like in git zip archive.
1717# Update when tagging a new release.
18- FALLBACK_VERSION = ' 2.0.4'
18+ FALLBACK_VERSION = " 2.0.4"
1919
2020# determine if we run with Python 3.
21- PY3 = ( sys .version_info [0 ] == 3 )
21+ PY3 = sys .version_info [0 ] == 3
2222
2323# versioncfgfile holds version data for git commit hash and date.
2424# It must reside in the same directory as version.py.
2525MYDIR = 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+
2829
2930def gitinfo ():
3031 from subprocess import Popen , PIPE
32+
3133 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 )
3335 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 )
3537 glog = proc .stdout .read ()
3638 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 )
3941 return rv
4042
4143
@@ -44,19 +46,19 @@ def getversioncfg():
4446 from configparser import RawConfigParser
4547 else :
4648 from ConfigParser import RawConfigParser
47- vd0 = dict (version = FALLBACK_VERSION , commit = '' , date = '' , timestamp = 0 )
49+ vd0 = dict (version = FALLBACK_VERSION , commit = "" , date = "" , timestamp = 0 )
4850 # first fetch data from gitarchivecfgfile, ignore if it is unexpanded
4951 g = vd0 .copy ()
5052 cp0 = RawConfigParser (vd0 )
5153 cp0 .read (gitarchivecfgfile )
52- if len (cp0 .get (' DEFAULT' , ' commit' )) > 20 :
54+ if len (cp0 .get (" DEFAULT" , " commit" )) > 20 :
5355 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" ))
5557 if mx :
56- g [' version' ] = mx .group (1 )
58+ g [" version" ] = mx .group (1 )
5759 # 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 :
6062 try :
6163 g = gitinfo ()
6264 except OSError :
@@ -65,94 +67,97 @@ def getversioncfg():
6567 cp = RawConfigParser ()
6668 cp .read (versioncfgfile )
6769 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+ )
7074 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 :
7680 cp .write (fp )
7781 return cp
7882
83+
7984versiondata = getversioncfg ()
8085
8186
8287def dirglob (d , * patterns ):
8388 from glob import glob
89+
8490 rv = []
8591 for p in patterns :
8692 rv += glob (os .path .join (d , p ))
8793 return rv
8894
8995
90- with open (os .path .join (MYDIR , ' README.rst' )) as fp :
96+ with open (os .path .join (MYDIR , " README.rst" )) as fp :
9197 long_description = fp .read ()
9298
9399# define distribution
94100setup_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" ,
104110 ],
105111 },
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" , "*" )),
112118 ],
113119 # 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" ,
120126 ],
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 = [
133138 # List of possible values at
134139 # 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" ,
152157 ],
153158)
154159
155- if __name__ == ' __main__' :
160+ if __name__ == " __main__" :
156161 setup (** setup_args )
157162
158163# End of file
0 commit comments