From fa54b08cd5fbea939e55e15bbc7b3c93408c244e Mon Sep 17 00:00:00 2001 From: Klaus Zimmermann Date: Mon, 29 Sep 2025 10:37:14 +0200 Subject: [PATCH] Replace setup.py install with pip install (#156711) #156027 already replaced most use of `python setup.py install`. This PR only adds a few more occurrences and adds `--no-build-isolation` in a few places. Pull Request resolved: https://github.com/pytorch/pytorch/pull/156711 Approved by: https://github.com/atalman --- .ci/manywheel/build_libtorch.sh | 2 +- .ci/pytorch/test.sh | 2 +- benchmarks/operator_benchmark/README.md | 2 +- test/test_cpp_extensions_aot.py | 3 ++- torch/testing/_internal/common_utils.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.ci/manywheel/build_libtorch.sh b/.ci/manywheel/build_libtorch.sh index 4de775b1823c..d78fbd5c3ed3 100644 --- a/.ci/manywheel/build_libtorch.sh +++ b/.ci/manywheel/build_libtorch.sh @@ -104,7 +104,7 @@ if [[ "$DESIRED_CUDA" == *"rocm"* ]]; then export ROCclr_DIR=/opt/rocm/rocclr/lib/cmake/rocclr fi -echo "Calling 'python -m pip install .' at $(date)" +echo "Calling -m pip install . -v --no-build-isolation at $(date)" if [[ $LIBTORCH_VARIANT = *"static"* ]]; then STATIC_CMAKE_FLAG="-DTORCH_STATIC=1" diff --git a/.ci/pytorch/test.sh b/.ci/pytorch/test.sh index b44836867977..316eea7c073e 100755 --- a/.ci/pytorch/test.sh +++ b/.ci/pytorch/test.sh @@ -1617,7 +1617,7 @@ test_operator_benchmark() { test_inductor_set_cpu_affinity cd benchmarks/operator_benchmark/pt_extension - python -m pip install . + python -m pip install . -v --no-build-isolation cd "${TEST_DIR}"/benchmarks/operator_benchmark $TASKSET python -m benchmark_all_test --device "$1" --tag-filter "$2" \ diff --git a/benchmarks/operator_benchmark/README.md b/benchmarks/operator_benchmark/README.md index 0a8ad5846bf2..b4556d908d7d 100644 --- a/benchmarks/operator_benchmark/README.md +++ b/benchmarks/operator_benchmark/README.md @@ -20,7 +20,7 @@ Key Features: The instruction below installs a cpp\_extension for PyTorch and it is required to run the benchmark suite. ```bash cd pt_extension -python -m pip install . +python -m pip install . -v --no-build-isolation ``` ## How to run the benchmarks: diff --git a/test/test_cpp_extensions_aot.py b/test/test_cpp_extensions_aot.py index 2f69bcfeb9c4..8ad4882e15ec 100644 --- a/test/test_cpp_extensions_aot.py +++ b/test/test_cpp_extensions_aot.py @@ -148,7 +148,8 @@ class TestCppExtensionAOT(common.TestCase): @unittest.skipIf(IS_WINDOWS, "Not available on Windows") def test_no_python_abi_suffix_sets_the_correct_library_name(self): - # For this test, run_test.py will call `python -m pip install .` in the + # For this test, run_test.py will call + # `python -m pip install . -v --no-build-isolation` in the # cpp_extensions/no_python_abi_suffix_test folder, where the # `BuildExtension` class has a `no_python_abi_suffix` option set to # `True`. This *should* mean that on Python 3, the produced shared diff --git a/torch/testing/_internal/common_utils.py b/torch/testing/_internal/common_utils.py index a2e27ddf82d3..1f80bda78379 100644 --- a/torch/testing/_internal/common_utils.py +++ b/torch/testing/_internal/common_utils.py @@ -5696,7 +5696,7 @@ def install_cpp_extension(extension_root): shutil.rmtree(d) # Build the extension - cmd = [sys.executable, "-m", "pip", "install", "--no-build-isolation", "-v", ".", "--root", install_dir] + cmd = [sys.executable, "-m", "pip", "install", extension_root, "-v", "--no-build-isolation", "--root", install_dir] return_code = shell(cmd, cwd=extension_root, env=os.environ) if return_code != 0: raise RuntimeError(f"build failed for cpp extension at {extension_root}")