Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
164ba83
update build_locally script to avoid python setup.py develop call
ndgrigorian Oct 14, 2025
2e96092
refactor common build functionality out into separate file
ndgrigorian Oct 15, 2025
07590f7
remove --build-dir option and fix --clean option
ndgrigorian Oct 15, 2025
5b0bd76
do not return compiler root unnecessarily from resolve_compilers
ndgrigorian Oct 15, 2025
6ab378b
update gen_coverage script to align with build_locally
ndgrigorian Oct 21, 2025
df44252
resolve bin_llvm from default compiler layout when not provided
ndgrigorian Oct 28, 2025
23aad14
keep find_objects defined within main
ndgrigorian Oct 28, 2025
6ac779e
generalize err and warn utilities for different build scripts
ndgrigorian Oct 28, 2025
bfd5891
use common resolve_compilers utility
ndgrigorian Oct 28, 2025
a54e341
update gen_docs script
ndgrigorian Oct 28, 2025
0738341
try using pip install -e in place of setup.py develop in CI
ndgrigorian Oct 28, 2025
b84cdf8
use python setup.py build_ext in Cython extension building
ndgrigorian Oct 28, 2025
e675ff1
add types and descriptions for script args
ndgrigorian Oct 30, 2025
8ce292f
do not override CMAKE_ARGS in build scripts
ndgrigorian Oct 30, 2025
6b62a8e
fix typo in cmake arg
ndgrigorian Oct 30, 2025
8bfa41c
remove `--target-level-zero argument`
ndgrigorian Nov 5, 2025
ec29c49
raise RuntimeError from scripts with invalid arguments
ndgrigorian Nov 5, 2025
b0bbfb3
Update CONTRIBUTING.md
ndgrigorian Nov 6, 2025
17a09fc
Update docs and example build instructions to remove python setup.py …
ndgrigorian Nov 6, 2025
ab77357
remove adding scripts to sys.path
ndgrigorian Nov 6, 2025
82ea6d7
Use updated build scripts in CI
ndgrigorian Nov 6, 2025
d5f25cf
Merge pull request #2189 from IntelPython/use-build-scripts-in-public-ci
ndgrigorian Nov 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ jobs:
do
pushd $d
conda activate --stack ${{ env.BUILD_ENV_NAME }}
CC=icx CXX=icpx python setup.py develop -G Ninja || exit 1
CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1
conda deactivate
python -m pytest tests || exit 1
popd
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,8 @@ jobs:
source /opt/intel/oneapi/setvars.sh
wget https://github.com/vovkos/doxyrest/releases/download/doxyrest-2.1.2/doxyrest-2.1.2-linux-amd64.tar.xz
tar xf doxyrest-2.1.2-linux-amd64.tar.xz
python setup.py develop -G Ninja --build-type=Release \
-- \
-DCMAKE_C_COMPILER:PATH=$(which icx) \
-DCMAKE_CXX_COMPILER:PATH=$(which icpx) \
-DDPCTL_GENERATE_DOCS=ON \
-DDPCTL_ENABLE_DOXYREST=ON \
-DDoxyrest_DIR=`pwd`/doxyrest-2.1.2-linux-amd64 \
-DCMAKE_VERBOSE_MAKEFILE=ON
python scripts/gen_docs.py --c-compiler=$(which icx) --cxx-compiler=$(which icpx) \
--doxyrest-root=`pwd`/doxyrest-2.1.2-linux-amd64 --verbose || exit 1
python -c "import dpctl; print(dpctl.__version__)" || exit 1
pushd "$(find _skbuild -name cmake-build)" || exit 1
cmake --build . --target Sphinx || exit 1
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/os-llvm-sycl-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ jobs:
shell: bash -l {0}
run: |
source set_allvars.sh
CC=clang CXX=clang++ python setup.py develop -G Ninja
python scripts/build_locally.py --c-compiler=clang --cxx-compiler=clang++ \
--compiler-root=${SYCL_BUNDLE_FOLDER}/dpcpp_compiler/bin || exit 1

