-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
109 lines (96 loc) · 3.77 KB
/
setup.py
File metadata and controls
109 lines (96 loc) · 3.77 KB
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
#!/usr/bin/env python3
from __future__ import print_function
from setuptools import setup
import sys
import os
import shutil
import errno
from glob import glob
MAIN_VERSION = '0.8.0a1'
if not ( "--help" in sys.argv):
if ("install" in sys.argv) or ("sdist" in sys.argv) or ("bdist_wheel" in sys.argv):
# check that we have write access to zgoubi/version.py
try:
f = open("zgoubi/version.py","w")
f.close()
f =open("install.log","w")
f.close()
f =open("build/lib/zgoubi/version.py","w")
f.close()
os.remove("build/lib/zgoubi/version.py")
except IOError as exc:
if exc.errno == errno.EACCES:
print("ERROR: Permission denied updating zgoubi/version.py, build and/or install.log.\nIf they are owned by root, due to previously running install as root please remove them (eg. sudo ./setup.py clean --all ; sudo rm install.log zgoubi/version.py).")
exit(1)
vfile = open("zgoubi/version.py","w")
vfile.write("#!/usr/bin/env python\n")
vfile.write("MAIN_VERSION = '%s'\n"%MAIN_VERSION)
vfile.close()
setup(name='pyzgoubi',
version=MAIN_VERSION,
packages=['zgoubi'],
scripts=['pyzgoubi'],
#package_data={'zgoubi': ['defs/*.py', 'defs/*.defs']},
data_files=[
#('share/pyzgoubi/definitions',glob('defs/*')),
('share/pyzgoubi/examples',glob('examples/*')),
('share/pyzgoubi/test',glob('tests/*.py')),
# ('share/pyzgoubi/doc', glob('doc'))
],
author="Sam Tygier",
author_email="sam.tygier@manchester.ac.uk",
url="http://sourceforge.net/projects/pyzgoubi/",
license="GNU GENERAL PUBLIC LICENSE",
description="PyZgoubi is an interface to the Zgoubi particle tracker written in python.",
classifiers=["Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Physics",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Programming Language :: Python :: 3.7"
"Programming Language :: Python :: 3.8"
"Programming Language :: Python :: 3.9"
],
# install_requires tends to install new versions, even if not needed, so comment out
#install_requires=["numpy>=1.8.0", "scipy>=0.13.0", "matplotlib>=1.2.0"],
)
if ("install" in sys.argv) and not ( "--help" in sys.argv):
#find the log
try:
logfile = [x for x in sys.argv if x.startswith('--record')][-1]
#strip away quotes, and expand path
logfile = logfile.split('=')[-1].strip('"\'')
logfile = os.path.expanduser(logfile)
except IndexError:
logfile = "install.log"
try:
for line in open(logfile):
line = line.strip()
if line.endswith("bin/pyzgoubi"):
bin_path = os.path.dirname(line)
if line.endswith("Scripts\pyzgoubi"):
bin_path = line.rpartition('\\')[0]
if line.endswith("zgoubi/__init__.py"):
lib_path = os.path.normpath(os.path.join(os.path.dirname(line),".."))
if line.endswith("zgoubi\__init__.py"):
lib_path = line.rpartition('\\')[0].rpartition('\\')[0]
except IOError:
print("Could not see install log, install may have failed.")
print("Can't give help with setting up path")
sys.exit(1)
if lib_path.endswith(".egg"):
lib_path = os.path.dirname(lib_path)
try:
if sys.platform == "win32":
print("Add the following to your PATH variable in user Environment Variables control panel")
#print "export PYTHONPATH=$PYTHONPATH:%s"%lib_path
print(bin_path)
bat_file = open(os.path.join( bin_path, "pyzgoubi.bat"), "w")
bat_file.write("set PYTHONPATH=%%PYTHONPATH%%;%s\n"%lib_path)
bat_file.write("python %s\\pyzgoubi %%*\n"%bin_path)
bat_file.close()
else:
print("\nyou may need to add the following to your .bashrc")
print("export PYTHONPATH=%s:$PYTHONPATH"%lib_path)
print("export PATH=%s:$PATH"%bin_path)
except NameError:
print("Could not find all paths in logfile")