diff --git a/.ci/docker/manywheel/Dockerfile_2_28 b/.ci/docker/manywheel/Dockerfile_2_28 index b150423e9954..7f279a1c1a73 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 wheel; \ + /opt/python/${cpython_version}/bin/python -m pip install "setuptools>=77.0.0" "packaging>=24.2" wheel; \ done; diff --git a/.ci/docker/manywheel/Dockerfile_s390x b/.ci/docker/manywheel/Dockerfile_s390x index 46ec7f77ae8b..335488b88f12 100644 --- a/.ci/docker/manywheel/Dockerfile_s390x +++ b/.ci/docker/manywheel/Dockerfile_s390x @@ -124,10 +124,9 @@ 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 flatbuffers && \ - pip3 install cython 'pkgconfig>=1.5.5' 'setuptools>=77' 'numpy<2.3.0' && \ +RUN pip3 install 'setuptools>=77.0' 'packaging>=24.2' && \ + pip3 install flatbuffers cython 'pkgconfig>=1.5.5' '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 9c8251989477..650c4e58c8ba 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: 3.44.6, 4.53.2 +#Pinned versions: 5.35.1 #test that import: test_xnnpack_integration.py, test_pruning_op.py, test_nn.py junitparser==2.1.1 @@ -307,7 +307,7 @@ pytest-cpp==2.3.0 #Pinned versions: 2.3.0 #test that import: -z3-solver==4.12.6.0 +z3-solver==4.15.1.0 #Description: The Z3 Theorem Prover Project #Pinned versions: #test that import: @@ -363,9 +363,10 @@ pwlf==2.2.1 # To build PyTorch itself +packaging>=24.2 pyyaml pyzstd -setuptools>=70.1.0 +setuptools>=77.0.0 six scons==4.5.2 ; platform_machine == "aarch64" diff --git a/.ci/pytorch/build.sh b/.ci/pytorch/build.sh index 994bd179e464..07bf2037f430 100755 --- a/.ci/pytorch/build.sh +++ b/.ci/pytorch/build.sh @@ -269,6 +269,9 @@ 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/win-test-helpers/build_pytorch.bat b/.ci/pytorch/win-test-helpers/build_pytorch.bat index 7ceb425ce2d1..74c9183f2abb 100644 --- a/.ci/pytorch/win-test-helpers/build_pytorch.bat +++ b/.ci/pytorch/win-test-helpers/build_pytorch.bat @@ -126,6 +126,11 @@ 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 b61dd06ef562..be7f3e4bb35c 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.12.2.0 +python -m pip install z3-solver==4.15.1.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 73622bd736ed..65405a875b6b 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 packaging wheel +%PYTHON_EXEC% -m pip install --upgrade pip "setuptools>=77.0.0" "packaging>=24.2" wheel if errorlevel 1 exit /b 1 diff --git a/.ci/pytorch/windows/setup_build.bat b/.ci/pytorch/windows/setup_build.bat index 9b492eef664d..df925b4ba90b 100644 --- a/.ci/pytorch/windows/setup_build.bat +++ b/.ci/pytorch/windows/setup_build.bat @@ -7,6 +7,9 @@ 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 @@ -16,7 +19,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 setuptools==72.1.0 +%PYTHON_EXEC% -m pip install boto3 ninja typing-extensions where cmake.exe diff --git a/.ci/wheel/build_wheel.sh b/.ci/wheel/build_wheel.sh index 878d6595c84c..dc44f8ccc292 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="==70.1.0" +SETUPTOOLS_PINNED_VERSION="==77.0.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=">=70.1.0" + SETUPTOOLS_PINNED_VERSION=">=77.0.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=">=70.1.0" + SETUPTOOLS_PINNED_VERSION=">=77.0.0" PYYAML_PINNED_VERSION=">=6.0.1" NUMPY_PINNED_VERSION="=2.1.0" ;; 3.12) echo "Using 3.12 deps" - SETUPTOOLS_PINNED_VERSION=">=70.1.0" + SETUPTOOLS_PINNED_VERSION=">=77.0.0" PYYAML_PINNED_VERSION=">=6.0.1" NUMPY_PINNED_VERSION="=2.0.2" ;; 3.11) echo "Using 3.11 deps" - SETUPTOOLS_PINNED_VERSION=">=70.1.0" + SETUPTOOLS_PINNED_VERSION=">=77.0.0" PYYAML_PINNED_VERSION=">=5.3" NUMPY_PINNED_VERSION="=2.0.2" ;; 3.10) echo "Using 3.10 deps" - SETUPTOOLS_PINNED_VERSION=">=70.1.0" + SETUPTOOLS_PINNED_VERSION=">=77.0.0" PYYAML_PINNED_VERSION=">=5.3" NUMPY_PINNED_VERSION="=2.0.2" ;; 3.9) echo "Using 3.9 deps" - SETUPTOOLS_PINNED_VERSION=">=70.1.0" + SETUPTOOLS_PINNED_VERSION=">=77.0.0" PYYAML_PINNED_VERSION=">=5.3" NUMPY_PINNED_VERSION="=2.0.2" ;; diff --git a/.github/requirements/pip-requirements-macOS.txt b/.github/requirements/pip-requirements-macOS.txt index e8464f0a55ff..7eaa962995b7 100644 --- a/.github/requirements/pip-requirements-macOS.txt +++ b/.github/requirements/pip-requirements-macOS.txt @@ -12,7 +12,7 @@ numba==0.59.0 numpy==1.26.4 opt-einsum>=3.3 optree==0.13.0 -packaging==23.1 +packaging==25.0 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==72.1.0 +setuptools==80.9.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.12.2.0 +z3-solver==4.15.1.0 diff --git a/.github/scripts/lintrunner.sh b/.github/scripts/lintrunner.sh index ef4741444f94..1411ff0397b5 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 uv==0.1.45 setuptools +python3 -m pip install -U uv 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 97cd535a4988..da2e86b40432 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==72.1.0 ninja +call conda run -n %PYTHON_PREFIX% pip install wheel pybind11 certifi cython cmake==3.31.6 setuptools==78.1.1 ninja dir "%VC_INSTALL_PATH%" diff --git a/pyproject.toml b/pyproject.toml index b41ae87621f0..133da9289f5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,13 +2,12 @@ [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>=70.1.0,<80.0", + "setuptools>=77.0.0,<80.0", "cmake>=3.27", "ninja", "numpy", - "packaging", + "packaging>=24.2", "pyyaml", "requests", "six", # dependency chain: NNPACK -> PeachPy -> six @@ -21,11 +20,7 @@ name = "torch" description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration" readme = "README.md" requires-python = ">=3.9,<3.14" -# 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" } +license = "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 be19d987f73d..12332b0e1af0 100644 --- a/requirements-build.txt +++ b/requirements-build.txt @@ -1,9 +1,9 @@ # Build System requirements -setuptools>=70.1.0,<80.0 # setuptools develop deprecated on 80.0 +setuptools>=77.0.0,<80.0 # setuptools develop deprecated on 80.0 cmake>=3.27 ninja numpy -packaging +packaging>=24.2 pyyaml requests six # dependency chain: NNPACK -> PeachPy -> six diff --git a/test/dynamo/test_exc.py b/test/dynamo/test_exc.py index acc3fd55f6fb..c340a2882d47 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]: 1 - ==> L['shape'][2]: 1 + ==> L['shape'][1]: 0 + ==> L['shape'][2]: 0 ==> L['x'].size()[0]: 3 ==> L['x'].storage_offset(): 0 ==> L['x'].stride()[0]: 1 - ==> s3: 1 - ==> s52: 1 + ==> s3: 0 + ==> s52: 0 ==> 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]: 1 - ==> L['shape'][1]: 1 + ==> L['shape'][0]: 0 + ==> L['shape'][1]: 0 ==> L['shape'][2]: 0 ==> L['x'].size()[0]: 3 ==> L['x'].storage_offset(): 0 ==> L['x'].stride()[0]: 1 ==> s3: 0 - ==> s52: 1 + ==> s52: 0 ==> s77: 3 - ==> s86: 1 + ==> s86: 0 Assertions: ==> (== 0 L['x'].storage_offset())