Skip to content

Commit f14fac0

Browse files
committed
update setup script
1 parent 1231851 commit f14fac0

File tree

6 files changed

+98
-90
lines changed

6 files changed

+98
-90
lines changed

AUTHORS.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
Xiaohao Yang
1+
This code is developed by:
2+
3+
Xiaohao Yang
4+
5+
This code was developed as part of the xPDFsuite project to create software
6+
and tools for general researchers to use PDF in their work. For more
7+
information on the DiffPy project email sb2896@columbia.edu

LICENSENOTICE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ prohibited. If you don’t know whether or not your anticipated use is under
55
a license, you must contact Prof. Simon Billinge at sb2896@columbia.edu.
66
Use of this software without a license is prohibited.
77

8-
Copyright 2009-2014, Trustees of Columbia University in the City of New York.
8+
Copyright 2009-2016, Trustees of Columbia University in the City of New York.
99

1010

1111
For more information please email Prof. Simon Billinge at sb2896@columbia.edu

README.rst

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,30 @@ The dpx.srxplanargui requires Python 2.7 and the following software:
1010

1111
* ``diffpy.srxplanar``
1212
* ``dpx.confutils``
13-
* ``dpx.srxplanargui``
1413
* ``numpy``
14+
* ``scipy``
1515
* ``traits``
1616
* ``traitsui``
1717
* ``chaco``
18-
* ``mayavi``
1918

20-
To enable calibrant image calibration function, following packages are required:
19+
The image integration (diffpy.srxplanargui) requires
2120

22-
* ``pyFAI``
23-
* ``FabIO``
21+
* ``fabio``
22+
* ``pyfai``
2423
* ``matplotlib``
2524

26-
BACKENDS
27-
------------------------------------------------------------------------
28-
29-
SrXplanargui can use both WX and Qt backends. Please note that traitsui has
30-
compatibility issuses with WX>2.8. It only works with WX 2.8. So it is strongly
31-
recommonded to use QT backend (default). Especailly for MacOSX which the WX2.8 is not
32-
available for the latest distribution.
33-
34-
WX backend requires:
35-
* ``wxpython=2.8``
36-
37-
Qt backend requires:
38-
* ``pyQt``
39-
or
40-
* ``pyside``
41-
42-
If you would like to use image calibration function in pyFAI, please note that
43-
pyside may not work and you probably need to switch to pyQt.
44-
45-
To start SrXplanargui using different backend, use
46-
47-
srxplanargui --toolkit backend
48-
49-
where backend could be "wx" or "qt"
50-
5125
INSTALLATION
5226
------------------------------------------------------------------------
5327

54-
To install the dpx.pdfgetxgui package:
28+
We are going to release conda package for all platform. For general user
29+
please use the installation file and install software. For developor,
30+
you can install dpx.srxplanargui using
5531

5632
python setup.py install
33+
34+
Note: the dependency is not specified in the setup.py. You need to install
35+
them yourself. You can use Anaconda or other python enviroment.
5736

58-
By default the files are installed in the system directories, which are
59-
usually only writeable by the root. See the usage info "./setup.py install
60-
--help" for options to install as a normal user under a different location.
61-
Note that installation to non-standard directories you may require adjustments
62-
to the PATH and PYTHONPATH environment variables.
6337

6438
CONTACTS
6539
------------------------------------------------------------------------
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[DEFAULT]
2+
commit = $Format:%H$
3+
date = $Format:%ai$
4+
timestamp = $Format:%at$
5+
refnames = $Format:%D$

setup.cfg

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.py

