mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[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:
committed by
PyTorch MergeBot
parent
fc0376e8b1
commit
4dce5b71a0
32
setup.py
32
setup.py
@ -263,6 +263,7 @@ import json
|
||||
import shutil
|
||||
import subprocess
|
||||
import sysconfig
|
||||
import textwrap
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
@ -601,7 +602,7 @@ def build_deps() -> None:
|
||||
report(
|
||||
'Finished running cmake. Run "ccmake build" or '
|
||||
'"cmake-gui build" to adjust build options and '
|
||||
'"python setup.py install" to build.'
|
||||
'"python -m pip install --no-build-isolation -v ." to build.'
|
||||
)
|
||||
sys.exit()
|
||||
|
||||
@ -1207,24 +1208,25 @@ def configure_extension_build() -> tuple[
|
||||
|
||||
# post run, warnings, printed at the end to make them more visible
|
||||
build_update_message = """
|
||||
It is no longer necessary to use the 'build' or 'rebuild' targets
|
||||
It is no longer necessary to use the 'build' or 'rebuild' targets
|
||||
|
||||
To install:
|
||||
$ python setup.py install
|
||||
To develop locally:
|
||||
$ python setup.py develop
|
||||
To force cmake to re-generate native build files (off by default):
|
||||
$ CMAKE_FRESH=1 python setup.py develop
|
||||
"""
|
||||
To install:
|
||||
$ python -m pip install --no-build-isolation -v .
|
||||
To develop locally:
|
||||
$ python -m pip install --no-build-isolation -v -e .
|
||||
To force cmake to re-generate native build files (off by default):
|
||||
$ CMAKE_FRESH=1 python -m pip install --no-build-isolation -v -e .
|
||||
""".strip()
|
||||
|
||||
|
||||
def print_box(msg: str) -> None:
|
||||
lines = msg.split("\n")
|
||||
size = max(len(l) + 1 for l in lines)
|
||||
print("-" * (size + 2))
|
||||
for l in lines:
|
||||
print("|{}{}|".format(l, " " * (size - len(l))))
|
||||
print("-" * (size + 2))
|
||||
msg = textwrap.dedent(msg).strip()
|
||||
lines = ["", *msg.split("\n"), ""]
|
||||
max_width = max(len(l) for l in lines)
|
||||
print("+" + "-" * (max_width + 4) + "+", file=sys.stderr, flush=True)
|
||||
for line in lines:
|
||||
print(f"| {line:<{max_width}s} |", file=sys.stderr, flush=True)
|
||||
print("+" + "-" * (max_width + 4) + "+", file=sys.stderr, flush=True)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
Reference in New Issue
Block a user