2
1

python3-3.3-000-generate-sysconfigdata-buildir.patch 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. changeset: 79745:f85c3f4d9b98
  2. parent: 79743:36b2ca7dc893
  3. parent: 79744:24d52d3060e8
  4. user: Trent Nelson <trent@trent.me>
  5. date: Tue Oct 16 08:17:11 2012 -0400
  6. summary: Merge issue #15298: ensure _sysconfigdata is generated in build directory,
  7. Taken from upstream.
  8. ---
  9. Lib/sysconfig.py | 11 ++++++++++-
  10. Makefile.pre.in | 24 +++++++++++++-----------
  11. setup.py | 14 --------------
  12. 3 files changed, 23 insertions(+), 26 deletions(-)
  13. Index: Python-3.3.0/Lib/sysconfig.py
  14. ===================================================================
  15. --- Python-3.3.0.orig/Lib/sysconfig.py
  16. +++ Python-3.3.0/Lib/sysconfig.py
  17. @@ -390,13 +390,22 @@
  18. if _PYTHON_BUILD:
  19. vars['LDSHARED'] = vars['BLDSHARED']
  20. - destfile = os.path.join(os.path.dirname(__file__), '_sysconfigdata.py')
  21. + pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version[:3])
  22. + if hasattr(sys, "gettotalrefcount"):
  23. + pybuilddir += '-pydebug'
  24. + os.makedirs(pybuilddir, exist_ok=True)
  25. + destfile = os.path.join(pybuilddir, '_sysconfigdata.py')
  26. +
  27. with open(destfile, 'w', encoding='utf8') as f:
  28. f.write('# system configuration generated and used by'
  29. ' the sysconfig module\n')
  30. f.write('build_time_vars = ')
  31. pprint.pprint(vars, stream=f)
  32. + # Create file used for sys.path fixup -- see Modules/getpath.c
  33. + with open('pybuilddir.txt', 'w', encoding='ascii') as f:
  34. + f.write(pybuilddir)
  35. +
  36. def _init_posix(vars):
  37. """Initialize the module as appropriate for POSIX systems."""
  38. # _sysconfigdata is generated at build time, see _generate_posix_vars()
  39. Index: Python-3.3.0/Makefile.pre.in
  40. ===================================================================
  41. --- Python-3.3.0.orig/Makefile.pre.in
  42. +++ Python-3.3.0/Makefile.pre.in
  43. @@ -410,8 +410,6 @@
  44. Objects/unicodectype.o \
  45. Objects/weakrefobject.o
  46. -SYSCONFIGDATA=$(srcdir)/Lib/_sysconfigdata.py
  47. -
  48. ##########################################################################
  49. # objects that get linked into the Python library
  50. LIBRARY_OBJS_OMIT_FROZEN= \
  51. @@ -432,7 +430,7 @@
  52. # Default target
  53. all: build_all
  54. -build_all: $(BUILDPYTHON) $(SYSCONFIGDATA) oldsharedmods sharedmods gdbhooks Modules/_testembed
  55. +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed
  56. # Compile a binary with gcc profile guided optimization.
  57. profile-opt:
  58. @@ -466,15 +464,17 @@
  59. $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY)
  60. $(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Modules/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
  61. -platform: $(BUILDPYTHON) $(SYSCONFIGDATA)
  62. +platform: $(BUILDPYTHON)
  63. $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform
  64. -# Generate the sysconfig build-time data
  65. -$(SYSCONFIGDATA): $(BUILDPYTHON)
  66. +# Create build directory and generate the sysconfig build-time data there.
  67. +# pybuilddir.txt contains the name of the build dir and is used for
  68. +# sys.path fixup -- see Modules/getpath.c.
  69. +pybuilddir.txt: $(BUILDPYTHON)
  70. $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars
  71. # Build the shared modules
  72. -sharedmods: $(BUILDPYTHON) $(SYSCONFIGDATA)
  73. +sharedmods: $(BUILDPYTHON) pybuilddir.txt
  74. case $$MAKEFLAGS in *s*) quiet=-q; esac; \
  75. $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
  76. $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
  77. @@ -1036,7 +1036,7 @@
  78. else true; \
  79. fi; \
  80. done
  81. - @for i in $(srcdir)/Lib/*.py ; \
  82. + @for i in $(srcdir)/Lib/*.py `cat pybuilddir.txt`/_sysconfigdata.py; \
  83. do \
  84. if test -x $$i; then \
  85. $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
  86. @@ -1196,6 +1196,8 @@
  87. --install-scripts=$(BINDIR) \
  88. --install-platlib=$(DESTSHARED) \
  89. --root=$(DESTDIR)/
  90. + -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata.py
  91. + -rm -r $(DESTDIR)$(DESTSHARED)/__pycache__
  92. # Here are a couple of targets for MacOSX again, to install a full
  93. # framework-based Python. frameworkinstall installs everything, the
  94. @@ -1341,9 +1343,10 @@
  95. find . -name '*.s[ol]' -exec rm -f {} ';'
  96. find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
  97. find build -name 'fficonfig.h' -exec rm -f {} ';' || true
  98. - find build -name 'fficonfig.py' -exec rm -f {} ';' || true
  99. + find build -name '*.py' -exec rm -f {} ';' || true
  100. + find build -name '*.py[co]' -exec rm -f {} ';' || true
  101. + -rm -f pybuilddir.txt
  102. -rm -f Lib/lib2to3/*Grammar*.pickle
  103. - -rm -f $(SYSCONFIGDATA)
  104. -rm -f Modules/_testembed Modules/_freeze_importlib
  105. profile-removal:
  106. @@ -1367,7 +1370,6 @@
  107. Modules/Setup Modules/Setup.local Modules/Setup.config \
  108. Modules/ld_so_aix Modules/python.exp Misc/python.pc
  109. -rm -f python*-gdb.py
  110. - -rm -f pybuilddir.txt
  111. find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
  112. -o -name '[@,#]*' -o -name '*.old' \
  113. -o -name '*.orig' -o -name '*.rej' \
  114. Index: Python-3.3.0/setup.py
  115. ===================================================================
  116. --- Python-3.3.0.orig/setup.py
  117. +++ Python-3.3.0/setup.py
  118. @@ -33,10 +33,6 @@
  119. # This global variable is used to hold the list of modules to be disabled.
  120. disabled_module_list = []
  121. -# File which contains the directory for shared mods (for sys.path fixup
  122. -# when running from the build dir, see Modules/getpath.c)
  123. -_BUILDDIR_COOKIE = "pybuilddir.txt"
  124. -
  125. def add_dir_to_list(dirlist, dir):
  126. """Add the directory 'dir' to the list 'dirlist' (after any relative
  127. directories) if:
  128. @@ -252,16 +248,6 @@
  129. args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
  130. self.compiler.set_executables(**args)
  131. - # Not only do we write the builddir cookie, but we manually install
  132. - # the shared modules directory if it isn't already in sys.path.
  133. - # Otherwise trying to import the extensions after building them
  134. - # will fail.
  135. - with open(_BUILDDIR_COOKIE, "wb") as f:
  136. - f.write(self.build_lib.encode('utf-8', 'surrogateescape'))
  137. - abs_build_lib = os.path.join(os.getcwd(), self.build_lib)
  138. - if abs_build_lib not in sys.path:
  139. - sys.path.append(abs_build_lib)
  140. -
  141. build_ext.build_extensions(self)
  142. longest = max([len(e.name) for e in self.extensions])