41814568b561653f3a56446c6d702086e9340802
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / python3 / 102-optional-2to3.patch
1 Add an option to disable lib2to3
2
3 lib2to3 is a library to convert Python 2.x code to Python 3.x. As
4 such, it is probably not very useful on embedded system targets.
5
6 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7 Signed-off-by: Samuel Martin <s.martin49@gmail.com>
8
9 ---
10  Makefile.pre.in |   18 ++++++++++++++----
11  configure.ac    |    6 ++++++
12  setup.py        |    5 +++--
13  3 files changed, 23 insertions(+), 6 deletions(-)
14
15 Index: b/Makefile.pre.in
16 ===================================================================
17 --- a/Makefile.pre.in
18 +++ b/Makefile.pre.in
19 @@ -1107,7 +1107,9 @@
20         (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
21  endif
22         -rm -f $(DESTDIR)$(BINDIR)/2to3
23 +ifeq (@LIB2TO3@,yes)
24         (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
25 +endif
26         -rm -f $(DESTDIR)$(BINDIR)/pyvenv
27         (cd $(DESTDIR)$(BINDIR); $(LN) -s pyvenv-$(VERSION) pyvenv)
28         if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
29 @@ -1147,7 +1149,6 @@
30                 html json http dbm xmlrpc \
31                 sqlite3 \
32                 logging csv wsgiref urllib \
33 -               lib2to3 lib2to3/fixes lib2to3/pgen2 \
34                 ctypes ctypes/macholib \
35                 idlelib idlelib/Icons \
36                 distutils distutils/command $(XMLLIBSUBDIRS) \
37 @@ -1189,9 +1190,6 @@
38                  test/test_importlib/namespace_pkgs/module_and_namespace_package \
39                  test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test \
40                 sqlite3/test \
41 -               lib2to3/tests \
42 -               lib2to3/tests/data lib2to3/tests/data/fixers \
43 -               lib2to3/tests/data/fixers/myfixes \
44                 ctypes/test \
45                 idlelib/idle_test \
46                 distutils/tests \
47 @@ -1204,6 +1202,14 @@
48  LIBSUBDIRS += pydoc_data
49  endif
50  
51 +ifeq (@LIB2TO3@,yes)
52 +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
53 +TESTSUBDIRS += lib2to3/tests                   \
54 +       lib2to3/tests/data                      \
55 +       lib2to3/tests/data/fixers               \
56 +       lib2to3/tests/data/fixers/myfixes
57 +endif
58 +
59  ifeq (@TEST_MODULES@,yes)
60  LIBSUBDIRS += $(TESTSUBDIRS)
61  endif
62 @@ -1299,10 +1305,12 @@
63                 -d $(LIBDEST)/site-packages -f $(STDLIB_CACHE_FLAGS) \
64                 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
65  endif
66 +ifeq (@LIB2TO3@,yes)
67         -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
68                 $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
69         -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
70                 $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
71 +endif
72  
73  # Create the PLATDIR source directory, if one wasn't distributed..
74  $(srcdir)/Lib/$(PLATDIR):
75 Index: b/setup.py
76 ===================================================================
77 --- a/setup.py
78 +++ b/setup.py
79 @@ -2201,10 +2201,11 @@
80      import warnings
81      warnings.filterwarnings("ignore",category=DeprecationWarning)
82  
83 -    scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
84 -               'Lib/smtpd.py']
85 +    scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
86      if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
87          scripts += [ 'Tools/scripts/pydoc3' ]
88 +    if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
89 +        scripts += [ 'Tools/scripts/2to3' ]
90  
91      setup(# PyPI Metadata (PEP 301)
92            name = "Python",
93 Index: b/configure.ac
94 ===================================================================
95 --- a/configure.ac
96 +++ b/configure.ac
97 @@ -2687,6 +2687,12 @@
98         AS_HELP_STRING([--disable-test-modules], [disable test modules]),
99         [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
100  
101 +AC_SUBST(LIB2TO3)
102 +
103 +AC_ARG_ENABLE(lib2to3,
104 +       AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
105 +       [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
106 +
107  # Check for enable-ipv6
108  AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
109  AC_MSG_CHECKING([if --enable-ipv6 is specified])