mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE][Easy] remove unused build-time dependency astunparse
and change astunparse.unparse
-> ast.unparse
(#157907)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157907 Approved by: https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
ba0d0de5e6
commit
af3d069094
@ -363,10 +363,11 @@ pwlf==2.2.1
|
||||
|
||||
|
||||
# To build PyTorch itself
|
||||
astunparse
|
||||
PyYAML
|
||||
pyyaml
|
||||
pyzstd
|
||||
setuptools
|
||||
six
|
||||
wheel
|
||||
|
||||
scons==4.5.2 ; platform_machine == "aarch64"
|
||||
|
||||
|
@ -185,7 +185,7 @@ torchbench_setup_macos() {
|
||||
}
|
||||
|
||||
pip_benchmark_deps() {
|
||||
python -mpip install --no-input astunparse requests cython scikit-learn
|
||||
python -mpip install --no-input requests cython scikit-learn six
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ pull-deps: clone-deps
|
||||
(cd ../../../torchbenchmark && git fetch && git checkout "$$(cat ../pytorch/.github/ci_commit_pins/torchbench.txt)" && git submodule update --init --recursive)
|
||||
|
||||
build-deps: clone-deps
|
||||
uv pip install astunparse numpy scipy ninja pyyaml mkl mkl-include setuptools cmake \
|
||||
uv pip install numpy scipy ninja pyyaml six mkl mkl-include setuptools wheel cmake \
|
||||
typing-extensions requests protobuf numba cython scikit-learn librosa
|
||||
(cd ../../../torchvision && uv pip install -e . --no-build-isolation)
|
||||
(cd ../../../torchdata && uv pip install -e .)
|
||||
|
@ -9,13 +9,13 @@ requires = [
|
||||
# 77.0.0: min version for SPDX expression support for project.license
|
||||
"setuptools>=62.3.0,<80.0",
|
||||
"wheel",
|
||||
"astunparse",
|
||||
"cmake>=3.27",
|
||||
"ninja",
|
||||
"numpy",
|
||||
"packaging",
|
||||
"pyyaml",
|
||||
"requests",
|
||||
"six", # dependency chain: NNPACK -> PeachPy -> six
|
||||
"typing-extensions>=4.10.0",
|
||||
]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
@ -1,5 +1,4 @@
|
||||
# Python dependencies required for development
|
||||
astunparse
|
||||
build[uv] # for building sdist and wheel
|
||||
cmake>=3.27
|
||||
expecttest>=0.3.0
|
||||
@ -18,6 +17,8 @@ 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
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import torch
|
||||
|
||||
@ -10,13 +9,11 @@ import torch
|
||||
# Make the helper files in test/ importable
|
||||
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
sys.path.append(pytorch_test_dir)
|
||||
from torch.jit.frontend import _IS_ASTUNPARSE_INSTALLED
|
||||
from torch.testing._internal.common_utils import raise_on_run_directly
|
||||
from torch.testing._internal.jit_utils import JitTestCase
|
||||
|
||||
|
||||
class TestIgnoreContextManager(JitTestCase):
|
||||
@unittest.skipUnless(_IS_ASTUNPARSE_INSTALLED, "astunparse package is required")
|
||||
def test_with_ignore_context_manager_with_inp_out(self):
|
||||
class A(torch.nn.Module):
|
||||
def forward(self):
|
||||
@ -68,7 +65,6 @@ class TestIgnoreContextManager(JitTestCase):
|
||||
self.assertEqual(s(), 6)
|
||||
self.assertEqual(s(), model())
|
||||
|
||||
@unittest.skipUnless(_IS_ASTUNPARSE_INSTALLED, "astunparse package is required")
|
||||
def test_with_ignore_context_manager_with_just_inp(self):
|
||||
class A(torch.nn.Module):
|
||||
def forward(self):
|
||||
@ -83,7 +79,6 @@ class TestIgnoreContextManager(JitTestCase):
|
||||
self.assertEqual(s(), 4)
|
||||
self.assertEqual(s(), model())
|
||||
|
||||
@unittest.skipUnless(_IS_ASTUNPARSE_INSTALLED, "astunparse package is required")
|
||||
def test_with_ignore_context_manager_with_just_out(self):
|
||||
class A(torch.nn.Module):
|
||||
def forward(self):
|
||||
|
@ -73,14 +73,6 @@ from torch.jit._dataclass_impls import DATACLASS_MAGIC_METHODS
|
||||
from torch.jit._monkeytype_config import get_qualified_name, monkeytype_trace
|
||||
|
||||
|
||||
_IS_ASTUNPARSE_INSTALLED = False
|
||||
try:
|
||||
import astunparse # type: ignore[import]
|
||||
|
||||
_IS_ASTUNPARSE_INSTALLED = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Borrowed from cPython implementation
|
||||
# https://github.com/python/cpython/blob/561612d8456cfab5672c9b445521113b847bd6b3/Lib/textwrap.py#L411#
|
||||
|
||||
@ -591,7 +583,7 @@ def build_ignore_context_manager(ctx, stmt):
|
||||
from typing import List, Dict, Tuple
|
||||
|
||||
@torch.jit.ignore
|
||||
{astunparse.unparse(ignore_function)}
|
||||
{ast.unparse(ignore_function)}
|
||||
"""
|
||||
g = copy.copy(globals())
|
||||
exec(ignore_func_str, g) # noqa: P204
|
||||
@ -846,11 +838,6 @@ class StmtBuilder(Builder):
|
||||
r = ctx.make_range(stmt.lineno, stmt.col_offset, stmt.col_offset + len("with"))
|
||||
# Handle ignore context manager
|
||||
if is_torch_jit_ignore_context_manager(stmt):
|
||||
if not _IS_ASTUNPARSE_INSTALLED:
|
||||
raise RuntimeError(
|
||||
"torch.jit._IgnoreContextManager requires installing Python library `astunparse`, \
|
||||
please install it in your Python environment"
|
||||
)
|
||||
assign_ast = build_ignore_context_manager(ctx, stmt)
|
||||
return build_stmt(ctx, assign_ast)
|
||||
return With(r, build_withitems(ctx, stmt.items), build_stmts(ctx, stmt.body))
|
||||
|
Reference in New Issue
Block a user