- name: Run lsplatforms
shell: bash -l {0}
Expand Down
7 changes: 2 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,8 @@ To check the code coverage for your code, follow these steps:
coverage html
```

The code coverage builds the C sources with debug symbols. For this
reason, the coverage script builds the package in `develop` mode of
`setup.py`.

The coverage results for the C and Python sources are printed to the
The code coverage builds the C sources with debug symbols, and the
coverage results for the C and Python sources are printed to the
terminal during the build (`libsyclinterface`) and pytest execution (Python).
The detailed coverage reports for the `libsyclinterface` library are saved to the
`dpctl-c-api-coverage` directory. The Python coverage reports are saved to
Expand Down
9 changes: 6 additions & 3 deletions docs/doc_sources/contributor_guides/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ To develop, run:

.. code-block:: bash

python setup.py develop -G Ninja -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx
python setup.py build_ext --inplace -G Ninja -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx
python -m pip install -e .

.. tab-item:: Windows
:sync: win

.. code-block:: bat

python setup.py develop -G Ninja -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx
python setup.py build_ext --inplace -G Ninja -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx
python -m pip install -e .


Developing can be streamlined using the driver script:
Expand Down Expand Up @@ -169,7 +171,8 @@ the relevant CMake variables, for example:

.. code-block:: bash

python setup.py develop -- -G Ninja -DCMAKE_C_COMPILER:PATH=$(which clang) -DCMAKE_CXX_COMPILER:PATH=$(which clang++)
python setup.py build_ext --inplace -G Ninja -DCMAKE_C_COMPILER:PATH=$(which clang) -DCMAKE_CXX_COMPILER:PATH=$(which clang++)
python -m pip install -e .


Or you can use the driver script:
Expand Down
9 changes: 7 additions & 2 deletions examples/cython/sycl_buffer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ oneMKL.

> **NOTE:** Make sure oneAPI is activated, $ONEAPI_ROOT must be set.

To compile the example, run:
To compile the example on Linux, run:
```bash
CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja
```
python setup.py develop

On Windows, run:
```bash
CC=icx CXX=icx python setup.py build_ext --inplace -G Ninja
```

## Running
Expand Down
8 changes: 7 additions & 1 deletion examples/cython/use_dpctl_sycl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ written in Cython.

## Building

To build the example on Linux, run:
```bash
python setup.py develop
CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja
```

On Windows, run:
```bash
CC=icx CXX=icx python setup.py build_ext --inplace -G Ninja
```

## Testing
Expand Down
17 changes: 14 additions & 3 deletions examples/pybind11/onemkl_gemv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

> **NOTE:** Install scikit-build and dpcpp before next steps.

To build, run:
```sh
python setup.py develop -- -G "Ninja" \
To build on Linux, run:
```bash
python setup.py build_ext --inplace -- -G "Ninja" \
-DCMAKE_C_COMPILER:PATH=icx \
-DCMAKE_CXX_COMPILER:PATH=icpx \
-DTBB_LIBRARY_DIR=$CONDA_PREFIX/lib \
Expand All @@ -16,6 +16,17 @@ python setup.py develop -- -G "Ninja" \
-DTBB_INCLUDE_DIR=${CONDA_PREFIX}/include
```

To build on Windows, run:
```bash
python setup.py build_ext --inplace -- -G "Ninja" \
-DCMAKE_C_COMPILER:PATH=icx \
-DCMAKE_CXX_COMPILER:PATH=icx \
-DTBB_LIBRARY_DIR=$CONDA_PREFIX/lib \
-DMKL_LIBRARY_DIR=${CONDA_PREFIX}/lib \
-DMKL_INCLUDE_DIR=${CONDA_PREFIX}/include \
-DTBB_INCLUDE_DIR=${CONDA_PREFIX}/include
```

## Running

To run the example, use:
Expand Down
167 changes: 167 additions & 0 deletions scripts/_build_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# Data Parallel Control (dpctl)
#
# Copyright 2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import shutil
import subprocess
import sys


