-
Notifications
You must be signed in to change notification settings - Fork 23
Remove use of python setup.py develop/install
#2716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
antonwolfy
wants to merge
8
commits into
master
Choose a base branch
from
do-not-use-setup-py-develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+634
−421
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7ef7ccd
Copy _build_helper.py from dpctl scripts
antonwolfy 0634ba9
Update scripts/build_locally.py to use build helper
antonwolfy ceed662
Update the Quick start guide
antonwolfy 09db149
Remove unused build script for the rendering documentation
antonwolfy e582c3a
Update scripts/gen_coverage.py to use build helper
antonwolfy 46c1949
Add PR to the changelog
antonwolfy 6b9c18f
Support CMAKE_BUILD_TYPE=Coverage
antonwolfy 311e43c
Apply suggestions from code review
antonwolfy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,243 @@ | ||
| # ***************************************************************************** | ||
| # Copyright (c) 2026, Intel Corporation | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # - Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # - Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # - Neither the name of the copyright holder nor the names of its contributors | ||
| # may be used to endorse or promote products derived from this software | ||
| # without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
| # THE POSSIBILITY OF SUCH DAMAGE. | ||
| # ***************************************************************************** | ||
|
|
||
| import os | ||
| import shutil | ||
| import subprocess | ||
| import sys | ||
| import warnings | ||
|
|
||
|
|
||
| def get_dpctl_cmake_dir(): | ||
| """ | ||
| If dpctl is locally built using `script/build_locally.py`, it is needed | ||
| to pass the -DDpctl_ROOT=$(python -m dpctl --cmakedir) during the build. | ||
| If dpctl is conda installed, it is optional to pass this parameter. | ||
| """ | ||
|
|
||
| process = subprocess.Popen( | ||
| ["python", "-m", "dpctl", "--cmakedir"], | ||
antonwolfy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.PIPE, | ||
| ) | ||
| output, error = process.communicate() | ||
| if process.returncode == 0: | ||
| return output.decode("utf-8").strip() | ||
|
|
||
| raise RuntimeError( | ||
| "Failed to retrieve dpctl cmake directory: " | ||
| + error.decode("utf-8").strip() | ||
| ) | ||
|
|
||
|
|
||
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this logic validates |
||
| 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 resolve_onemath( | ||
| onemath: bool, | ||
| onemath_dir: str, | ||
| target_cuda: str = None, | ||
| target_hip: str = None, | ||
| onemkl_interfaces: bool = False, | ||
| onemkl_interfaces_dir: str = None, | ||
| ): | ||
| # always enable build with oneMath i/f when oneMath path is passed | ||
| if onemath_dir: | ||
| onemath = True | ||
|
|
||
| # always enable build with oneMath i/f for CUDA or HIP target | ||
| if target_cuda or target_hip: | ||
| onemath = True | ||
|
|
||
| # TODO: onemkl_interfaces and onemkl_interfaces_dir are deprecated in | ||
| # dpnp-0.19.0 and should be removed in dpnp-0.20.0. | ||
| if onemkl_interfaces: | ||
| warnings.warn( | ||
| "Using 'onemkl_interfaces' is deprecated. Please use 'onemath' instead.", | ||
| DeprecationWarning, | ||
| stacklevel=1, | ||
| ) | ||
| onemath = True | ||
| if onemkl_interfaces_dir is not None: | ||
| warnings.warn( | ||
| "Using 'onemkl_interfaces_dir' is deprecated. Please use 'onemath_dir' instead.", | ||
| DeprecationWarning, | ||
| stacklevel=1, | ||
| ) | ||
| onemath_dir = onemkl_interfaces_dir | ||
| return onemath, onemath_dir | ||
|
|
||
|
|
||
| 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, | ||
| dpctl_cmake_dir: str = None, | ||
| onemath: bool = False, | ||
| onemath_dir: str = None, | ||
| 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_ROOT={dpctl_cmake_dir}" if dpctl_cmake_dir else "", | ||
| ] | ||
|
|
||
| if onemath: | ||
| args.append("-DDPNP_USE_ONEMATH=ON") | ||
| if onemath_dir: | ||
| args.append(f"-DDPNP_ONEMATH_DIR={onemath_dir}") | ||
|
|
||
| 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 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that AMD build in dpnp are no longer supported but according to
OneMathdocs the ROCm target actitecture should be set viaHIP_TARGETShttps://uxlfoundation.github.io/oneMath/building_the_project_with_dpcpp.html#building-for-rocm