-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsetup.py
156 lines (131 loc) · 5.1 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import glob
import os.path
import subprocess
from distutils import log
from setuptools import (setup, find_packages)
from setuptools.command import (build_py, install, sdist)
PACKAGENAME = 'dqsegdb'
DESCRIPTION = 'Client library for DQSegDB'
LONG_DESCRIPTION = ''
AUTHOR = 'Ryan Fisher'
AUTHOR_EMAIL = '[email protected]'
LICENSE = 'GPLv3'
print("This version of the dqsegdb code is obsolete. Please see https://git.ligo.org/computing/dqsegdb/ for the current code.")
print("This code has been modified to prevent accidental installation of the obsolete code. You should only modify and install it if you *really* know what you're doing.")
exit()
# -- versioning ---------------------------------------------------------------
import versioneer
__version__ = versioneer.get_version()
cmdclass = versioneer.get_cmdclass()
# -- custom install with etc scripts ------------------------------------------
Install = cmdclass.pop('install', install.install)
class DQSegDBInstall(Install):
"""Extension of setuptools install to write source script for
users.
"""
shenv = os.path.join('etc', '%s-user-env.sh' % PACKAGENAME)
cshenv = os.path.join('etc', '%s-user-env.csh' % PACKAGENAME)
def finalize_options(self):
Install.finalize_options(self)
try:
etc = list(zip(*self.distribution.data_files))[0].index('etc')
except TypeError:
self.distribution.data_files = [('etc', [])]
etc = 0
except (ValueError, IndexError):
self.distribution.data_files.append(('etc', []))
etc = 0
self.data_files = self.distribution.data_files[etc][1]
def _get_install_paths(self):
"""Internal utility to get install and library paths for install.
"""
installpath = self.install_scripts
if self.install_purelib == self.install_platlib:
pythonpath = self.install_purelib
else:
pythonpath = os.pathsep.join([self.install_platlib,
self.install_purelib])
if self.root:
installpath = os.path.normpath(installpath.replace(self.root, ''))
pythonpath = os.path.normpath(pythonpath.replace(self.root, ''))
return installpath, pythonpath
def write_env_sh(self, fp=shenv):
"""Write the shell environment script for DQSegDB.
Parameters
----------
fp : `str`
path (relative to install prefix) of output csh file
"""
installpath, pythonpath = self._get_install_paths()
with open(fp, 'w') as env:
print('#!/bin/sh\n', file=env)
print('PATH=%s:${PATH}' % (installpath), file=env)
print('export PATH', file=env)
print('PYTHONPATH=%s:${PYTHONPATH}' % (pythonpath), file=env)
print('export PYTHONPATH', file=env)
self.data_files.append(fp)
def write_env_csh(self, fp=cshenv):
"""Write the shell environment script for DQSegDB.
Parameters
----------
fp : `str`
path (relative to install prefix) of output csh file
"""
installpath, pythonpath = self._get_install_paths()
with open(fp, 'w') as env:
print('setenv PATH %s:${PATH}' % (installpath), file=env)
print('setenv PYTHONPATH %s:${PYTHONPATH}' % (pythonpath),
file=env)
self.data_files.append(fp)
def run(self):
self.write_env_sh()
self.write_env_csh()
Install.run(self)
if not self.root:
print("\n--------------------------------------------------")
print("DQSegDB has been installed.")
print("If you are running csh, you can set your environment by "
"running:\n")
print("source %s\n" % os.path.join(self.install_base, self.cshenv))
print("Otherwise, you can run:\n")
print("source %s" % os.path.join(self.install_base, self.shenv))
print("--------------------------------------------------")
run.__doc__ = Install.__doc__
cmdclass['install'] = DQSegDBInstall
# -- setup ---------------------------------------------------------------------
# Use the find_packages tool to locate all packages and modules
packagenames = find_packages()
# glob for all scripts
if os.path.isdir('bin'):
scripts = glob.glob(os.path.join('bin', '*'))
else:
scripts = []
setup(name=PACKAGENAME,
cmdclass=cmdclass,
version=__version__,
description=DESCRIPTION,
url="http://www.lsc-group.phys.uwm.edu/daswg/",
packages=packagenames,
ext_modules=[],
scripts=scripts,
setup_requires=['setuptools'],
install_requires=[
'gwdatafind',
'lalsuite',
'ligo-segments',
'lscsoft-glue>=1.55.0',
'pyOpenSSL>=0.14',
'pyRXP',
],
provides=[PACKAGENAME],
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
long_description=LONG_DESCRIPTION,
zip_safe=False,
use_2to3=False
)