def resolve_compilers(
oneapi: bool,
c_compiler: str,
cxx_compiler: str,
compiler_root: str,
):
is_linux = "linux" in sys.platform

if oneapi or (
c_compiler is None and cxx_compiler is None and compiler_root is None
):
return "icx", ("icpx" if is_linux else "icx")

if (
(c_compiler is None or not os.path.isabs(c_compiler))
and (cxx_compiler is None or not os.path.isabs(cxx_compiler))
and (not compiler_root or not os.path.exists(compiler_root))
):
raise RuntimeError(
"--compiler-root option must be set when using non-default DPC++ "
"layout unless absolute paths are provided for both compilers"
)

# default values
if c_compiler is None:
c_compiler = "icx"
if cxx_compiler is None:
cxx_compiler = "icpx" if is_linux else "icx"

for name, opt_name in (
(c_compiler, "--c-compiler"),
(cxx_compiler, "--cxx-compiler"),
):
if os.path.isabs(name):
path = name
else:
path = os.path.join(compiler_root, name)
if not os.path.exists(path):
raise RuntimeError(f"{opt_name} value {name} not found")
return c_compiler, cxx_compiler


def run(cmd: list[str], env: dict[str, str] = None, cwd: str = None):
print("+", " ".join(cmd))
subprocess.check_call(
cmd, env=env or os.environ.copy(), cwd=cwd or os.getcwd()
)


def capture_cmd_output(cmd: list[str], cwd: str = None):
print("+", " ".join(cmd))
return (
subprocess.check_output(cmd, cwd=cwd or os.getcwd())
.decode("utf-8")
.strip("\n")
)


def err(msg: str, script: str):
raise RuntimeError(f"[{script}] error: {msg}")


def log_cmake_args(cmake_args: list[str], script: str):
print(f"[{script}] Using CMake args:\n{' '.join(cmake_args)}")


def make_cmake_args(
c_compiler: str = None,
cxx_compiler: str = None,
level_zero: bool = True,
glog: bool = False,
verbose: bool = False,
other_opts: str = None,
):
args = [
f"-DCMAKE_C_COMPILER:PATH={c_compiler}" if c_compiler else "",
f"-DCMAKE_CXX_COMPILER:PATH={cxx_compiler}" if cxx_compiler else "",
f"-DDPCTL_ENABLE_L0_PROGRAM_CREATION={'ON' if level_zero else 'OFF'}",
f"-DDPCTL_ENABLE_GLOG:BOOL={'ON' if glog else 'OFF'}",
]

if verbose:
args.append("-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON")
if other_opts:
args.extend(other_opts.split())

return args


def build_extension(
setup_dir: str,
env: dict[str, str],
cmake_args: list[str],
cmake_executable: str = None,
generator: str = None,
build_type: str = None,
):
cmd = [sys.executable, "setup.py", "build_ext", "--inplace"]
if cmake_executable:
cmd.append(f"--cmake-executable={cmake_executable}")
if generator:
cmd.append(f"--generator={generator}")
if build_type:
cmd.append(f"--build-type={build_type}")
if cmake_args:
cmd.append("--")
cmd += cmake_args
run(
cmd,
env=env,
cwd=setup_dir,
)


def install_editable(setup_dir: str, env: dict[str, str]):
run(
[
sys.executable,
"-m",
"pip",
"install",
"-e",
".",
"--no-build-isolation",
],
env=env,
cwd=setup_dir,
)


def clean_build_dir(setup_dir: str):
if (
not isinstance(setup_dir, str)
or not setup_dir
or not os.path.isdir(setup_dir)
):
raise RuntimeError(f"Invalid setup directory provided: '{setup_dir}'")
target = os.path.join(setup_dir, "_skbuild")
if os.path.exists(target):
print(f"Cleaning build directory: {target}")
try:
shutil.rmtree(target)
except Exception as e:
print(f"Failed to remove build directory: '{target}'")
raise e
Loading
Loading