python-2.7-010-disable_modules_and_ssl.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Support some customisation on python compilation.
  2. With this patch, we can now remove some modules introducing external
  3. dependencies from the compilation, thus removing these irrelevant in most
  4. cases dependencies (ie. openssl, ncurses, etc).
  5. This modules can be removed by listing them in the PYTHON_DISABLE_MODULES
  6. environment variable.
  7. Patch ported to python2.7 by Maxime Ripard <ripard@archos.com>
  8. diff -rduNp Python-2.7.orig/setup.py Python-2.7/setup.py
  9. --- Python-2.7.orig/setup.py 2010-09-21 17:31:52.000000000 +0200
  10. +++ Python-2.7/setup.py 2010-09-21 17:35:20.000000000 +0200
  11. @@ -21,7 +21,15 @@ from distutils.spawn import find_executa
  12. COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
  13. # This global variable is used to hold the list of modules to be disabled.
  14. -disabled_module_list = []
  15. +try:
  16. + disabled_module_list = os.environ["PYTHON_DISABLE_MODULES"].split()
  17. +except KeyError:
  18. + disabled_module_list = list()
  19. +
  20. +try:
  21. + disable_ssl = os.environ["PYTHON_DISABLE_SSL"]
  22. +except KeyError:
  23. + disable_ssl = 0
  24. def add_dir_to_list(dirlist, dir):
  25. """Add the directory 'dir' to the list 'dirlist' (at the front) if
  26. @@ -346,6 +354,7 @@ class PyBuildExt(build_ext):
  27. return sys.platform
  28. def detect_modules(self):
  29. + global disable_ssl
  30. try:
  31. modules_include_dirs = os.environ["PYTHON_MODULES_INCLUDE"].split()
  32. except KeyError:
  33. @@ -685,7 +694,8 @@ class PyBuildExt(build_ext):
  34. ] )
  35. if (ssl_incs is not None and
  36. - ssl_libs is not None):
  37. + ssl_libs is not None and
  38. + not disable_ssl):
  39. exts.append( Extension('_ssl', ['_ssl.c'],
  40. include_dirs = ssl_incs,
  41. library_dirs = ssl_libs,