python-2.7-008-reread-environment.patch 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Make sure setup.py reads the correct CONFIG_ARGS
  2. The setup.py script that builds and installs all the Python modules
  3. shipped with the interpreter looks at the CONFIG_ARGS variable stored
  4. in the "sysconfig" module to look at the ./configure options and
  5. adjust its behaviour accordingly.
  6. Unfortunately, when cross-compiling, the value of CONFIG_ARGS returned
  7. by the sysconfig are the one passed to the ./configure script of the
  8. *host* Python and not the one we're currently building for the target.
  9. In order to avoid that, we re-initialize the values in the sysconfig
  10. module by re-reading the environment at the beginning of the setup.py
  11. script, and we make sure that the CONFIG_ARGS variable is actually
  12. part of the environment of setup.py.
  13. See the beginning of
  14. http://article.gmane.org/gmane.comp.python.devel/99772 for the
  15. inspiration.
  16. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  17. ---
  18. Makefile.pre.in | 6 +++---
  19. setup.py | 3 +++
  20. 2 files changed, 6 insertions(+), 3 deletions(-)
  21. Index: Python-2.7.2/Makefile.pre.in
  22. ===================================================================
  23. --- Python-2.7.2.orig/Makefile.pre.in
  24. +++ Python-2.7.2/Makefile.pre.in
  25. @@ -411,8 +411,8 @@
  26. # Build the shared modules
  27. sharedmods: $(BUILDPYTHON)
  28. @case $$MAKEFLAGS in \
  29. - *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py -q build;; \
  30. - *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py build;; \
  31. + *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" CONFIG_ARGS="$(CONFIG_ARGS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py -q build;; \
  32. + *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" CONFIG_ARGS="$(CONFIG_ARGS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py build;; \
  33. esac
  34. # Build static library
  35. @@ -1044,7 +1044,7 @@
  36. # Install the dynamically loadable modules
  37. # This goes into $(exec_prefix)
  38. sharedinstall: sharedmods
  39. - $(RUNSHARED) CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py install \
  40. + $(RUNSHARED) CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" CONFIG_ARGS="$(CONFIG_ARGS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py install \
  41. --prefix=$(prefix) \
  42. --install-scripts=$(BINDIR) \
  43. --install-platlib=$(DESTSHARED) \
  44. Index: Python-2.7.2/setup.py
  45. ===================================================================
  46. --- Python-2.7.2.orig/setup.py
  47. +++ Python-2.7.2/setup.py
  48. @@ -20,6 +20,9 @@
  49. # Were we compiled --with-pydebug or with #define Py_DEBUG?
  50. COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
  51. +sysconfig.get_config_vars()
  52. +sysconfig._CONFIG_VARS.update(os.environ)
  53. +
  54. # This global variable is used to hold the list of modules to be disabled.
  55. try:
  56. disabled_module_list = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ")