From feaa02f9addfc6764843c8b48f8c403de593737c Mon Sep 17 00:00:00 2001 From: PyTorch MergeBot Date: Mon, 21 Jul 2025 22:46:53 +0000 Subject: [PATCH] Revert "[build] pin `setuptools>=77` to enable PEP 639 (#158104)" This reverts commit a78fb63dbdf98a1db219095293de1a11005e0390. Reverted https://github.com/pytorch/pytorch/pull/158104 on behalf of https://github.com/malfet due to It still breaks inductor-perf-nightly, see https://github.com/pytorch/pytorch/actions/runs/16425364208/job/46417088208, I'm going to dismiss all previous reviews ([comment](https://github.com/pytorch/pytorch/pull/158104#issuecomment-3099706457)) --- .ci/aarch64_linux/aarch64_ci_setup.sh | 2 +- .ci/docker/manywheel/Dockerfile_2_28 | 2 +- .ci/docker/manywheel/Dockerfile_s390x | 5 +++-- .ci/docker/requirements-ci.txt | 11 +++++------ .ci/pytorch/build.sh | 3 --- .ci/pytorch/test.sh | 2 +- .ci/pytorch/win-test-helpers/build_pytorch.bat | 5 ----- .ci/pytorch/win-test.sh | 2 +- .ci/pytorch/windows/internal/install_python.bat | 2 +- .ci/pytorch/windows/setup_build.bat | 5 +---- .ci/wheel/build_wheel.sh | 14 +++++++------- .github/requirements-gha-cache.txt | 2 +- .github/requirements/pip-requirements-macOS.txt | 8 ++++---- .github/scripts/lintrunner.sh | 2 +- .github/scripts/windows/build_triton.bat | 2 +- .github/workflows/_mac-test.yml | 5 ----- pyproject.toml | 11 ++++++++--- requirements-build.txt | 4 ++-- test/dynamo/test_exc.py | 16 ++++++++-------- 19 files changed, 46 insertions(+), 57 deletions(-) diff --git a/.ci/aarch64_linux/aarch64_ci_setup.sh b/.ci/aarch64_linux/aarch64_ci_setup.sh index b18d27f2793f..8ffba65d7fed 100755 --- a/.ci/aarch64_linux/aarch64_ci_setup.sh +++ b/.ci/aarch64_linux/aarch64_ci_setup.sh @@ -12,7 +12,7 @@ fi SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" source $SCRIPTPATH/../manywheel/set_desired_python.sh -pip install -q numpy==${NUMPY_VERSION} pyyaml==6.0.2 scons==4.7.0 ninja==1.11.1.4 patchelf==0.17.2 +pip install -q numpy==${NUMPY_VERSION} pyyaml==6.0.2 scons==4.7.0 ninja==1.11.1 patchelf==0.17.2 for tool in python python3 pip pip3 ninja scons patchelf; do ln -sf ${DESIRED_PYTHON_BIN_DIR}/${tool} /usr/local/bin; diff --git a/.ci/docker/manywheel/Dockerfile_2_28 b/.ci/docker/manywheel/Dockerfile_2_28 index 7f279a1c1a73..b150423e9954 100644 --- a/.ci/docker/manywheel/Dockerfile_2_28 +++ b/.ci/docker/manywheel/Dockerfile_2_28 @@ -128,7 +128,7 @@ ENV PATH=/opt/rh/gcc-toolset-${DEVTOOLSET_VERSION}/root/usr/bin:$PATH ENV LD_LIBRARY_PATH=/opt/rh/gcc-toolset-${DEVTOOLSET_VERSION}/root/usr/lib64:/opt/rh/gcc-toolset-${DEVTOOLSET_VERSION}/root/usr/lib:$LD_LIBRARY_PATH # Install setuptools and wheel for python 3.12/3.13 RUN for cpython_version in "cp312-cp312" "cp313-cp313" "cp313-cp313t"; do \ - /opt/python/${cpython_version}/bin/python -m pip install "setuptools>=77.0.0" "packaging>=24.2" wheel; \ + /opt/python/${cpython_version}/bin/python -m pip install setuptools wheel; \ done; diff --git a/.ci/docker/manywheel/Dockerfile_s390x b/.ci/docker/manywheel/Dockerfile_s390x index 335488b88f12..46ec7f77ae8b 100644 --- a/.ci/docker/manywheel/Dockerfile_s390x +++ b/.ci/docker/manywheel/Dockerfile_s390x @@ -124,9 +124,10 @@ RUN python3 -mpip install cmake==3.28.0 # install newest flatbuffers version first: # for some reason old version is getting pulled in otherwise. # packaging package is required for onnxruntime wheel build. -RUN pip3 install 'setuptools>=77.0' 'packaging>=24.2' && \ - pip3 install flatbuffers cython 'pkgconfig>=1.5.5' 'numpy<2.3.0' && \ +RUN pip3 install flatbuffers && \ + pip3 install cython 'pkgconfig>=1.5.5' 'setuptools>=77' 'numpy<2.3.0' && \ pip3 install --no-build-isolation h5py==3.11.0 && \ + pip3 install packaging && \ git clone https://github.com/microsoft/onnxruntime && \ cd onnxruntime && git checkout v1.21.0 && \ git submodule update --init --recursive && \ diff --git a/.ci/docker/requirements-ci.txt b/.ci/docker/requirements-ci.txt index 926f8aef35f2..944b1fb35b36 100644 --- a/.ci/docker/requirements-ci.txt +++ b/.ci/docker/requirements-ci.txt @@ -50,7 +50,7 @@ flatbuffers==24.12.23 hypothesis==5.35.1 # Pin hypothesis to avoid flakiness: https://github.com/pytorch/pytorch/issues/31136 #Description: advanced library for generating parametrized tests -#Pinned versions: 5.35.1 +#Pinned versions: 3.44.6, 4.53.2 #test that import: test_xnnpack_integration.py, test_pruning_op.py, test_nn.py junitparser==2.1.1 @@ -104,10 +104,10 @@ networkx==2.8.8 #Pinned versions: 2.8.8 #test that import: functorch -ninja==1.11.1.4 +ninja==1.11.1.3 #Description: build system. Used in some tests. Used in build to generate build #time tracing information -#Pinned versions: 1.11.1.4 +#Pinned versions: 1.11.1.3 #test that import: run_test.py, test_cpp_extensions_aot.py,test_determination.py numba==0.49.0 ; python_version < "3.9" @@ -307,7 +307,7 @@ pytest-cpp==2.3.0 #Pinned versions: 2.3.0 #test that import: -z3-solver==4.15.1.0 +z3-solver==4.12.6.0 #Description: The Z3 Theorem Prover Project #Pinned versions: #test that import: @@ -362,10 +362,9 @@ pwlf==2.2.1 #test that import: test_sac_estimator.py # To build PyTorch itself -packaging>=24.2 pyyaml pyzstd -setuptools>=77.0.0 +setuptools>=70.1.0 six scons==4.5.2 ; platform_machine == "aarch64" diff --git a/.ci/pytorch/build.sh b/.ci/pytorch/build.sh index f2b8998a6f6c..58454bcb108a 100755 --- a/.ci/pytorch/build.sh +++ b/.ci/pytorch/build.sh @@ -269,9 +269,6 @@ if [[ "$BUILD_ENVIRONMENT" == *-bazel-* ]]; then tools/bazel build --config=no-tty "${BAZEL_MEM_LIMIT}" "${BAZEL_CPU_LIMIT}" //... fi else - # install build-system requirements before running setup.py commands - python -m pip install -r requirements-build.txt - # check that setup.py would fail with bad arguments echo "The next three invocations are expected to fail with invalid command error messages." ( ! get_exit_code python setup.py bad_argument ) diff --git a/.ci/pytorch/test.sh b/.ci/pytorch/test.sh index e40d36abc2cc..4f28297b5bce 100755 --- a/.ci/pytorch/test.sh +++ b/.ci/pytorch/test.sh @@ -201,7 +201,7 @@ fi if [[ "$BUILD_ENVIRONMENT" != *-bazel-* ]] ; then # JIT C++ extensions require ninja. - pip_install "ninja==1.11.1.4" + pip_install "ninja==1.10.2" # ninja is installed in $HOME/.local/bin, e.g., /var/lib/jenkins/.local/bin for CI user jenkins # but this script should be runnable by any user, including root export PATH="$HOME/.local/bin:$PATH" diff --git a/.ci/pytorch/win-test-helpers/build_pytorch.bat b/.ci/pytorch/win-test-helpers/build_pytorch.bat index 74c9183f2abb..7ceb425ce2d1 100644 --- a/.ci/pytorch/win-test-helpers/build_pytorch.bat +++ b/.ci/pytorch/win-test-helpers/build_pytorch.bat @@ -126,11 +126,6 @@ if "%USE_CUDA%"=="1" ( set CMAKE_CUDA_COMPILER_LAUNCHER=%TMP_DIR%/bin/randomtemp.exe;%TMP_DIR%\bin\sccache.exe ) -:: Install build-system requirements before running setup.py commands -python -m pip install -r requirements-build.txt -if errorlevel 1 goto fail -if not errorlevel 0 goto fail - :: Print all existing environment variable for debugging set diff --git a/.ci/pytorch/win-test.sh b/.ci/pytorch/win-test.sh index be7f3e4bb35c..b61dd06ef562 100755 --- a/.ci/pytorch/win-test.sh +++ b/.ci/pytorch/win-test.sh @@ -41,7 +41,7 @@ fi python -m pip install pytest-rerunfailures==10.3 pytest-cpp==2.3.0 tensorboard==2.13.0 protobuf==5.29.4 pytest-subtests==0.13.1 # Install Z3 optional dependency for Windows builds. -python -m pip install z3-solver==4.15.1.0 +python -m pip install z3-solver==4.12.2.0 # Install tlparse for test\dynamo\test_structured_trace.py UTs. python -m pip install tlparse==0.3.30 diff --git a/.ci/pytorch/windows/internal/install_python.bat b/.ci/pytorch/windows/internal/install_python.bat index 65405a875b6b..73622bd736ed 100644 --- a/.ci/pytorch/windows/internal/install_python.bat +++ b/.ci/pytorch/windows/internal/install_python.bat @@ -18,5 +18,5 @@ start /wait "" python-amd64.exe /quiet InstallAllUsers=1 PrependPath=0 Include_t if errorlevel 1 exit /b 1 set "PATH=%CD%\Python\Scripts;%CD%\Python;%PATH%" -%PYTHON_EXEC% -m pip install --upgrade pip "setuptools>=77.0.0" "packaging>=24.2" wheel +%PYTHON_EXEC% -m pip install --upgrade pip setuptools packaging wheel if errorlevel 1 exit /b 1 diff --git a/.ci/pytorch/windows/setup_build.bat b/.ci/pytorch/windows/setup_build.bat index df925b4ba90b..9b492eef664d 100644 --- a/.ci/pytorch/windows/setup_build.bat +++ b/.ci/pytorch/windows/setup_build.bat @@ -7,9 +7,6 @@ call "internal\install_python.bat" %PYTHON_EXEC% --version set "PATH=%CD%\Python\Lib\site-packages\cmake\data\bin;%CD%\Python\Scripts;%CD%\Python;%PATH%" - -%PYTHON_EXEC% -m pip install "setuptools>=77.0.0" "packaging>=24.2" - if "%DESIRED_PYTHON%" == "3.13t" %PYTHON_EXEC% -m pip install numpy==2.2.1 cmake if "%DESIRED_PYTHON%" == "3.13" %PYTHON_EXEC% -m pip install numpy==2.1.2 cmake if "%DESIRED_PYTHON%" == "3.12" %PYTHON_EXEC% -m pip install numpy==2.0.2 cmake @@ -19,7 +16,7 @@ if "%DESIRED_PYTHON%" == "3.9" %PYTHON_EXEC% -m pip install numpy==2.0.2 cmake %PYTHON_EXEC% -m pip install pyyaml %PYTHON_EXEC% -m pip install mkl-include mkl-static -%PYTHON_EXEC% -m pip install boto3 ninja typing-extensions +%PYTHON_EXEC% -m pip install boto3 ninja typing_extensions setuptools==72.1.0 where cmake.exe diff --git a/.ci/wheel/build_wheel.sh b/.ci/wheel/build_wheel.sh index dc44f8ccc292..878d6595c84c 100755 --- a/.ci/wheel/build_wheel.sh +++ b/.ci/wheel/build_wheel.sh @@ -127,7 +127,7 @@ export INSTALL_TEST=0 # dont install test binaries into site-packages export MACOSX_DEPLOYMENT_TARGET=10.15 export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"} -SETUPTOOLS_PINNED_VERSION="==77.0.0" +SETUPTOOLS_PINNED_VERSION="==70.1.0" PYYAML_PINNED_VERSION="=5.3" EXTRA_CONDA_INSTALL_FLAGS="" CONDA_ENV_CREATE_FLAGS="" @@ -135,7 +135,7 @@ RENAME_WHEEL=true case $desired_python in 3.13t) echo "Using 3.13 deps" - SETUPTOOLS_PINNED_VERSION=">=77.0.0" + SETUPTOOLS_PINNED_VERSION=">=70.1.0" PYYAML_PINNED_VERSION=">=6.0.1" NUMPY_PINNED_VERSION="=2.1.0" CONDA_ENV_CREATE_FLAGS="python-freethreading" @@ -145,31 +145,31 @@ case $desired_python in ;; 3.13) echo "Using 3.13 deps" - SETUPTOOLS_PINNED_VERSION=">=77.0.0" + SETUPTOOLS_PINNED_VERSION=">=70.1.0" PYYAML_PINNED_VERSION=">=6.0.1" NUMPY_PINNED_VERSION="=2.1.0" ;; 3.12) echo "Using 3.12 deps" - SETUPTOOLS_PINNED_VERSION=">=77.0.0" + SETUPTOOLS_PINNED_VERSION=">=70.1.0" PYYAML_PINNED_VERSION=">=6.0.1" NUMPY_PINNED_VERSION="=2.0.2" ;; 3.11) echo "Using 3.11 deps" - SETUPTOOLS_PINNED_VERSION=">=77.0.0" + SETUPTOOLS_PINNED_VERSION=">=70.1.0" PYYAML_PINNED_VERSION=">=5.3" NUMPY_PINNED_VERSION="=2.0.2" ;; 3.10) echo "Using 3.10 deps" - SETUPTOOLS_PINNED_VERSION=">=77.0.0" + SETUPTOOLS_PINNED_VERSION=">=70.1.0" PYYAML_PINNED_VERSION=">=5.3" NUMPY_PINNED_VERSION="=2.0.2" ;; 3.9) echo "Using 3.9 deps" - SETUPTOOLS_PINNED_VERSION=">=77.0.0" + SETUPTOOLS_PINNED_VERSION=">=70.1.0" PYYAML_PINNED_VERSION=">=5.3" NUMPY_PINNED_VERSION="=2.0.2" ;; diff --git a/.github/requirements-gha-cache.txt b/.github/requirements-gha-cache.txt index 381bccbee847..5c691e4bf9b3 100644 --- a/.github/requirements-gha-cache.txt +++ b/.github/requirements-gha-cache.txt @@ -8,7 +8,7 @@ boto3==1.35.42 jinja2==3.1.6 lintrunner==0.10.7 -ninja==1.11.1.4 +ninja==1.10.0.post1 nvidia-ml-py==11.525.84 pyyaml==6.0 requests==2.32.4 diff --git a/.github/requirements/pip-requirements-macOS.txt b/.github/requirements/pip-requirements-macOS.txt index ea005956aefa..9c72c71523b7 100644 --- a/.github/requirements/pip-requirements-macOS.txt +++ b/.github/requirements/pip-requirements-macOS.txt @@ -7,12 +7,12 @@ hypothesis==6.56.4 librosa>=0.6.2 mpmath==1.3.0 networkx==2.8.7 -ninja==1.11.1.4 +ninja==1.10.2.4 numba==0.59.0 numpy==1.26.4 opt-einsum>=3.3 optree==0.13.0 -packaging==25.0 +packaging==23.1 parameterized==0.8.1 pillow==10.3.0 protobuf==5.29.4 @@ -26,11 +26,11 @@ pytest-xdist==3.3.1 pytest==7.3.2 pyyaml==6.0.2 scipy==1.12.0 -setuptools==80.9.0 +setuptools==72.1.0 sympy==1.13.3 tlparse==0.3.30 tensorboard==2.13.0 typing-extensions==4.12.2 unittest-xml-reporting<=3.2.0,>=2.0.0 xdoctest==1.1.0 -z3-solver==4.15.1.0 +z3-solver==4.12.2.0 diff --git a/.github/scripts/lintrunner.sh b/.github/scripts/lintrunner.sh index 1411ff0397b5..ef4741444f94 100755 --- a/.github/scripts/lintrunner.sh +++ b/.github/scripts/lintrunner.sh @@ -2,7 +2,7 @@ set -ex # Use uv to speed up lintrunner init -python3 -m pip install -U uv setuptools +python3 -m pip install uv==0.1.45 setuptools CACHE_DIRECTORY="/tmp/.lintbin" # Try to recover the cached binaries diff --git a/.github/scripts/windows/build_triton.bat b/.github/scripts/windows/build_triton.bat index da2e86b40432..97cd535a4988 100644 --- a/.github/scripts/windows/build_triton.bat +++ b/.github/scripts/windows/build_triton.bat @@ -10,7 +10,7 @@ if "%PY_VERS%" == "3.13t" ( call conda create -n %PYTHON_PREFIX% -y -c=conda-forge python=%PY_VERS% ) :: Fix cmake version for issue https://github.com/pytorch/pytorch/issues/150480 -call conda run -n %PYTHON_PREFIX% pip install wheel pybind11 certifi cython cmake==3.31.6 setuptools==78.1.1 ninja +call conda run -n %PYTHON_PREFIX% pip install wheel pybind11 certifi cython cmake==3.31.6 setuptools==72.1.0 ninja dir "%VC_INSTALL_PATH%" diff --git a/.github/workflows/_mac-test.yml b/.github/workflows/_mac-test.yml index 8822aaf7df41..063c97e449c7 100644 --- a/.github/workflows/_mac-test.yml +++ b/.github/workflows/_mac-test.yml @@ -80,11 +80,6 @@ jobs: run: | sysctl machdep.cpu.brand_string kern.osproductversion - - name: Install build toolchain - run: | - brew update --quiet - brew install --formula cmake ninja - - name: Clean up leftover processes on MacOS pet runner continue-on-error: true run: | diff --git a/pyproject.toml b/pyproject.toml index 133da9289f5c..b41ae87621f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,12 +2,13 @@ [build-system] requires = [ + # 70.1.0: min version for integrated bdist_wheel command from wheel package # 77.0.0: min version for SPDX expression support for project.license - "setuptools>=77.0.0,<80.0", + "setuptools>=70.1.0,<80.0", "cmake>=3.27", "ninja", "numpy", - "packaging>=24.2", + "packaging", "pyyaml", "requests", "six", # dependency chain: NNPACK -> PeachPy -> six @@ -20,7 +21,11 @@ name = "torch" description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration" readme = "README.md" requires-python = ">=3.9,<3.14" -license = "BSD-3-Clause" +# TODO: change to `license = "BSD-3-Clause"` and enable PEP 639 after pinning setuptools>=77 +# FIXME: As of 2025.06.20, it is hard to ensure the minimum version of setuptools in our CI environment. +# TOML-table-based license deprecated in setuptools>=77, and the deprecation warning will be changed +# to an error on 2026.02.18. See also: https://github.com/pypa/setuptools/issues/4903 +license = { text = "BSD-3-Clause" } authors = [{ name = "PyTorch Team", email = "packages@pytorch.org" }] keywords = ["pytorch", "machine learning"] classifiers = [ diff --git a/requirements-build.txt b/requirements-build.txt index 12332b0e1af0..be19d987f73d 100644 --- a/requirements-build.txt +++ b/requirements-build.txt @@ -1,9 +1,9 @@ # Build System requirements -setuptools>=77.0.0,<80.0 # setuptools develop deprecated on 80.0 +setuptools>=70.1.0,<80.0 # setuptools develop deprecated on 80.0 cmake>=3.27 ninja numpy -packaging>=24.2 +packaging pyyaml requests six # dependency chain: NNPACK -> PeachPy -> six diff --git a/test/dynamo/test_exc.py b/test/dynamo/test_exc.py index c340a2882d47..acc3fd55f6fb 100644 --- a/test/dynamo/test_exc.py +++ b/test/dynamo/test_exc.py @@ -251,13 +251,13 @@ translation validation failed. Model: ==> L['shape'][0]: 0 - ==> L['shape'][1]: 0 - ==> L['shape'][2]: 0 + ==> L['shape'][1]: 1 + ==> L['shape'][2]: 1 ==> L['x'].size()[0]: 3 ==> L['x'].storage_offset(): 0 ==> L['x'].stride()[0]: 1 - ==> s3: 0 - ==> s52: 0 + ==> s3: 1 + ==> s52: 1 ==> s77: 3 ==> s86: 0 @@ -315,16 +315,16 @@ Failure occurred while running node: %split : [num_users=3] = call_method[target=split](args = (%l_x_, (%l_shape_0_, %l_shape_1_, %l_shape_2_)), kwargs = {}) Model: - ==> L['shape'][0]: 0 - ==> L['shape'][1]: 0 + ==> L['shape'][0]: 1 + ==> L['shape'][1]: 1 ==> L['shape'][2]: 0 ==> L['x'].size()[0]: 3 ==> L['x'].storage_offset(): 0 ==> L['x'].stride()[0]: 1 ==> s3: 0 - ==> s52: 0 + ==> s52: 1 ==> s77: 3 - ==> s86: 0 + ==> s86: 1 Assertions: ==> (== 0 L['x'].storage_offset())