diff --git a/.ci/docker/requirements-ci.txt b/.ci/docker/requirements-ci.txt index 7b069a5706c4..5c21ababddc6 100644 --- a/.ci/docker/requirements-ci.txt +++ b/.ci/docker/requirements-ci.txt @@ -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" diff --git a/.ci/pytorch/macos-test.sh b/.ci/pytorch/macos-test.sh index 57549a7d63e1..83f8e4e04331 100755 --- a/.ci/pytorch/macos-test.sh +++ b/.ci/pytorch/macos-test.sh @@ -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 } diff --git a/benchmarks/dynamo/Makefile b/benchmarks/dynamo/Makefile index c62773280bc2..c5a0a20aaa69 100644 --- a/benchmarks/dynamo/Makefile +++ b/benchmarks/dynamo/Makefile @@ -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 .) diff --git a/pyproject.toml b/pyproject.toml index a2939483fc35..265470c6bb92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/requirements.txt b/requirements.txt index 9bd9b5425814..7af83c0a8c39 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/test/jit/test_ignore_context_manager.py b/test/jit/test_ignore_context_manager.py index 59b27cba52a7..98fb3e7e21d2 100644 --- a/test/jit/test_ignore_context_manager.py +++ b/test/jit/test_ignore_context_manager.py @@ -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): diff --git a/torch/jit/frontend.py b/torch/jit/frontend.py index f6f4d99918fa..518eb7df2749 100644 --- a/torch/jit/frontend.py +++ b/torch/jit/frontend.py @@ -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))