-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
121 lines (97 loc) · 4.44 KB
/
setup.py
File metadata and controls
121 lines (97 loc) · 4.44 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from __future__ import print_function
import os
import platform
import subprocess
import numpy
import setuptools
import sys
from Cython.Build import cythonize
from setuptools.command.develop import develop
from setuptools.command.install import install
from setuptools.extension import Extension
#pip install -e git+http://github.com/mazinlab/mkidreadout.git@restructure#egg=mkidreadout --src ./mkidtest
def get_virtualenv_path():
"""Used to work out path to install compiled binaries to."""
if hasattr(sys, 'real_prefix'):
return sys.prefix
if hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix:
return sys.prefix
if 'conda' in sys.prefix:
return sys.prefix
return None
def compile_and_install_software():
"""Used the subprocess module to compile/install the C software."""
#don't compile if installing on anything that's not linux
if platform.system()!='Linux':
return
src_paths = ['./mkidreadout/readout/mkidshm']
#'./mkidreadout/readout/packetmaster/']
# compile the software
cmds = ["gcc -shared -o libmkidshm.so -fPIC mkidshm.c -lrt -lpthread"]
venv = get_virtualenv_path()
try:
for cmd, src_path in zip(cmds, src_paths):
if venv:
cmd += ' --prefix=' + os.path.abspath(venv)
subprocess.check_call(cmd, cwd=src_path, shell=True)
except Exception as e:
print(str(e))
raise e
class CustomInstall(install, object):
"""Custom handler for the 'install' command."""
def run(self):
compile_and_install_software()
super(CustomInstall,self).run()
class CustomDevelop(develop, object):
"""Custom handler for the 'install' command."""
def run(self):
compile_and_install_software()
super(CustomDevelop,self).run()
extensions = [Extension(name="mkidreadout.readout.sharedmem",
sources=['mkidreadout/readout/sharedmem.pyx'],
include_dirs=[numpy.get_include(), 'mkidreadout/readout/mkidshm'],
extra_compile_args=['-shared', '-fPIC'],
library_dirs=['mkidreadout/readout/mkidshm'],
runtime_library_dirs=[os.path.abspath('mkidreadout/readout/mkidshm')],
extra_link_args=['-O3', '-lmkidshm', '-lrt', '-lpthread']),# '-Wl,-rpath=mkidreadout/readout/mkidshm']),
Extension(name="mkidreadout.readout.packetmaster",
sources=['mkidreadout/readout/pmthreads.c', 'mkidreadout/readout/packetmaster.pyx'],
include_dirs=[numpy.get_include(), 'mkidreadout/readout/packetmaster',
'mkidreadout/readout/mkidshm'],
library_dirs=['mkidreadout/readout/mkidshm'],
runtime_library_dirs=[os.path.abspath('mkidreadout/readout/mkidshm')],
extra_compile_args=['-O3', '-shared', '-fPIC'],
extra_link_args=['-lmkidshm', '-lrt', '-lpthread'])
]
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="mkidreadout",
version="0.7.1",
author="MazinLab",
author_email="mazinlab@ucsb.edu",
description="An UVOIR MKID Data Readout Package",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/MazinLab/MKIDReadout",
packages=setuptools.find_packages(),
package_data={'mkidreadout': ('config/*.yml', 'resources/firmware/*', 'resources/firfilters/*')},
scripts=['mkidreadout/channelizer/initgui.py',
'mkidreadout/channelizer/hightemplar.py',
'mkidreadout/readout/dashboard.py',
'mkidreadout/channelizer/reinitADCDAC.py',
'mkidreadout/configuration/powersweep/clickthrough_hell.py',
'mkidreadout/configuration/powersweep/ml/findResonatorsWPS.py',
'mkidreadout/configuration/sbSuppressionOptimizer.py',
'mkidreadout/configuration/processResLists.py',
'mkidreadout/configuration/beammap/sweep.py'],
ext_modules=cythonize(extensions),
classifiers=(
"Programming Language :: Python :: 2.7",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Development Status :: 1 - Planning",
"Intended Audience :: Science/Research"
),
cmdclass={'install': CustomInstall,'develop': CustomDevelop}
)