mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[build] pin setuptools>=70.1.0
for integrated bdist_wheel
command (#157783)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157783 Approved by: https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
b4476ca378
commit
4283d96bcd
@ -66,7 +66,7 @@ function do_cpython_build {
|
||||
ln -s pip3 ${prefix}/bin/pip
|
||||
fi
|
||||
# install setuptools since python 3.12 is required to use distutils
|
||||
${prefix}/bin/pip install wheel==0.34.2 setuptools==68.2.2
|
||||
${prefix}/bin/pip install wheel==0.45.1 setuptools==80.9.0
|
||||
local abi_tag=$(${prefix}/bin/python -c "from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag; print('{0}{1}-{2}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag()))")
|
||||
ln -sf ${prefix} /opt/python/${abi_tag}
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ pwlf==2.2.1
|
||||
# To build PyTorch itself
|
||||
pyyaml
|
||||
pyzstd
|
||||
setuptools
|
||||
setuptools>=70.1.0
|
||||
six
|
||||
wheel
|
||||
|
||||
|
@ -97,7 +97,8 @@ if [[ -z "$PYTORCH_ROOT" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
pushd "$PYTORCH_ROOT"
|
||||
retry pip install -q cmake
|
||||
retry pip install -q "setuptools>=70.1.0" packaging
|
||||
retry pip install -qU cmake ninja
|
||||
python setup.py clean
|
||||
retry pip install -qr requirements.txt
|
||||
case ${DESIRED_PYTHON} in
|
||||
|
@ -92,7 +92,8 @@ if [[ -z "$PYTORCH_ROOT" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
pushd "$PYTORCH_ROOT"
|
||||
retry pip install -q cmake
|
||||
retry pip install -q "setuptools>=70.1.0" packaging
|
||||
retry pip install -qU cmake ninja
|
||||
python setup.py clean
|
||||
retry pip install -qr requirements.txt
|
||||
retry pip install -q numpy==2.0.1
|
||||
|
@ -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="=46.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=">=68.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=">=68.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=">=68.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=">=46.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=">=46.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=">=46.0.0"
|
||||
SETUPTOOLS_PINNED_VERSION=">=70.1.0"
|
||||
PYYAML_PINNED_VERSION=">=5.3"
|
||||
NUMPY_PINNED_VERSION="=2.0.2"
|
||||
;;
|
||||
|
@ -2,12 +2,9 @@
|
||||
|
||||
[build-system]
|
||||
requires = [
|
||||
# After 75.8.2 dropped dep disttools API. Please fix
|
||||
# API temporarily restored and shim used. Please fix
|
||||
# Setuptools will drop support for setup.py past 80
|
||||
# 62.3.0: min version for recursive glob package data support
|
||||
# 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>=62.3.0,<80.0",
|
||||
"setuptools>=70.1.0,<80.0",
|
||||
"wheel",
|
||||
"cmake>=3.27",
|
||||
"ninja",
|
||||
|
@ -1,6 +1,19 @@
|
||||
# Python dependencies required for development
|
||||
build[uv] # for building sdist and wheel
|
||||
|
||||
# Build System requirements
|
||||
setuptools>=70.1.0,<80.0 # setuptools develop deprecated on 80.0
|
||||
wheel
|
||||
cmake>=3.27
|
||||
ninja
|
||||
numpy
|
||||
packaging
|
||||
pyyaml
|
||||
requests
|
||||
six # dependency chain: NNPACK -> PeachPy -> six
|
||||
typing-extensions>=4.10.0
|
||||
|
||||
# Install / Development extra requirements
|
||||
build[uv] # for building sdist and wheel
|
||||
expecttest>=0.3.0
|
||||
filelock
|
||||
fsspec
|
||||
@ -8,17 +21,7 @@ hypothesis
|
||||
jinja2
|
||||
lintrunner ; platform_machine != "s390x"
|
||||
networkx
|
||||
ninja
|
||||
numpy
|
||||
optree>=0.13.0
|
||||
packaging
|
||||
psutil
|
||||
pyyaml
|
||||
requests
|
||||
# setuptools develop deprecated on 80.0
|
||||
setuptools>=62.3.0,<80.0
|
||||
six # dependency chain: NNPACK -> PeachPy -> six
|
||||
sympy>=1.13.3
|
||||
types-dataclasses
|
||||
typing-extensions>=4.13.2
|
||||
wheel
|
||||
|
54
setup.py
54
setup.py
@ -269,6 +269,7 @@ from collections import defaultdict
|
||||
from pathlib import Path
|
||||
from typing import Any, ClassVar, IO
|
||||
|
||||
import setuptools.command.bdist_wheel
|
||||
import setuptools.command.build_ext
|
||||
import setuptools.command.sdist
|
||||
import setuptools.errors
|
||||
@ -958,38 +959,29 @@ class concat_license_files:
|
||||
self.f1.write_text(self.bsd_text, encoding="utf-8")
|
||||
|
||||
|
||||
try:
|
||||
from wheel.bdist_wheel import bdist_wheel # type: ignore[import-untyped]
|
||||
except ImportError:
|
||||
# This is useful when wheel is not installed and bdist_wheel is not
|
||||
# specified on the command line. If it _is_ specified, parsing the command
|
||||
# line will fail before wheel_concatenate is needed
|
||||
wheel_concatenate: type[Command] | None = None
|
||||
else:
|
||||
# Need to create the proper LICENSE.txt for the wheel
|
||||
class wheel_concatenate(bdist_wheel): # type: ignore[no-redef]
|
||||
"""check submodules on sdist to prevent incomplete tarballs"""
|
||||
# Need to create the proper LICENSE.txt for the wheel
|
||||
class bdist_wheel(setuptools.command.bdist_wheel.bdist_wheel):
|
||||
def run(self) -> None:
|
||||
with concat_license_files(include_files=True):
|
||||
super().run()
|
||||
|
||||
def run(self) -> None:
|
||||
with concat_license_files(include_files=True):
|
||||
super().run()
|
||||
def write_wheelfile(self, *args: Any, **kwargs: Any) -> None:
|
||||
super().write_wheelfile(*args, **kwargs)
|
||||
|
||||
def write_wheelfile(self, *args: Any, **kwargs: Any) -> None:
|
||||
super().write_wheelfile(*args, **kwargs)
|
||||
|
||||
if BUILD_LIBTORCH_WHL:
|
||||
bdist_dir = Path(self.bdist_dir)
|
||||
# Remove extraneneous files in the libtorch wheel
|
||||
for file in itertools.chain(
|
||||
bdist_dir.rglob("*.a"),
|
||||
bdist_dir.rglob("*.so"),
|
||||
):
|
||||
if (bdist_dir / file.name).is_file():
|
||||
file.unlink()
|
||||
for file in bdist_dir.rglob("*.py"):
|
||||
if BUILD_LIBTORCH_WHL:
|
||||
assert self.bdist_dir is not None
|
||||
bdist_dir = Path(self.bdist_dir)
|
||||
# Remove extraneneous files in the libtorch wheel
|
||||
for file in itertools.chain(
|
||||
bdist_dir.rglob("*.a"),
|
||||
bdist_dir.rglob("*.so"),
|
||||
):
|
||||
if (bdist_dir / file.name).is_file():
|
||||
file.unlink()
|
||||
# need an __init__.py file otherwise we wouldn't have a package
|
||||
(bdist_dir / "torch" / "__init__.py").touch()
|
||||
for file in bdist_dir.rglob("*.py"):
|
||||
file.unlink()
|
||||
# need an __init__.py file otherwise we wouldn't have a package
|
||||
(bdist_dir / "torch" / "__init__.py").touch()
|
||||
|
||||
|
||||
class clean(Command):
|
||||
@ -1019,6 +1011,7 @@ class clean(Command):
|
||||
shutil.rmtree(filename, ignore_errors=True)
|
||||
|
||||
|
||||
# Need to dump submodule hashes and create the proper LICENSE.txt for the sdist
|
||||
class sdist(setuptools.command.sdist.sdist):
|
||||
def run(self) -> None:
|
||||
with concat_license_files():
|
||||
@ -1182,12 +1175,11 @@ def configure_extension_build() -> tuple[
|
||||
ext_modules.append(Extension(name="functorch._C", sources=[]))
|
||||
|
||||
cmdclass = {
|
||||
"bdist_wheel": bdist_wheel,
|
||||
"build_ext": build_ext,
|
||||
"clean": clean,
|
||||
"sdist": sdist,
|
||||
}
|
||||
if wheel_concatenate is not None:
|
||||
cmdclass["bdist_wheel"] = wheel_concatenate
|
||||
|
||||
entry_points = {
|
||||
"console_scripts": [
|
||||
|
@ -92,24 +92,26 @@ class CMake:
|
||||
if IS_WINDOWS:
|
||||
return "cmake"
|
||||
|
||||
cmake_versions: dict[str, Version] = {}
|
||||
cmake_versions: list[str] = []
|
||||
valid_cmake_versions: dict[str, Version] = {}
|
||||
for cmd in ("cmake", "cmake3"):
|
||||
command = shutil.which(cmd)
|
||||
ver = CMake._get_version(command)
|
||||
if ver is not None:
|
||||
eprint(f"Found {cmd} ({command}) version: {ver}", end="")
|
||||
cmake_versions.append(f"{cmd}=={ver}")
|
||||
if ver >= CMAKE_MINIMUM_VERSION:
|
||||
eprint(f" (>={CMAKE_MINIMUM_VERSION})")
|
||||
cmake_versions[cmd] = ver
|
||||
valid_cmake_versions[cmd] = ver
|
||||
else:
|
||||
eprint(f" (<{CMAKE_MINIMUM_VERSION})")
|
||||
|
||||
if not cmake_versions:
|
||||
if not valid_cmake_versions:
|
||||
raise RuntimeError(
|
||||
f"no cmake or cmake3 with version >= {CMAKE_MINIMUM_VERSION}, "
|
||||
f"found: {list(cmake_versions.values())}"
|
||||
f"found: {cmake_versions}"
|
||||
)
|
||||
return max(cmake_versions, key=cmake_versions.get) # type: ignore[arg-type]
|
||||
return max(valid_cmake_versions, key=valid_cmake_versions.get) # type: ignore[arg-type]
|
||||
|
||||
@staticmethod
|
||||
def _get_version(cmd: str | None) -> Version | None:
|
||||
|
Reference in New Issue
Block a user