build: Add fallback commands to setup.py (#162009)

Adds fallback commands for the following:
* python setup.py install
* python setup.py develop

Ideally these should just work and should provide backwards compat.

Thought process here is that multiple people rely on these commands and just because setuptools wants to drop support for this I don't think a lot of our downstream users who build from source are expecting these to be gone.

This should provide some room for developers to move away from these commands until we have a unified frontend for doing all of these commands that should abstract most of these away.

Signed-off-by: Eli Uriegas <eliuriegas@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/162009
Approved by: https://github.com/clee2000, https://github.com/atalman
This commit is contained in:
Eli Uriegas
2025-09-02 16:39:21 -07:00
committed by PyTorch MergeBot
parent d5643e8f3a
commit 0447f2d99b

View File

@ -420,6 +420,41 @@ for i, arg in enumerate(sys.argv):
if arg == "rebuild" or arg == "build":
arg = "build" # rebuild is gone, make it build
EMIT_BUILD_WARNING = True
if arg == "develop":
print(
(
"WARNING: Redirecting 'python setup.py develop' to 'pip install -e . -v --no-build-isolation',"
" for more info see https://github.com/pytorch/pytorch/issues/152276"
),
file=sys.stderr,
)
result = subprocess.run(
[
sys.executable,
"-m",
"pip",
"install",
"-e",
".",
"-v",
"--no-build-isolation",
],
env={**os.environ},
)
sys.exit(result.returncode)
if arg == "install":
print(
(
"WARNING: Redirecting 'python setup.py install' to 'pip install . -v --no-build-isolation',"
" for more info see https://github.com/pytorch/pytorch/issues/152276"
),
file=sys.stderr,
)
result = subprocess.run(
[sys.executable, "-m", "pip", "install", ".", "-v", "--no-build-isolation"],
env={**os.environ},
)
sys.exit(result.returncode)
if arg == "--":
filtered_args += sys.argv[i:]
break