Skip to content

Commit febd6f9

Browse files
committed
Use fissix to replace lib2to3 under Python >=3.13
Add entries to `sys.modules` so that `future`/`past` can find lib2to3 modules.
1 parent ac480e7 commit febd6f9

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

lib/galaxy/dependencies/pinned-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ email-validator==2.2.0
6666
exceptiongroup==1.2.2 ; python_full_version < '3.11'
6767
fastapi-slim==0.115.4
6868
filelock==3.16.1
69+
fissix==24.4.24 ; python_full_version >= '3.13'
6970
frozenlist==1.5.0
7071
fs==2.4.16
7172
fsspec==2024.10.0

lib/galaxy/util/template.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
"""Entry point for the usage of Cheetah templating within Galaxy."""
22

3+
import sys
34
import traceback
4-
from lib2to3.refactor import RefactoringTool
55

66
from Cheetah.Compiler import Compiler
77
from Cheetah.NameMapper import NotFound
88
from Cheetah.Parser import ParseError
99
from Cheetah.Template import Template
1010
from packaging.version import Version
11-
from past.translation import myfixes
1211

1312
from galaxy.util.tree_dict import TreeDict
1413
from . import unicodify
1514

15+
if sys.version_info >= (3, 13):
16+
import fissix
17+
from fissix import (
18+
fixes as fissix_fixes,
19+
pgen2 as fissix_pgen2,
20+
refactor as fissix_refactor,
21+
)
22+
23+
sys.modules["lib2to3"] = fissix
24+
sys.modules["lib2to3.fixes"] = fissix_fixes
25+
sys.modules["lib2to3.pgen2"] = fissix_pgen2
26+
sys.modules["lib2to3.refactor"] = fissix_refactor
27+
28+
from lib2to3.refactor import RefactoringTool
29+
30+
from past.translation import myfixes
31+
1632
# Skip libpasteurize fixers, which make sure code is py2 and py3 compatible.
1733
# This is not needed, we only translate code on py3.
1834
myfixes = [f for f in myfixes if not f.startswith("libpasteurize")]

packages/util/setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jstree =
5454
dictobj
5555
template =
5656
CT3>=3.3.3
57+
fissix;python_version>='3.13'
5758
future>=1.0.0
5859
config_template =
5960
Jinja2

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies = [
3737
"dparse",
3838
"edam-ontology",
3939
"fastapi-slim>=0.111.0",
40+
"fissix ; python_version>='3.13'",
4041
"fs",
4142
"future>=1.0.0", # Python 3.12 support
4243
"graphene",

0 commit comments

Comments
 (0)