Skip to content

Commit e39f7a9

Browse files
Merge pull request #1366 from IntelPython/add-scripts-build-locally
Add scripts build locally
2 parents 26f73d5 + 0416c41 commit e39f7a9

File tree

11 files changed

+194
-124
lines changed

11 files changed

+194
-124
lines changed

0.build.sh

Lines changed: 0 additions & 73 deletions
This file was deleted.

0.env.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

1.build.bat

Lines changed: 0 additions & 11 deletions
This file was deleted.

1.env.bat

Lines changed: 0 additions & 8 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ After these steps, `dpnp` can be built in debug mode as follows:
2424
```bash
2525
git clone https://github.com/IntelPython/dpnp
2626
cd dpnp
27-
./0.build.sh
27+
python scripts/build_locally.py
2828
```
2929

3030
## Install Wheel Package from Pypi
@@ -48,7 +48,6 @@ export OCL_ICD_FILENAMES=libintelocl.so
4848

4949
## Run test
5050
```bash
51-
. ./0.env.sh
5251
pytest
5352
# or
5453
pytest tests/test_matmul.py -s -v

doc/0.builddoc.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ BUILDDOCDIR=$(dirname $(readlink -e ${BASH_SOURCE[0]}))
44
ROOTDIR=$BUILDDOCDIR/..
55

66
cd $ROOTDIR
7-
. 0.env.sh
87
python setup.py develop
98

109
cd $BUILDDOCDIR

doc/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ You can install the latest development version of DPNP from a cloned Git reposit
3434

3535
$ git clone --recursive https://github.com/IntelPython/dpnp.git
3636
$ cd dpnp
37-
$ ./0.build.sh
37+
$ python scripts/build_locally.py
3838

3939
.. note::
4040

scripts/azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
echo ========================= CI ENV ==========================================
4141
. ./scripts/set_ci_env.sh
4242
echo ========================= build DPNP ======================================
43-
./0.build.sh
43+
python scripts/build_locally.py
4444
echo ========================= run valgrind ====================================
4545
export PYTHONMALLOC=malloc
4646
valgrind --show-leak-kinds=definite --log-file=/tmp/valgrind-output \

scripts/build_locally.py

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# -*- coding: utf-8 -*-
2+
# *****************************************************************************
3+
# Copyright (c) 2016-2023, Intel Corporation
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
# - Redistributions of source code must retain the above copyright notice,
9+
# this list of conditions and the following disclaimer.
10+
# - Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24+
# THE POSSIBILITY OF SUCH DAMAGE.
25+
# *****************************************************************************
26+
27+
import os
28+
import subprocess
29+
import sys
30+
import dpctl
31+
32+
33+
def run(
34+
use_oneapi=True,
35+
build_type="Release",
36+
c_compiler=None,
37+
cxx_compiler=None,
38+
compiler_root=None,
39+
cmake_executable=None,
40+
verbose=False,
41+
cmake_opts="",
42+
):
43+
build_system = None
44+
45+
if "linux" in sys.platform:
46+
build_system = "Ninja"
47+
elif sys.platform in ["win32", "cygwin"]:
48+
build_system = "Ninja"
49+
else:
50+
assert False, sys.platform + " not supported"
51+
52+
setup_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
53+
cmake_args = [
54+
sys.executable,
55+
"setup.py",
56+
"develop",
57+
]
58+
if cmake_executable:
59+
cmake_args += [
60+
"--cmake-executable=" + cmake_executable,
61+
]
62+
dpctl_module_path = os.path.join(dpctl.get_include(), "..", "resources", "cmake")
63+
cmake_args += [
64+
"--build-type=" + build_type,
65+
"--generator=" + build_system,
66+
"--",
67+
"-DCMAKE_C_COMPILER:PATH=" + c_compiler,
68+
"-DCMAKE_CXX_COMPILER:PATH=" + cxx_compiler,
69+
"-DDPCTL_MODULE_PATH:PATH=" + dpctl_module_path,
70+
]
71+
if verbose:
72+
cmake_args += [
73+
"-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON",
74+
]
75+
if cmake_opts:
76+
cmake_args += cmake_opts.split()
77+
if use_oneapi:
78+
if "DPL_ROOT" in os.environ:
79+
os.environ["DPL_ROOT_HINT"] = os.environ["DPL_ROOT"]
80+
subprocess.check_call(
81+
cmake_args, shell=False, cwd=setup_dir, env=os.environ
82+
)
83+
84+
85+
if __name__ == "__main__":
86+
import argparse
87+
88+
parser = argparse.ArgumentParser(
89+
description="Driver to build dpnp for in-place installation"
90+
)
91+
driver = parser.add_argument_group(title="Coverage driver arguments")
92+
driver.add_argument("--c-compiler", help="Name of C compiler", default=None)
93+
driver.add_argument(
94+
"--cxx-compiler", help="Name of C++ compiler", default=None
95+
)
96+
driver.add_argument(
97+
"--oneapi",
98+
help="Set if using one-API installation",
99+
dest="oneapi",
100+
action="store_true",
101+
)
102+
driver.add_argument(
103+
"--debug",
104+
default="Release",
105+
const="Debug",
106+
action="store_const",
107+
help="Set the compilation mode to debugging",
108+
)
109+
driver.add_argument(
110+
"--compiler-root",
111+
type=str,
112+
help="Path to compiler home directory",
113+
default=None,
114+
)
115+
driver.add_argument(
116+
"--cmake-executable",
117+
type=str,
118+
help="Path to cmake executable",
119+
default=None,
120+
)
121+
driver.add_argument(
122+
"--verbose",
123+
help="Build using vebose makefile mode",
124+
dest="verbose",
125+
action="store_true",
126+
)
127+
driver.add_argument(
128+
"--cmake-opts",
129+
help="Channels through additional cmake options",
130+
dest="cmake_opts",
131+
default="",
132+
type=str,
133+
)
134+
args = parser.parse_args()
135+
136+
args_to_validate = [
137+
"c_compiler",
138+
"cxx_compiler",
139+
"compiler_root",
140+
]
141+
142+
if args.oneapi or (
143+
args.c_compiler is None
144+
and args.cxx_compiler is None
145+
and args.compiler_root is None
146+
):
147+
args.c_compiler = "icx"
148+
args.cxx_compiler = "icpx" if "linux" in sys.platform else "icx"
149+
args.compiler_root = None
150+
else:
151+
cr = args.compiler_root
152+
if isinstance(cr, str) and os.path.exists(cr):
153+
if args.c_compiler is None:
154+
args.c_compiler = "icx"
155+
if args.cxx_compiler is None:
156+
args.cxx_compiler = "icpx" if "linux" in sys.platform else "icx"
157+
else:
158+
raise RuntimeError(
159+
"Option 'compiler-root' must be provided when "
160+
"using non-default DPC++ layout."
161+
)
162+
args_to_validate = [
163+
"c_compiler",
164+
"cxx_compiler",
165+
]
166+
for p in args_to_validate:
167+
arg = getattr(args, p)
168+
assert isinstance(arg, str)
169+
if not os.path.exists(arg):
170+
arg2 = os.path.join(cr, arg)
171+
if os.path.exists(arg2):
172+
arg = arg2
173+
setattr(args, p, arg)
174+
if not os.path.exists(arg):
175+
opt_name = p.replace("_", "-")
176+
raise RuntimeError(f"Option {opt_name} value {arg} must exist.")
177+
178+
run(
179+
use_oneapi=args.oneapi,
180+
build_type=args.debug,
181+
c_compiler=args.c_compiler,
182+
cxx_compiler=args.cxx_compiler,
183+
compiler_root=args.compiler_root,
184+
cmake_executable=args.cmake_executable,
185+
verbose=args.verbose,
186+
cmake_opts=args.cmake_opts,
187+
)

scripts/install_cmake_lin.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ THEDIR=$(dirname $(readlink -e ${BASH_SOURCE[0]}))
44

55
echo ========================= install cmake ==================================
66
curl --output cmake_webimage.tar.gz \
7-
--url https://cmake.org/files/v3.19/cmake-3.19.2-Linux-x86_64.tar.gz \
7+
--url https://github.com/Kitware/CMake/releases/download/v3.26.2/cmake-3.26.2-linux-x86_64.tar.gz \
88
--retry 5 --retry-delay 5
99

1010
tar -xzf cmake_webimage.tar.gz
1111
rm -f cmake_webimage.tar.gz
1212

13-
export PATH=`pwd`/cmake-3.19.2-Linux-x86_64/bin:$PATH
13+
export PATH=`pwd`/cmake-3.26.2-linux-x86_64/bin:$PATH
1414

1515
which cmake
1616
cmake --version

0 commit comments

Comments
 (0)