Description: Remove dependency on astunparse
 It has been replaced with ast.unparse since Python 3.9.
Author: Shengqi Chen <harry-chen@outlook.com>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1086773
Forwarded: not-needed
 Upstream needs it to support python 3.8.
Last-Update: 2024-11-06
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: pytorch/benchmarks/dynamo/Makefile
===================================================================
--- pytorch.orig/benchmarks/dynamo/Makefile
+++ pytorch/benchmarks/dynamo/Makefile
@@ -27,7 +27,7 @@ build-deps: clone-deps
 	# conda env remove --name torchdynamo
 	# conda create --name torchdynamo -y python=3.8
 	# conda activate torchdynamo
-	conda install -y astunparse numpy scipy ninja pyyaml mkl mkl-include setuptools cmake \
+	conda install -y numpy scipy ninja pyyaml mkl mkl-include setuptools cmake \
 		typing-extensions requests protobuf numba cython scikit-learn
 	conda install -y -c pytorch magma-cuda116
 	conda install -y -c conda-forge librosa
Index: pytorch/pyproject.toml
===================================================================
--- pytorch.orig/pyproject.toml
+++ pytorch/pyproject.toml
@@ -2,7 +2,6 @@
 requires = [
     "setuptools",
     "wheel",
-    "astunparse",
     "numpy",
     "ninja",
     "pyyaml",
Index: pytorch/requirements.txt
===================================================================
--- pytorch.orig/requirements.txt
+++ pytorch/requirements.txt
@@ -1,5 +1,4 @@
 # Python dependencies required for development
-astunparse
 expecttest>=0.2.1
 hypothesis
 numpy
Index: pytorch/torch/jit/frontend.py
===================================================================
--- pytorch.orig/torch/jit/frontend.py
+++ pytorch/torch/jit/frontend.py
@@ -74,13 +74,7 @@ from torch.jit._dataclass_impls import D
 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
+_IS_ASTUNPARSE_INSTALLED = True
 
 # Borrowed from cPython implementation
 # https://github.com/python/cpython/blob/561612d8456cfab5672c9b445521113b847bd6b3/Lib/textwrap.py#L411#
@@ -583,7 +577,7 @@ def build_ignore_context_manager(ctx, st
     ignore_function.body.append(return_stmt)  # type: ignore[attr-defined]
 
     # registers the custom function in the global context
-    ignore_func_str = "@torch.jit.ignore\n" + astunparse.unparse(ignore_function)
+    ignore_func_str = "@torch.jit.ignore\n" + ast.unparse(ignore_function)
     ignore_func_str += f'\nglobals()["{ignore_function_name}"] = {ignore_function_name}'
     exec(ignore_func_str)  # noqa: P204
 
