From 939ad2174f651fcc6b842344c0cd479dc8921fff Mon Sep 17 00:00:00 2001 From: Klaus Zimmermann Date: Tue, 24 Jun 2025 18:18:25 +0200 Subject: [PATCH] Update [ghstack-poisoned] --- .ci/aarch64_linux/aarch64_wheel_ci_build.py | 2 +- .ci/aarch64_linux/build_aarch64_wheel.py | 14 ++--- .ci/docker/common/install_triton.sh | 6 +-- .ci/docker/requirements-ci.txt | 5 ++ .ci/manywheel/build_common.sh | 14 ++--- .ci/pytorch/build.sh | 6 +-- .ci/pytorch/macos-build.sh | 4 +- .ci/pytorch/test.sh | 2 +- .../win-test-helpers/build_pytorch.bat | 2 +- .ci/pytorch/windows/arm64/build_pytorch.bat | 2 +- .ci/pytorch/windows/internal/setup.bat | 2 +- .ci/wheel/build_wheel.sh | 18 +++---- .../requirements/pip-requirements-macOS.txt | 1 + .../test/test_python_agnostic.py | 4 +- test/run_test.py | 2 +- tools/packaging/build_wheel.py | 26 +++++---- tools/packaging/split_wheel.py | 54 +++++++++++++++---- 17 files changed, 105 insertions(+), 59 deletions(-) diff --git a/.ci/aarch64_linux/aarch64_wheel_ci_build.py b/.ci/aarch64_linux/aarch64_wheel_ci_build.py index 0a44838a1445..293626bafa16 100755 --- a/.ci/aarch64_linux/aarch64_wheel_ci_build.py +++ b/.ci/aarch64_linux/aarch64_wheel_ci_build.py @@ -248,7 +248,7 @@ def parse_arguments(): else: print("build pytorch without mkldnn backend") - os.system(f"cd /pytorch; {build_vars} python3 setup.py bdist_wheel") + os.system(f"cd /pytorch; {build_vars} python3 -m build --wheel --no-isolation") if enable_cuda: print("Updating Cuda Dependency") filename = os.listdir("/pytorch/dist/") diff --git a/.ci/aarch64_linux/build_aarch64_wheel.py b/.ci/aarch64_linux/build_aarch64_wheel.py index 025d0a20579d..42a7523dc168 100755 --- a/.ci/aarch64_linux/build_aarch64_wheel.py +++ b/.ci/aarch64_linux/build_aarch64_wheel.py @@ -444,7 +444,7 @@ def build_torchvision( if host.using_docker(): build_vars += " CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000" - host.run_cmd(f"cd vision && {build_vars} python3 setup.py bdist_wheel") + host.run_cmd(f"cd vision && {build_vars} python3 -m build --wheel --no-isolation") vision_wheel_name = host.list_dir("vision/dist")[0] embed_libgomp(host, use_conda, os.path.join("vision", "dist", vision_wheel_name)) @@ -501,7 +501,7 @@ def build_torchdata( if host.using_docker(): build_vars += " CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000" - host.run_cmd(f"cd data && {build_vars} python3 setup.py bdist_wheel") + host.run_cmd(f"cd data && {build_vars} python3 -m build --wheel --no-isolation") wheel_name = host.list_dir("data/dist")[0] embed_libgomp(host, use_conda, os.path.join("data", "dist", wheel_name)) @@ -559,7 +559,7 @@ def build_torchtext( if host.using_docker(): build_vars += " CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000" - host.run_cmd(f"cd text && {build_vars} python3 setup.py bdist_wheel") + host.run_cmd(f"cd text && {build_vars} python3 -m build --wheel --no-isolation") wheel_name = host.list_dir("text/dist")[0] embed_libgomp(host, use_conda, os.path.join("text", "dist", wheel_name)) @@ -622,7 +622,7 @@ def build_torchaudio( host.run_cmd( f"cd audio && export FFMPEG_ROOT=$(pwd)/third_party/ffmpeg && export USE_FFMPEG=1 \ && ./packaging/ffmpeg/build.sh \ - && {build_vars} python3 setup.py bdist_wheel" + && {build_vars} python3 -m build --wheel --no-isolation" ) wheel_name = host.list_dir("audio/dist")[0] @@ -734,7 +734,7 @@ def start_build( print("Building PyTorch wheel") build_opts = "" if pytorch_build_number is not None: - build_opts += f" --build-number {pytorch_build_number}" + build_opts += f" -C--build-option=--build-number={pytorch_build_number}" # Breakpad build fails on aarch64 build_vars = "USE_BREAKPAD=0 " if branch == "nightly": @@ -755,7 +755,7 @@ def start_build( print("build pytorch with mkldnn+acl backend") build_vars += " USE_MKLDNN=ON USE_MKLDNN_ACL=ON" host.run_cmd( - f"cd $HOME/pytorch && export ACL_ROOT_DIR=$HOME/ComputeLibrary && {build_vars} python3 setup.py bdist_wheel{build_opts}" + f"cd $HOME/pytorch && export ACL_ROOT_DIR=$HOME/ComputeLibrary && {build_vars} python3 -m build --wheel --no-isolation{build_opts}" ) print("Repair the wheel") pytorch_wheel_name = host.list_dir("pytorch/dist")[0] @@ -771,7 +771,7 @@ def start_build( else: print("build pytorch without mkldnn backend") host.run_cmd( - f"cd pytorch && {build_vars} python3 setup.py bdist_wheel{build_opts}" + f"cd pytorch && {build_vars} python3 -m build --wheel --no-isolation{build_opts}" ) print("Deleting build folder") diff --git a/.ci/docker/common/install_triton.sh b/.ci/docker/common/install_triton.sh index f5e39fbaf9cc..2183bcaa8c43 100755 --- a/.ci/docker/common/install_triton.sh +++ b/.ci/docker/common/install_triton.sh @@ -66,15 +66,15 @@ if [ -n "${UBUNTU_VERSION}" ] && [ -n "${GCC_VERSION}" ] && [[ "${GCC_VERSION}" # Triton needs at least gcc-9 to build apt-get install -y g++-9 - CXX=g++-9 conda_run python setup.py bdist_wheel + CXX=g++-9 conda_run python -m build --wheel --no-isolation elif [ -n "${UBUNTU_VERSION}" ] && [ -n "${CLANG_VERSION}" ]; then # Triton needs which surprisingly is not available with clang-9 toolchain add-apt-repository -y ppa:ubuntu-toolchain-r/test apt-get install -y g++-9 - CXX=g++-9 conda_run python setup.py bdist_wheel + CXX=g++-9 conda_run python -m build --wheel --no-isolation else - conda_run python setup.py bdist_wheel + conda_run python -m build --wheel --no-isolation fi # Copy the wheel to /opt for multi stage docker builds diff --git a/.ci/docker/requirements-ci.txt b/.ci/docker/requirements-ci.txt index f8445d125b68..c873d3ee3aac 100644 --- a/.ci/docker/requirements-ci.txt +++ b/.ci/docker/requirements-ci.txt @@ -10,6 +10,11 @@ boto3==1.35.42 #Pinned versions: 1.19.12, 1.16.34 #test that import: +build +#Description: A simple, correct Python build frontend. +#Pinned versions: +#test that import: + click #Description: Command Line Interface Creation Kit #Pinned versions: diff --git a/.ci/manywheel/build_common.sh b/.ci/manywheel/build_common.sh index 74ce994207d4..43d6e50f1aa4 100644 --- a/.ci/manywheel/build_common.sh +++ b/.ci/manywheel/build_common.sh @@ -139,26 +139,26 @@ fi echo "Calling setup.py bdist at $(date)" if [[ "$USE_SPLIT_BUILD" == "true" ]]; then - echo "Calling setup.py bdist_wheel for split build (BUILD_LIBTORCH_WHL)" + echo "Calling -m build --wheel --no-isolation for split build (BUILD_LIBTORCH_WHL)" time EXTRA_CAFFE2_CMAKE_FLAGS=${EXTRA_CAFFE2_CMAKE_FLAGS[@]} \ BUILD_LIBTORCH_WHL=1 BUILD_PYTHON_ONLY=0 \ BUILD_LIBTORCH_CPU_WITH_DEBUG=$BUILD_DEBUG_INFO \ USE_NCCL=${USE_NCCL} USE_RCCL=${USE_RCCL} USE_KINETO=${USE_KINETO} \ - python setup.py bdist_wheel -d /tmp/$WHEELHOUSE_DIR - echo "Finished setup.py bdist_wheel for split build (BUILD_LIBTORCH_WHL)" - echo "Calling setup.py bdist_wheel for split build (BUILD_PYTHON_ONLY)" + python -m build --wheel --no-isolation --outdir /tmp/$WHEELHOUSE_DIR + echo "Finished -m build --wheel --no-isolation for split build (BUILD_LIBTORCH_WHL)" + echo "Calling -m build --wheel --no-isolation for split build (BUILD_PYTHON_ONLY)" time EXTRA_CAFFE2_CMAKE_FLAGS=${EXTRA_CAFFE2_CMAKE_FLAGS[@]} \ BUILD_LIBTORCH_WHL=0 BUILD_PYTHON_ONLY=1 \ BUILD_LIBTORCH_CPU_WITH_DEBUG=$BUILD_DEBUG_INFO \ USE_NCCL=${USE_NCCL} USE_RCCL=${USE_RCCL} USE_KINETO=${USE_KINETO} \ - CMAKE_FRESH=1 python setup.py bdist_wheel -d /tmp/$WHEELHOUSE_DIR - echo "Finished setup.py bdist_wheel for split build (BUILD_PYTHON_ONLY)" + CMAKE_FRESH=1 python -m build --wheel --no-isolation --outdir /tmp/$WHEELHOUSE_DIR + echo "Finished -m build --wheel --no-isolation for split build (BUILD_PYTHON_ONLY)" else time CMAKE_ARGS=${CMAKE_ARGS[@]} \ EXTRA_CAFFE2_CMAKE_FLAGS=${EXTRA_CAFFE2_CMAKE_FLAGS[@]} \ BUILD_LIBTORCH_CPU_WITH_DEBUG=$BUILD_DEBUG_INFO \ USE_NCCL=${USE_NCCL} USE_RCCL=${USE_RCCL} USE_KINETO=${USE_KINETO} \ - python setup.py bdist_wheel -d /tmp/$WHEELHOUSE_DIR + python -m build --wheel --no-isolation --outdir /tmp/$WHEELHOUSE_DIR fi echo "Finished setup.py bdist at $(date)" diff --git a/.ci/pytorch/build.sh b/.ci/pytorch/build.sh index 3ba2d36624ea..fab961e2f754 100755 --- a/.ci/pytorch/build.sh +++ b/.ci/pytorch/build.sh @@ -290,9 +290,9 @@ else WERROR=1 python setup.py clean if [[ "$USE_SPLIT_BUILD" == "true" ]]; then - python3 tools/packaging/split_wheel.py bdist_wheel + python3 tools/packaging/split_wheel.py build_wheel else - WERROR=1 python setup.py bdist_wheel + WERROR=1 python -m build --wheel --no-isolation fi else python setup.py clean @@ -303,7 +303,7 @@ else echo "USE_SPLIT_BUILD cannot be used with xla or rocm" exit 1 else - python setup.py bdist_wheel + python -m build --wheel --no-isolation fi fi pip_install_whl "$(echo dist/*.whl)" diff --git a/.ci/pytorch/macos-build.sh b/.ci/pytorch/macos-build.sh index d7447e7d4858..c01efda11ea6 100755 --- a/.ci/pytorch/macos-build.sh +++ b/.ci/pytorch/macos-build.sh @@ -36,11 +36,11 @@ fi print_cmake_info if [[ ${BUILD_ENVIRONMENT} == *"distributed"* ]]; then # Needed for inductor benchmarks, as lots of HF networks make `torch.distribtued` calls - USE_DISTRIBUTED=1 USE_OPENMP=1 WERROR=1 python setup.py bdist_wheel + USE_DISTRIBUTED=1 USE_OPENMP=1 WERROR=1 python -m build --wheel --no-isolation else # Explicitly set USE_DISTRIBUTED=0 to align with the default build config on mac. This also serves as the sole CI config that tests # that building with USE_DISTRIBUTED=0 works at all. See https://github.com/pytorch/pytorch/issues/86448 - USE_DISTRIBUTED=0 USE_OPENMP=1 MACOSX_DEPLOYMENT_TARGET=11.0 WERROR=1 BUILD_TEST=OFF USE_PYTORCH_METAL=1 python setup.py bdist_wheel --plat-name macosx_11_0_arm64 + USE_DISTRIBUTED=0 USE_OPENMP=1 MACOSX_DEPLOYMENT_TARGET=11.0 WERROR=1 BUILD_TEST=OFF USE_PYTORCH_METAL=1 python -m build --wheel --no-isolation -C--build-option=--plat-name=macosx_11_0_arm64 fi if which sccache > /dev/null; then print_sccache_stats diff --git a/.ci/pytorch/test.sh b/.ci/pytorch/test.sh index b9351a4033d9..b9c9313cdeb2 100755 --- a/.ci/pytorch/test.sh +++ b/.ci/pytorch/test.sh @@ -1358,7 +1358,7 @@ EOF pip3 install -r requirements.txt # shellcheck source=./common-build.sh source "$(dirname "${BASH_SOURCE[0]}")/common-build.sh" - python setup.py bdist_wheel --bdist-dir="base_bdist_tmp" --dist-dir="base_dist" + python -m build --wheel --no-isolation -C--build-option=--bdist-dir="base_bdist_tmp" --outdir "base_dist" python -mpip install base_dist/*.whl echo "::endgroup::" diff --git a/.ci/pytorch/win-test-helpers/build_pytorch.bat b/.ci/pytorch/win-test-helpers/build_pytorch.bat index 6a475dd89d32..74e6c305c69c 100644 --- a/.ci/pytorch/win-test-helpers/build_pytorch.bat +++ b/.ci/pytorch/win-test-helpers/build_pytorch.bat @@ -129,7 +129,7 @@ if "%USE_CUDA%"=="1" ( :: Print all existing environment variable for debugging set -python setup.py bdist_wheel +python -m build --wheel --no-isolation if errorlevel 1 goto fail if not errorlevel 0 goto fail sccache --show-stats diff --git a/.ci/pytorch/windows/arm64/build_pytorch.bat b/.ci/pytorch/windows/arm64/build_pytorch.bat index 3363a2d08846..b5c2ef65b84a 100644 --- a/.ci/pytorch/windows/arm64/build_pytorch.bat +++ b/.ci/pytorch/windows/arm64/build_pytorch.bat @@ -48,7 +48,7 @@ sccache --zero-stats sccache --show-stats :: Call PyTorch build script -python setup.py bdist_wheel -d "%PYTORCH_FINAL_PACKAGE_DIR%" +python -m build --wheel --no-isolation --outdir "%PYTORCH_FINAL_PACKAGE_DIR%" :: show sccache stats sccache --show-stats diff --git a/.ci/pytorch/windows/internal/setup.bat b/.ci/pytorch/windows/internal/setup.bat index 71056540464c..34a5140cb1ee 100644 --- a/.ci/pytorch/windows/internal/setup.bat +++ b/.ci/pytorch/windows/internal/setup.bat @@ -86,7 +86,7 @@ copy /Y "%LIBTORCH_PREFIX%-%PYTORCH_BUILD_VERSION%.zip" "%PYTORCH_FINAL_PACKAGE_ goto build_end :pytorch -%PYTHON_EXEC% setup.py bdist_wheel -d "%PYTORCH_FINAL_PACKAGE_DIR%" +%PYTHON_EXEC% -m build --wheel --no-isolation --outdir "%PYTORCH_FINAL_PACKAGE_DIR%" :build_end IF ERRORLEVEL 1 exit /b 1 diff --git a/.ci/wheel/build_wheel.sh b/.ci/wheel/build_wheel.sh index 76206d9937ef..f6876efb8fe3 100755 --- a/.ci/wheel/build_wheel.sh +++ b/.ci/wheel/build_wheel.sh @@ -199,20 +199,20 @@ export USE_QNNPACK=OFF export BUILD_TEST=OFF pushd "$pytorch_rootdir" -echo "Calling setup.py bdist_wheel at $(date)" +echo "Calling -m build --wheel --no-isolation at $(date)" if [[ "$USE_SPLIT_BUILD" == "true" ]]; then - echo "Calling setup.py bdist_wheel for split build (BUILD_LIBTORCH_WHL)" - BUILD_LIBTORCH_WHL=1 BUILD_PYTHON_ONLY=0 python setup.py bdist_wheel -d "$whl_tmp_dir" - echo "Finished setup.py bdist_wheel for split build (BUILD_LIBTORCH_WHL)" - echo "Calling setup.py bdist_wheel for split build (BUILD_PYTHON_ONLY)" - BUILD_LIBTORCH_WHL=0 BUILD_PYTHON_ONLY=1 CMAKE_FRESH=1 python setup.py bdist_wheel -d "$whl_tmp_dir" - echo "Finished setup.py bdist_wheel for split build (BUILD_PYTHON_ONLY)" + echo "Calling -m build --wheel --no-isolation for split build (BUILD_LIBTORCH_WHL)" + BUILD_LIBTORCH_WHL=1 BUILD_PYTHON_ONLY=0 python -m build --wheel --no-isolation --outdir "$whl_tmp_dir" + echo "Finished -m build --wheel --no-isolation for split build (BUILD_LIBTORCH_WHL)" + echo "Calling -m build --wheel --no-isolation for split build (BUILD_PYTHON_ONLY)" + BUILD_PYTHON_ONLY=1 BUILD_LIBTORCH_WHL=0 CMAKE_FRESH=1 python -m build --wheel --no-isolation --outdir "$whl_tmp_dir" + echo "Finished -m build --wheel --no-isolation for split build (BUILD_PYTHON_ONLY)" else - python setup.py bdist_wheel -d "$whl_tmp_dir" + python -m build --wheel --no-isolation --outdir "$whl_tmp_dir" fi -echo "Finished setup.py bdist_wheel at $(date)" +echo "Finished -m build --wheel --no-isolation at $(date)" if [[ $package_type != 'libtorch' ]]; then echo "delocating wheel dependencies" diff --git a/.github/requirements/pip-requirements-macOS.txt b/.github/requirements/pip-requirements-macOS.txt index e8464f0a55ff..8bd1ff968c73 100644 --- a/.github/requirements/pip-requirements-macOS.txt +++ b/.github/requirements/pip-requirements-macOS.txt @@ -1,4 +1,5 @@ boto3==1.35.42 +build==1.2.2.post1 cmake==3.27.* expecttest==0.3.0 fbscribelogger==0.1.7 diff --git a/test/cpp_extensions/python_agnostic_extension/test/test_python_agnostic.py b/test/cpp_extensions/python_agnostic_extension/test/test_python_agnostic.py index a64ddc8e440e..f0597191ea9b 100644 --- a/test/cpp_extensions/python_agnostic_extension/test/test_python_agnostic.py +++ b/test/cpp_extensions/python_agnostic_extension/test/test_python_agnostic.py @@ -24,7 +24,7 @@ def setUpClass(cls): shutil.rmtree(cls.dist_dir) # Build the wheel - wheel_cmd = [sys.executable, "setup.py", "bdist_wheel"] + wheel_cmd = [sys.executable, "-m", "build", "--wheel", "--no-isolation"] return_code = shell(wheel_cmd, cwd=cls.extension_root, env=os.environ) if return_code != 0: raise RuntimeError("python_agnostic bdist_wheel failed to build") @@ -32,7 +32,7 @@ def setUpClass(cls): @onlyCUDA @unittest.skipIf(not IS_LINUX, "test requires linux tools ldd and nm") def test_extension_is_python_agnostic(self, device): - # For this test, run_test.py will call `python setup.py bdist_wheel` in the + # For this test, run_test.py will call `python -m build --wheel --no-isolation` in the # cpp_extensions/python_agnostic_extension folder, where the extension and # setup calls specify py_limited_api to `True`. To approximate that the # extension is indeed python agnostic, we test diff --git a/test/run_test.py b/test/run_test.py index 50172c144ac8..360e6952d791 100755 --- a/test/run_test.py +++ b/test/run_test.py @@ -827,7 +827,7 @@ def _test_cpp_extensions_aot(test_directory, options, use_ninja): shell_env = os.environ.copy() shell_env["USE_NINJA"] = str(1 if use_ninja else 0) install_cmd = [sys.executable, "-m", "pip", "install", ".", "-v", "--no-build-isolation", "--root", "./install"] - wheel_cmd = [sys.executable, "setup.py", "bdist_wheel"] + wheel_cmd = [sys.executable, "-m", "build", "--wheel", "--no-isolation"] return_code = shell(install_cmd, cwd=cpp_extensions_test_dir, env=shell_env) if return_code != 0: return return_code diff --git a/tools/packaging/build_wheel.py b/tools/packaging/build_wheel.py index 16e9a87bd963..b7b94694dd06 100644 --- a/tools/packaging/build_wheel.py +++ b/tools/packaging/build_wheel.py @@ -19,7 +19,6 @@ logger.setLevel(logging.DEBUG) ROOT_PATH = Path(__file__).absolute().parent.parent.parent -SETUP_PY_PATH = ROOT_PATH / "setup.py" REQUIREMENTS_PATH = ROOT_PATH / "requirements.txt" @@ -68,18 +67,27 @@ class Builder: def __init__(self, interpreter: str) -> None: self.interpreter = interpreter - def setup_py(self, cmd_args: list[str]) -> bool: + def build_wheel(self, destination: str) -> bool: + logger.info("Running bdist_wheel -d %s", destination) return ( - run_cmd([self.interpreter, str(SETUP_PY_PATH), *cmd_args]).returncode == 0 + run_cmd( + [ + self.interpreter, + "-m", + "build", + "--wheel", + "--no-isolation", + "--outdir", + destination, + str(ROOT_PATH), + ] + ).returncode + == 0 ) - def bdist_wheel(self, destination: str) -> bool: - logger.info("Running bdist_wheel -d %s", destination) - return self.setup_py(["bdist_wheel", "-d", destination]) - def clean(self) -> bool: logger.info("Running clean") - return self.setup_py(["clean"]) + return run_cmd([self.interpreter, "setup.py", "clean"]).returncode == 0 def install_requirements(self) -> None: logger.info("Installing requirements") @@ -130,7 +138,7 @@ def main() -> None: start_time = time.time() - builder.bdist_wheel(args.destination) + builder.build_wheel(args.destination) end_time = time.time() diff --git a/tools/packaging/split_wheel.py b/tools/packaging/split_wheel.py index fd52c39a22b0..e78fdf677346 100644 --- a/tools/packaging/split_wheel.py +++ b/tools/packaging/split_wheel.py @@ -38,7 +38,38 @@ # NOTE: This will need to be updated if this script is ever moved ROOT_PATH = Path(__file__).absolute().parents[2] -SETUP_PY_PATH = ROOT_PATH / "setup.py" + +INTERPRETER = sys.executable + +COMMANDS = { + "install": [ + INTERPRETER, + "-m", + "pip", + "install", + str(ROOT_PATH), + "-v", + "--no-build-isolation", + ], + "build_wheel": [ + INTERPRETER, + "-m", + "build", + "--wheel", + "--no-isolation", + str(ROOT_PATH), + ], + "develop": [ + INTERPRETER, + "-m", + "pip", + "install", + "-e", + str(ROOT_PATH), + "-v", + "--no-build-isolation", + ], +} def requirements_installed() -> bool: @@ -51,15 +82,16 @@ def requirements_installed() -> bool: "Requirements not installed, run the following command to install:" ) logger.error( - " > %s -m pip install -r %s/requirements.txt", sys.executable, ROOT_PATH + " > %s -m pip install -r %s/requirements.txt", + sys.executable, + str(ROOT_PATH), ) return False -def setup_py(cmd_args: list[str], extra_env: Optional[dict[str, str]] = None) -> None: +def run_cmd(cmd: list[str], extra_env: Optional[dict[str, str]] = None) -> None: if extra_env is None: extra_env = {} - cmd = [sys.executable, str(SETUP_PY_PATH), *cmd_args] logger.debug("+ %s", " ".join(cmd)) subprocess.run( cmd, @@ -69,17 +101,17 @@ def setup_py(cmd_args: list[str], extra_env: Optional[dict[str, str]] = None) -> ) -def split_build(cmd: str) -> None: +def split_build(cmd: list[str]) -> None: logger.info("Running %s for libtorch wheel", cmd) - setup_py( - [cmd], + run_cmd( + cmd, extra_env={"BUILD_LIBTORCH_WHL": "1", "BUILD_PYTHON_ONLY": "0"}, ) logger.info("Running %s for torch wheel", cmd) # NOTE: Passing CMAKE_FRESH=1 is necessary here since the torch frontend has it's # own cmake files that it needs to generate - setup_py( - [cmd], + run_cmd( + cmd, extra_env={ "BUILD_LIBTORCH_WHL": "0", "BUILD_PYTHON_ONLY": "1", @@ -93,7 +125,7 @@ def parse_args() -> argparse.Namespace: command_subparser = parser.add_subparsers(dest="command") # Ideally these should mirror setuptools commands if we need support here for that command_subparser.add_parser("install") - command_subparser.add_parser("bdist_wheel") + command_subparser.add_parser("build_wheel") command_subparser.add_parser("develop") return parser.parse_args() @@ -102,7 +134,7 @@ def main() -> None: args = parse_args() if not requirements_installed(): sys.exit(1) - split_build(args.command) + split_build(COMMANDS[args.command]) if __name__ == "__main__":