[build] modernize build-frontend: python setup.py develop/install -> [uv ]pip install --no-build-isolation [-e ]. (#156027)

Modernize the development installation:

```bash
# python setup.py develop
python -m pip install --no-build-isolation -e .

# python setup.py install
python -m pip install --no-build-isolation .
```

Now, the `python setup.py develop` is a wrapper around `python -m pip install -e .` since `setuptools>=80.0`:

- pypa/setuptools#4955

`python setup.py install` is deprecated and will emit a warning during run. The warning will become an error on October 31, 2025.

- 9c4d383631/setuptools/command/install.py (L58-L67)

> ```python
> SetuptoolsDeprecationWarning.emit(
>     "setup.py install is deprecated.",
>     """
>     Please avoid running ``setup.py`` directly.
>     Instead, use pypa/build, pypa/installer or other
>     standards-based tools.
>     """,
>     see_url="https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html",
>     due_date=(2025, 10, 31),
> )
> ```

- pypa/setuptools#3849

Additional Resource:

- [Why you shouldn't invoke setup.py directly](https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/156027
Approved by: https://github.com/ezyang
This commit is contained in:
Xuehai Pan
2025-07-09 16:16:10 +08:00
committed by PyTorch MergeBot
parent fc0376e8b1
commit 4dce5b71a0
21 changed files with 91 additions and 73 deletions

View File

@ -8,12 +8,12 @@ It also provides mechanisms to compare PyTorch with other frameworks.
Make sure you're on a machine with CUDA, torchvision, and pytorch installed. Install in the following order:
```
# Install torchvision. It comes with the pytorch stable release binary
pip3 install torch torchvision
python -m pip install torch torchvision
# Install the latest pytorch master from source.
# It should supersede the installation from the release binary.
cd $PYTORCH_HOME
python setup.py build develop
python -m pip install --no-build-isolation -v -e .
# Check the pytorch installation version
python -c "import torch; print(torch.__version__)"

View File

@ -17,8 +17,8 @@ export DEBUG=0
export OMP_NUM_THREADS=10
# Compile pytorch with the base revision
git checkout master
python setup.py develop
git checkout main
python -m pip install --no-build-isolation -v -e .
# Install dependencies:
# Scipy is required by detr
@ -32,7 +32,7 @@ python functional_autograd_benchmark.py --output before.txt
# Compile pytorch with your change
popd
git checkout your_feature_branch
python setup.py develop
python -m pip install --no-build-isolation -v -e .
# Run the benchmark for the new version
pushd benchmarks/functional_autograd_benchmark

View File

@ -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 setup.py install
python -m pip install .
```
## How to run the benchmarks:

View File

@ -11,7 +11,7 @@ export USE_MKL=1
CMAKE_ONLY=1 python setup.py build
ccmake build # or cmake-gui build
python setup.py install
python -m pip install --no-build-isolation -v .
cd benchmarks
echo "!! SPARSE SPMM TIME BENCHMARK!! " >> $OUTFILE
@ -28,7 +28,7 @@ echo "----- USE_MKL=0 ------" >> $OUTFILE
rm -rf build
export USE_MKL=0
python setup.py install
python -m pip install --no-build-isolation -v .
cd benchmarks
for dim0 in 1000 5000 10000; do