gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / python-cross-compile.patch
1 Patch taken from https://bugs.python.org/issue22724 and augmented with
2 following Nix patch
3 https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/python/cpython/2.7/cross-compile.patch
4 to fix the whole cross-compilation circus.
5
6 ---
7 Makefile.pre.in | 14 +++++++-------
8 configure | 5 ++++-
9 setup.py | 9 ++++++---
10 3 files changed, 17 insertions(+), 11 deletions(-)
11
12 diff --git a/Makefile.pre.in b/Makefile.pre.in
13 index 2a14f3323b..6239fc32fc 100644
14 --- a/Makefile.pre.in
15 +++ b/Makefile.pre.in
16 @@ -492,7 +492,7 @@ $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
17 $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
18
19 platform: $(BUILDPYTHON) pybuilddir.txt
20 - $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
21 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
22
23 # Create build directory and generate the sysconfig build-time data there.
24 # pybuilddir.txt contains the name of the build dir and is used for
25 @@ -503,7 +503,7 @@ platform: $(BUILDPYTHON) pybuilddir.txt
26 # or removed in case of failure.
27 pybuilddir.txt: $(BUILDPYTHON)
28 @echo "none" > ./pybuilddir.txt
29 - $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
30 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
31 if test $$? -ne 0 ; then \
32 echo "generate-posix-vars failed" ; \
33 rm -f ./pybuilddir.txt ; \
34 @@ -525,7 +525,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
35 esac; \
36 $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
37 _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
38 - $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
39 + $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
40
41 # Build static library
42 # avoid long command lines, same as LIBRARY_OBJS
43 @@ -928,7 +928,7 @@ install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKI
44 upgrade) ensurepip="--upgrade" ;; \
45 install|*) ensurepip="" ;; \
46 esac; \
47 - $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
48 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -m ensurepip \
49 $$ensurepip --root=$(DESTDIR)/ ; \
50 fi
51
52 @@ -939,7 +939,7 @@ altinstall: commoninstall
53 upgrade) ensurepip="--altinstall --upgrade --no-default-pip" ;; \
54 install|*) ensurepip="--altinstall --no-default-pip" ;; \
55 esac; \
56 - $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
57 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -m ensurepip \
58 $$ensurepip --root=$(DESTDIR)/ ; \
59 fi
60
61 @@ -1270,7 +1270,7 @@ libainstall: @DEF_MAKE_RULE@ python-config
62 # Install the dynamically loadable modules
63 # This goes into $(exec_prefix)
64 sharedinstall: sharedmods
65 - $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
66 + $(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
67 --prefix=$(prefix) \
68 --install-scripts=$(BINDIR) \
69 --install-platlib=$(DESTSHARED) \
70 @@ -1344,7 +1344,7 @@ frameworkinstallextras:
71 # This installs a few of the useful scripts in Tools/scripts
72 scriptsinstall:
73 SRCDIR=$(srcdir) $(RUNSHARED) \
74 - $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
75 + $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
76 --prefix=$(prefix) \
77 --install-scripts=$(BINDIR) \
78 --root=$(DESTDIR)/
79 diff --git a/configure b/configure
80 index 67300fe2b6..6050f588c5 100755
81 --- a/configure
82 +++ b/configure
83 @@ -741,6 +741,7 @@ CONFIG_ARGS
84 SOVERSION
85 VERSION
86 PYTHON_FOR_BUILD
87 +PY_BUILD_ENVIRON
88 PYTHON_FOR_REGEN
89 host_os
90 host_vendor
91 @@ -2964,7 +2965,8 @@ $as_echo_n "checking for python interpreter for cross build... " >&6; }
92 fi
93 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5
94 $as_echo "$interp" >&6; }
95 - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp
96 + PY_BUILD_ENVIRON='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR)'
97 + PYTHON_FOR_BUILD=$interp
98 fi
99 elif test "$cross_compiling" = maybe; then
100 as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5
101 @@ -2974,6 +2976,7 @@ fi
102
103
104
105 +
106 if test "$prefix" != "/"; then
107 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
108 fi
109 diff --git a/setup.py b/setup.py
110 index cb47a2339c..472e7e2b26 100644
111 --- a/setup.py
112 +++ b/setup.py
113 @@ -497,8 +497,6 @@ class PyBuildExt(build_ext):
114 if not cross_compiling:
115 add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
116 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
117 - if cross_compiling:
118 - self.add_gcc_paths()
119 self.add_multiarch_paths()
120
121 # Add paths specified in the environment variables LDFLAGS and
122 @@ -556,7 +554,10 @@ class PyBuildExt(build_ext):
123 # be assumed that no additional -I,-L directives are needed.
124 inc_dirs = self.compiler.include_dirs[:]
125 lib_dirs = self.compiler.library_dirs[:]
126 - if not cross_compiling:
127 + if cross_compiling:
128 + inc_dirs = []
129 + lib_dirs = []
130 + else:
131 for d in (
132 '/usr/include',
133 ):
134 @@ -621,6 +622,8 @@ class PyBuildExt(build_ext):
135 # Some modules that are normally always on:
136 #exts.append( Extension('_weakref', ['_weakref.c']) )
137
138 + self.compiler.library_dirs = lib_dirs + [ '.' ]
139 +
140 # array objects
141 exts.append( Extension('array', ['arraymodule.c']) )
142
143 --
144 2.17.1
145