-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·142 lines (118 loc) · 3.83 KB
/
setup
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
#!/usr/bin/env python3
"""Setup CLI script"""
import os
import subprocess
import click
# Import from local bin
from bin.boost import boost_build, boost_clean
from bin.cbox import cbox_clean
def get_options(
with_cbox, with_pyarrow, with_zarr, with_dask, with_server, enable_analysis
):
options = ""
if with_cbox:
options = options + " --with-cbox"
if with_pyarrow:
options = options + " --with-zarr"
if with_zarr:
options = options + " --with-zarr"
if with_dask:
options = options + " --with-dask"
if with_server:
options = options + " --with-server"
if enable_analysis:
options = options + " --enable-analysis"
return options
@click.group(name="setup")
def setup():
"""Setup toolkit for BoxKit"""
@setup.command(name="depends")
@click.option("--keep-artifacts", is_flag=True, help="Preserve build artifacts")
def depends(keep_artifacts):
"""Build dependencies for the Python library"""
boost_build()
if not keep_artifacts:
boost_clean()
@setup.command(name="develop")
@click.option("--with-cbox", is_flag=True, help="With C++ backend")
@click.option("--with-pyarrow", is_flag=True, help="With pyarrow data backend")
@click.option("--with-zarr", is_flag=True, help="With zarr data backend")
@click.option("--with-dask", is_flag=True, help="With dask data/parallel backend")
@click.option("--with-server", is_flag=True, help="With remote server utility")
@click.option("--enable-analysis", is_flag=True, help="Enable analysis mode")
def develop(
with_cbox, with_pyarrow, with_zarr, with_dask, with_server, enable_analysis
):
"""
\b
Development mode
\b
Environment variables for building C++ backend
CXX : C++ compiler (clang++, g++)
BOOST_INCLUDE_DIR : Path to boost/python.hpp
BOOST_LIB_DIR : Path to libboost_python.so, libbboost_python.dylib
"""
options = get_options(
with_cbox, with_pyarrow, with_zarr, with_dask, with_server, enable_analysis
)
subprocess.run(
f"python3 setup.py develop --user {options}",
shell=True,
check=True,
executable="/bin/bash",
)
@setup.command(name="install")
@click.option("--with-cbox", is_flag=True, help="With C++ backend")
@click.option("--with-pyarrow", is_flag=True, help="With pyarrow data backend")
@click.option("--with-zarr", is_flag=True, help="With zarr data backend")
@click.option("--with-dask", is_flag=True, help="With dask data/parallel backend")
@click.option("--with-server", is_flag=True, help="With remote server utility")
@click.option("--enable-analysis", is_flag=True, help="Enable analysis mode")
def install(
with_cbox,
with_pyarrow,
with_zarr,
with_dask,
with_server,
enable_analysis,
):
"""Installation command"""
options = get_options(
with_cbox, with_pyarrow, with_zarr, with_dask, with_server, enable_analysis
)
subprocess.run(
f"python3 setup.py develop --user",
shell=True,
check=True,
executable="/bin/bash",
)
subprocess.run(
f"python3 setup.py build",
shell=True,
check=True,
executable="/bin/bash",
)
subprocess.run(
f"python3 setup.py install --user {options}",
shell=True,
check=True,
executable="/bin/bash",
)
@setup.command(name="publish")
def publish():
"""Publish PyPi package"""
subprocess.run(
"python3 setup.py sdist", shell=True, check=True, executable="/bin/bash"
)
subprocess.run(
"twine upload dist/* --verbose", shell=True, check=True, executable="/bin/bash"
)
@setup.command(name="clean")
def clean():
"""Clean installation artifacts"""
subprocess.run(
"rm -rf *.egg-info build dist", shell=True, check=True, executable="/bin/bash"
)
cbox_clean()
if __name__ == "__main__":
setup()