Lines changed: 75 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,70 @@
1010
"""
1111

1212
import os
13-
import glob
1413
from setuptools import setup, find_packages
14+
from setuptools.command.build_py import build_py
15+
import py_compile
16+
17+
18+
class custom_build_pyc(build_py):
19+
20+
def byte_compile(self, files):
21+
for file in files:
22+
if file.endswith('.py'):
23+
py_compile.compile(file)
24+
os.unlink(file)
25+
26+
# Use this version when git data are not available, like in git zip archive.
27+
# Update when tagging a new release.
28+
FALLBACK_VERSION = '1.0'
1529

1630
# versioncfgfile holds version data for git commit hash and date.
1731
# It must reside in the same directory as version.py.
1832
MYDIR = os.path.dirname(os.path.abspath(__file__))
1933
versioncfgfile = os.path.join(MYDIR, 'dpx', 'srxplanargui', 'version.cfg')
20-
defaultversion = '1.0'
34+
gitarchivecfgfile = versioncfgfile.replace('version.cfg', 'gitarchive.cfg')
35+
2136

2237
def gitinfo():
2338
from subprocess import Popen, PIPE
2439
kw = dict(stdout=PIPE, cwd=MYDIR)
25-
rv = {}
2640
proc = Popen(['git', 'describe', '--match=v[[:digit:]]*'], **kw)
2741
desc = proc.stdout.read()
2842
proc = Popen(['git', 'log', '-1', '--format=%H %at %ai'], **kw)
2943
glog = proc.stdout.read()
30-
if desc != '':
31-
rv['version'] = desc.strip().split('-')[0].lstrip('v')
32-
else:
33-
rv['version'] = defaultversion
34-
if glog != '':
35-
rv['commit'], rv['timestamp'], rv['date'] = glog.strip().split(None, 2)
36-
else:
37-
rv['commit'], rv['timestamp'], rv['date'] = 'no git', 'no git', 'no git'
44+
rv = {}
45+
rv['version'] = '.post'.join(desc.strip().split('-')[:2]).lstrip('v')
46+
rv['commit'], rv['timestamp'], rv['date'] = glog.strip().split(None, 2)
3847
return rv
3948

4049

4150
def getversioncfg():
42-
from ConfigParser import SafeConfigParser
43-
cp = SafeConfigParser()
44-
cp.read(versioncfgfile)
51+
import re
52+
from ConfigParser import RawConfigParser
53+
vd0 = dict(version=FALLBACK_VERSION, commit='', date='', timestamp=0)
54+
# first fetch data from gitarchivecfgfile, ignore if it is unexpanded
55+
g = vd0.copy()
56+
cp0 = RawConfigParser(vd0)
57+
cp0.read(gitarchivecfgfile)
58+
if '$Format:' not in cp0.get('DEFAULT', 'commit'):
59+
g = cp0.defaults()
60+
mx = re.search(r'\btag: v(\d[^,]*)', g.pop('refnames'))
61+
if mx:
62+
g['version'] = mx.group(1)
63+
# then try to obtain version data from git.
4564
gitdir = os.path.join(MYDIR, '.git')
46-
if not os.path.isdir(gitdir):
47-
# not a git repo
48-
cp.set('DEFAULT', 'version', defaultversion)
49-
cp.set('DEFAULT', 'commit', 'no git')
50-
cp.set('DEFAULT', 'date', 'no git')
51-
cp.set('DEFAULT', 'timestamp', 'no git')
52-
cp.write(open(versioncfgfile, 'w'))
53-
try:
54-
g = gitinfo()
55-
except OSError:
56-
return cp
65+
if os.path.exists(gitdir) or 'GIT_DIR' in os.environ:
66+
try:
67+
g = gitinfo()
68+
except OSError:
69+
pass
70+
# finally, check and update the active version file
71+
cp = RawConfigParser()
72+
cp.read(versioncfgfile)
5773
d = cp.defaults()
58-
if g['version'] != d.get('version') or g['commit'] != d.get('commit'):
74+
rewrite = not d or (g['commit'] and (
75+
g['version'] != d.get('version') or g['commit'] != d.get('commit')))
76+
if rewrite:
5977
cp.set('DEFAULT', 'version', g['version'])
6078
cp.set('DEFAULT', 'commit', g['commit'])
6179
cp.set('DEFAULT', 'date', g['date'])
@@ -65,29 +83,38 @@ def getversioncfg():
6583

6684
versiondata = getversioncfg()
6785

86+
87+
def dirglob(d, *patterns):
88+
from glob import glob
89+
rv = []
90+
for p in patterns:
91+
rv += glob(os.path.join(d, p))
92+
return rv
93+
6894
# define distribution
6995
setup_args = dict(
70-
name='dpx.srxplanargui',
71-
version=versiondata.get('DEFAULT', 'version'),
72-
namespace_packages=['dpx'],
73-
packages=find_packages(),
74-
include_package_data=True,
75-
zip_safe=False,
76-
entry_points={
77-
# define console_scripts here, see setuptools docs for details.
78-
'console_scripts' : ['srxgui = dpx.srxplanargui.srxguiapp:main',
79-
],
80-
},
81-
82-
author='Simon J.L. Billinge',
83-
author_email='sb2896@columbia.edu',
84-
description='PDFgetXgui, a software for PDF transformation and visualization',
85-
maintainer='Xiaohao Yang',
86-
maintainer_email='xiaohao.yang@outlook.com',
87-
license='see LICENSENOTICE.txt',
88-
url='',
89-
keywords='2D powder diffraction image integration uncertainty propagation',
90-
classifiers=[
96+
name='dpx.srxplanargui',
97+
cmdclass=dict(build_py=custom_build_pyc),
98+
version=versiondata.get('DEFAULT', 'version'),
99+
namespace_packages=['dpx'],
100+
packages=find_packages(),
101+
include_package_data=True,
102+
zip_safe=False,
103+
entry_points={
104+
# define console_scripts here, see setuptools docs for details.
105+
'console_scripts': ['srxgui = dpx.srxplanargui.srxguiapp:main',
106+
],
107+
},
108+
109+
author='Simon J.L. Billinge',
110+
author_email='sb2896@columbia.edu',
111+
description='xPDFsuite, a software for PDF transformation and visualization',
112+
maintainer='Xiaohao Yang',
113+
maintainer_email='sodestiny1@gmail.com',
114+
license='see LICENSENOTICE.txt',
115+
url='',
116+
keywords='2D powder diffraction image integration uncertainty propagation',
117+
classifiers=[
91118
# List of possible values at
92119
# http://pypi.python.org/pypi?:action=list_classifiers
93120
'Development Status :: 5 - Production/Stable',
@@ -101,7 +128,7 @@ def getversioncfg():
101128
'Programming Language :: Python :: 2.6',
102129
'Programming Language :: Python :: 2.7',
103130
'Topic :: Scientific/Engineering :: Physics',
104-
],
131+
],
105132
)
106133

107134
if __name__ == '__main__':

0 commit comments

Comments
 (0)