forked from ganymede42/h5pyViewer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·182 lines (158 loc) · 6.09 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#! /usr/bin/env python
# FOR DISTUTILS READ:
# http://docs.python.org/2/distutils/index.html
import distutils.core
import distutils.command.install_lib, distutils.command.install
import re
import sys, os, platform, subprocess
# python setup.py --help-commands
# python setup.py --help
# python setup.py --name --version --fullname --author --author-email --maintainer --maintainer-email --contact --contact-email \
# --url --license --description --long-description --platforms --classifiers --keywords --provides --requires --obsoletes
# python setup.py build
# python setup.py build
# python setup.py install --prefix=~/
# python setup.py bdist_egg
# python setup.py install --root tmp
# python setup.py bdist --formats=wininst
# python setup.py bdist_wininst
# python setup.py bdist
# Command Line : --help-commands
# Standard commands:
# build build everything needed to install
# build_py "build" pure Python modules (copy to build directory)
# build_ext build C/C++ extensions (compile/link to build directory)
# build_clib build C/C++ libraries used by Python extensions
# build_scripts "build" scripts (copy and fixup #! line)
# clean clean up temporary files from 'build' command
# install install everything from build directory
# install_lib install all Python modules (extensions and pure Python)
# install_headers install C/C++ header files
# install_scripts install scripts (Python or otherwise)
# install_data install data files
# sdist create a source distribution (tarball, zip file, etc.)
# register register the distribution with the Python package index
# bdist create a built (binary) distribution
# bdist_dumb create a "dumb" built distribution
# bdist_rpm create an RPM distribution
# bdist_wininst create an executable installer for MS Windows
# upload upload binary package to PyPI
# check perform some checks on the package
def getVersion():
# for dirname, dirnames, filenames in os.walk('.'):
# for subdirname in dirnames:
# print os.path.join(dirname, subdirname)
# for filename in filenames:
# print os.path.join(dirname, filename)
fn = "./PKG-INFO"
if os.access(fn, os.R_OK):
sys.stdout.write("getVersion() -> Parsing " + fn + " -> ")
fo = open(fn, "r")
for ln in fo.readlines():
if ln.startswith("Version:"):
ver = re.match("Version:\s*(\S*)", ln).group(1)
elif ln.startswith("Summary:"):
# print ln
gitcmt = re.search("\(git:(.*)\)", ln).group(1)
fo.close()
else:
argv = sys.argv
sys.stdout.write("getVersion() -> using git command -> ")
# p = subprocess.Popen('git rev-list HEAD', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# retval = p.wait()
# res=p.stdout.readlines()
# ver=len(res)
# ver='0.0.0.'+str(ver)
# gitcmt=res[0][:7]
p = subprocess.Popen("git describe --match " "v*.*.*" " --long", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,)
retval = p.wait()
res = str(p.stdout.readline())
res = res[1:-1].rsplit("-", 1)
ver = res[0].replace("-", ".")
gitcmt = res[1][1:]
print(":{}:{}:".format(ver, gitcmt))
return (ver, gitcmt)
class MyINSTALL(distutils.command.install.install):
def run(self):
distutils.command.install.install.run(self)
print("post_install_message")
class MyINSTALL_LIB(distutils.command.install_lib.install_lib):
def run(self):
print("MyINSTALL_LIB.run()")
distutils.command.install_lib.install_lib.run(self)
instDir = os.path.join(self.install_dir, "h5pyViewerLib")
binDir = self.distribution.command_obj["install"].install_scripts
print(("instDir", instDir, "binDir", binDir))
if platform.system() == "Linux":
mod = 0o755
for fn in (
"h5pyViewer",
"hdfAttrib",
"hdfGrid",
"hdfImageGL",
"hdfImage",
"hdfTree",
):
fnInst = os.path.join(instDir, fn + ".py")
fnBin = os.path.join(binDir, fn)
print(("chmod %o " % mod + fnInst))
print(("symlink %s->%s " % (fnInst, fnBin)))
os.chmod(fnInst, mod)
if os.path.islink(fnBin):
os.unlink(fnBin)
os.symlink(fnInst, fnBin)
pass
def runSetup(**kv):
ver = getVersion()
args = {
"cmdclass": {"install_lib": MyINSTALL_LIB},
"name": "h5pyViewer",
"version": ver[0],
"description": "(git:" + ver[1] + ") HDF5-File-Viewer",
"author": "Thierry Zamofing",
"author_email": "thierry.zamofing@psi.ch",
"maintainer": "Thierry Zamofing",
"maintainer_email": "thierry.zamofing@psi.ch",
"url": "www.psi.ch",
"license": "BSD",
"long_description": open("README.rst", "r").read(),
"platforms": ["Linux", "Windows"],
"packages": ["h5pyViewerLib"],
"package_data": {"h5pyViewerLib": ["images/*.png", "images/*.ico"]},
"requires": ["ctypes", "h5py", "numpy", "matplotlib"],
}
if kv:
args.update(kv)
distutils.core.setup(**args)
print("done")
pass
def main():
argv = sys.argv
if "debug" in argv:
script_args = [
"--name",
"--version",
"--fullname",
"--author",
"--author-email",
"--maintainer",
"--maintainer-email",
"--contact",
"--contact-email",
"--url",
"--license",
"--description",
"--long-description",
"--platforms",
"--classifiers",
"--keywords",
"--provides",
"--requires",
"--obsoletes",
]
runSetup(script_args=script_args)
else:
runSetup()
pass
if __name__ == "__main__":
main()