-
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
22
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.
Open
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 2e96092
refactor common build functionality out into separate file
ndgrigorian 07590f7
remove --build-dir option and fix --clean option
ndgrigorian 5b0bd76
do not return compiler root unnecessarily from resolve_compilers
ndgrigorian 6ab378b
update gen_coverage script to align with build_locally
ndgrigorian df44252
resolve bin_llvm from default compiler layout when not provided
ndgrigorian 23aad14
keep find_objects defined within main
ndgrigorian 6ac779e
generalize err and warn utilities for different build scripts
ndgrigorian bfd5891
use common resolve_compilers utility
ndgrigorian a54e341
update gen_docs script
ndgrigorian 0738341
try using pip install -e in place of setup.py develop in CI
ndgrigorian b84cdf8
use python setup.py build_ext in Cython extension building
ndgrigorian e675ff1
add types and descriptions for script args
ndgrigorian 8ce292f
do not override CMAKE_ARGS in build scripts
ndgrigorian 6b62a8e
fix typo in cmake arg
ndgrigorian 8bfa41c
remove `--target-level-zero argument`
ndgrigorian ec29c49
raise RuntimeError from scripts with invalid arguments
ndgrigorian b0bbfb3
Update CONTRIBUTING.md
ndgrigorian 17a09fc
Update docs and example build instructions to remove python setup.py …
ndgrigorian ab77357
remove adding scripts to sys.path
ndgrigorian 82ea6d7
Use updated build scripts in CI
ndgrigorian d5f25cf
Merge pull request #2189 from IntelPython/use-build-scripts-in-public-ci
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.