-
Notifications
You must be signed in to change notification settings - Fork 31
Remove use of python setup.py develop/install in the project
#2172
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
ndgrigorian
wants to merge
20
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.
+709
−526
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9b7deae
update build_locally script to avoid python setup.py develop call
ndgrigorian 70e4638
refactor common build functionality out into separate file
ndgrigorian d7e561e
remove --build-dir option and fix --clean option
ndgrigorian 365cd43
do not return compiler root unnecessarily from resolve_compilers
ndgrigorian 4a3ab99
update gen_coverage script to align with build_locally
ndgrigorian 268351f
resolve bin_llvm from default compiler layout when not provided
ndgrigorian 181a51b
keep find_objects defined within main
ndgrigorian 5b4c927
generalize err and warn utilities for different build scripts
ndgrigorian 136d318
use common resolve_compilers utility
ndgrigorian 775394e
update gen_docs script
ndgrigorian 08d9cd3
try using pip install -e in place of setup.py develop in CI
ndgrigorian 0e0c1ba
use python setup.py build_ext in Cython extension building
ndgrigorian 7c8e35e
add types and descriptions for script args
ndgrigorian 1800644
do not override CMAKE_ARGS in build scripts
ndgrigorian 4339291
fix typo in cmake arg
ndgrigorian f3eb33a
remove `--target-level-zero argument`
ndgrigorian b50b8af
raise RuntimeError from scripts with invalid arguments
ndgrigorian ad31a0d
Update CONTRIBUTING.md
ndgrigorian 5db0cce
Update docs and example build instructions to remove python setup.py …
ndgrigorian 63455ce
remove adding scripts to sys.path
ndgrigorian 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 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 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 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 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,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 | ||
ndgrigorian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| 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.
Uh oh!
There was an error while loading. Please reload this page.