aboutsummaryrefslogtreecommitdiff
path: root/examples/python2.7/patches/sysconfigdata.diff
blob: a91bf8e935f40c8b0b9b30ac8370f435f076e1cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Index: b/Lib/sysconfig.py
===================================================================
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -330,9 +330,10 @@
         return os.path.join(_PROJECT_BASE, "Makefile")
     return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile")
 
-
-def _init_posix(vars):
-    """Initialize the module as appropriate for POSIX systems."""
+def _generate_posix_vars():
+    """Generate the Python module containing build-time variables."""
+    import pprint
+    vars = {}
     # load the installed Makefile:
     makefile = _get_makefile_filename()
     try:
@@ -360,6 +361,19 @@
     if _PYTHON_BUILD:
         vars['LDSHARED'] = vars['BLDSHARED']
 
+    destfile = '_sysconfigdata.py'
+    with open(destfile, 'w') as f:
+        f.write('# system configuration generated and used by'
+                ' the sysconfig module\n')
+        f.write('build_time_vars = ')
+        pprint.pprint(vars, stream=f)
+
+def _init_posix(vars):
+    """Initialize the module as appropriate for POSIX systems."""
+    # _sysconfigdata is generated at build time, see _generate_posix_vars()
+    from _sysconfigdata import build_time_vars
+    vars.update(build_time_vars)
+
 def _init_non_posix(vars):
     """Initialize the module as appropriate for NT"""
     # set basic install directories
Index: b/Makefile.pre.in
===================================================================
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -374,7 +374,7 @@
 
 # Default target
 all:		build_all
-build_all:	$(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
+build_all:	$(BUILDPYTHON) $(SYSCONFIGDATA) oldsharedmods sharedmods gdbhooks
 
 # Compile a binary with gcc profile guided optimization.
 profile-opt:
@@ -402,6 +402,7 @@
 	$(MAKE) clean
 	$(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
 
+SYSCONFIGDATA=_sysconfigdata.py
 
 # Build the interpreter
 $(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY)
@@ -409,14 +410,20 @@
 			Modules/python.o \
 			-Wl,--whole-archive $(BLDLIBRARY) -Wl,--no-whole-archive $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
 
-platform: $(BUILDPYTHON)
+platform: $(BUILDPYTHON) $(SYSCONFIGDATA)
 	$(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
 
+# Generate the sysconfig build-time data
+$(SYSCONFIGDATA): $(BUILDPYTHON)
+	$(RUNSHARED) ./$(BUILDPYTHON) -SE -c 'import sysconfig; sysconfig._generate_posix_vars()'
+	$(RUNSHARED) ./$(BUILDPYTHON) -S -c 'import os,sys ; from distutils.util import get_platform ; d=os.path.join("build", "lib."+get_platform()+"-"+sys.version[0:3]+("-pydebug" if hasattr(sys, "gettotalrefcount") else "")); sys.stdout.write(d)' > pybuilddir.txt
+	mkdir -p `cat pybuilddir.txt`
+	cp $(SYSCONFIGDATA) `cat pybuilddir.txt`/.
 
 # Build the shared modules
 # MAKEFLAGS are sorted and normalized. Under GNU make the 's' for
 # -s, --silent or --quiet is always the first char.
-sharedmods: $(BUILDPYTHON)
+sharedmods: $(BUILDPYTHON) $(SYSCONFIGDATA)
 	@case "$$MAKEFLAGS" in \
 	    s*) quiet="-q";; \
 	    *) quiet="";; \
@@ -910,7 +917,7 @@
 		else	true; \
 		fi; \
 	done
-	@for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
+	@for i in $(srcdir)/Lib/*.py $(SYSCONFIGDATA) $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
 	do \
 		if test -x $$i; then \
 			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \