Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:raulgs:gtk2_win
mingw32-python
Python-2.7.18-cross.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File Python-2.7.18-cross.patch of Package mingw32-python
diff -ubBr Python-2.7.18.orig/configure.ac Python-2.7.18/configure.ac --- Python-2.7.18.orig/configure.ac 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/configure.ac 2021-08-21 15:42:17.997177096 +0200 @@ -340,6 +340,9 @@ *-*-cygwin*) ac_sys_system=Cygwin ;; + *-*-mingw32*) + ac_sys_system=mingw + ;; *) # for now, limit cross builds to known configurations MACHDEP="unknown" @@ -364,6 +367,7 @@ case $MACHDEP in linux*) MACHDEP="linux2";; cygwin*) MACHDEP="cygwin";; + mingw*) MACHDEP="mingw";; darwin*) MACHDEP="darwin";; atheos*) MACHDEP="atheos";; irix646) MACHDEP="irix6";; @@ -386,6 +390,9 @@ *-*-cygwin*) _host_cpu= ;; + *-*-mingw32*) + _host_cpu= + ;; *) # for now, limit cross builds to known configurations MACHDEP="unknown" @@ -514,7 +521,7 @@ AC_SUBST(PLATDIR) PLATDIR=plat-$MACHDEP -# And add extra plat-mac for darwin +# And add extra plat-mac for Darwin AC_SUBST(EXTRAPLATDIR) AC_SUBST(EXTRAMACHDEPPATH) AC_MSG_CHECKING(EXTRAPLATDIR) @@ -533,6 +540,23 @@ fi AC_MSG_RESULT($EXTRAPLATDIR) +AC_MSG_CHECKING(posix flavour) +if test -z "$POSIX" +then + case $ac_sys_system/$ac_sys_release in + mingw*) + DELIM=';' + POSIX=nt + ;; + *) + DELIM=':' + POSIX=posix + ;; + esac + fi +AC_SUBST(DELIM) +AC_MSG_RESULT($POSIX) + # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, # it may influence the way we can build extensions, so distutils # needs to check it @@ -749,9 +773,11 @@ then AC_MSG_RESULT(yes) BUILDEXEEXT=.exe + case_sensitive=no else AC_MSG_RESULT(no) BUILDEXEEXT=$EXEEXT + case_sensitive=yes fi rmdir CaseSensitiveTestDir @@ -861,7 +887,7 @@ if test -z "$enable_shared" then case $ac_sys_system in - CYGWIN* | atheos*) + CYGWIN* | atheos* | mingw*) enable_shared="yes";; *) enable_shared="no";; @@ -917,6 +943,10 @@ LDLIBRARY='libpython$(VERSION).dll.a' DLLLIBRARY='libpython$(VERSION).dll' ;; + mingw*) + LDLIBRARY='libpython$(VERSION).dll.a' + DLLLIBRARY='libpython$(VERSION).dll' + ;; SunOS*) LDLIBRARY='libpython$(VERSION).so' BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)' @@ -973,6 +1003,10 @@ BLDLIBRARY='$(LIBRARY)' LDLIBRARY='libpython$(VERSION).dll.a' ;; + mingw*) + BLDLIBRARY='$(LIBRARY)' + LDLIBRARY='libpython$(VERSION).dll.a' + ;; esac fi @@ -1281,6 +1315,9 @@ OSF*) BASECFLAGS="$BASECFLAGS -mieee" ;; + mingw*) + OPT="-DMS_WINDOWS -DPy_WIN_WIDE_FILENAMES $OPT" + ;; esac ;; @@ -1337,7 +1374,7 @@ if test $ac_cv_opt_olimit_ok = yes; then case $ac_sys_system in # XXX is this branch needed? On MacOSX 10.2.2 the result of the - # olimit_ok test is "no". Is it "yes" in some other Darwin-esque + # olimit_ok test is "no". Is it "yes" in some other darwin-esque # environment? Darwin*) ;; @@ -2130,6 +2167,7 @@ esac ;; CYGWIN*) SO=.dll;; + mingw*) SO=.dll;; *) SO=.so;; esac else @@ -2290,6 +2328,9 @@ atheos*) LDSHARED="gcc -shared" LDCXXSHARED="g++ -shared";; + mingw*) + LDSHARED='$(CC) -mdll' + BLDSHARED='$(CC) -mdll libpython$(VERSION).dll';; *) LDSHARED="ld";; esac fi @@ -2381,6 +2422,11 @@ then LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)' fi;; + mingw*) + if test $enable_shared = "no" + then + LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)' + fi;; QNX*) # -Wl,-E causes the symbols to be added to the dynamic # symbol table so that they can be found when a module @@ -2465,6 +2511,16 @@ # BeOS' sockets are stashed in libnet. AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets +AC_CHECK_HEADER(winsock2.h) +AC_CHECK_LIB(wsock32, select, [LIBS="-lws2_32 -lwsock32 $LIBS"], [], $LIBS) # Mingw32 select +save_LIBS="$LIBS" +LIBS="-lws2_32 -lwsock32 $LIBS" +AC_MSG_CHECKING([for include <winsock2.h> select in libwinsock32]) +AC_TRY_LINK([#include <winsock2.h>], + [select (1,2,3,4,5);], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] + [LIBS="$save_LIBS"]) case "$ac_sys_system" in BeOS*) @@ -3093,6 +3149,7 @@ # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";; atheos*) DYNLOADFILE="dynload_atheos.o";; + mingw*) DYNLOADFILE="dynload_win.o";; *) # use dynload_shlib.c and dlopen() if we have it; otherwise stub # out any dynamic loading @@ -3421,6 +3478,8 @@ ]) ) +AC_CHECK_FUNCS(cwait fsync pipe popen spawnv system) + AC_MSG_CHECKING(for major, minor, and makedev) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #if defined(MAJOR_IN_MKDEV) @@ -4847,6 +4906,9 @@ #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif +#ifdef _WIN32 +#include <ws2tcpip.h> +#endif ]) case $ac_sys_system in @@ -4938,6 +5000,67 @@ AC_MSG_RESULT($ENSUREPIP) AC_SUBST(ENSUREPIP) +# Cross compiling +AC_SUBST(cross_compiling) + +if test "$cross_compiling" = "yes"; then + AC_MSG_CHECKING(cc for build) + ## /usr/bin/cc still uses wrong assembler + ## CC_FOR_BUILD="${CC_FOR_BUILD-/usr/bin/cc}" + CC_FOR_BUILD="${CC_FOR_BUILD-PATH=/usr/bin:$PATH cc}" +else + CC_FOR_BUILD="${CC_FOR_BUILD-$CC}" +fi + +if test "$cross_compiling" = "yes"; then + AC_MSG_RESULT($CC_FOR_BUILD) +fi + +AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler (default: cc)]) + +if test "$cross_compiling" = "yes"; then + AC_MSG_CHECKING(python for build) + PYTHON_FOR_BUILD="${PYTHON_FOR_BUILD-python}" +else + PYTHON_FOR_BUILD='$(BUILDPYTHON)' +fi + +if test "$cross_compiling" = "yes"; then + AC_MSG_RESULT($PYTHON_FOR_BUILD) +fi +AC_ARG_VAR(PYTHON_FOR_BUILD,[build system python (default: python)]) +AC_SUBST(PYTHON_FOR_BUILD) + +if test "$cross_compiling" = "yes"; then + CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-} + changequote(<<, >>)#dnl + python_include=`$PYTHON_FOR_BUILD -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'` + changequote([, ])#dnl + CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"-I$python_include"} + CROSS_COMMENT=# + if test "$case_sensitive" = "yes" + then + EXEEXT_FOR_BUILD= + else + EXEEXT_FOR_BUILD=.exe + fi + LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-} + LIBS_FOR_BUILD=${LIBS_FOR_BUILD-} + O_FOR_BUILD=x + RUNSHARED="CROSS_TARGET=$ac_sys_system SRCDIR=$srcdir SO=${SO}" +else + CROSS_COMMENT= + EXEEXT_FOR_BUILD=$BUILDEXEEXT + O_FOR_BUILD=o +fi +AC_SUBST(CFLAGS_FOR_BUILD) +AC_SUBST(CPPFLAGS_FOR_BUILD) +AC_SUBST(CROSS_COMMENT) +AC_SUBST(EXEEXT_FOR_BUILD) +AC_SUBST(LDFLAGS_FOR_BUILD) +AC_SUBST(LIBS_FOR_BUILD) +AC_SUBST(O_FOR_BUILD) + # generate output files AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) @@ -4948,6 +5071,9 @@ then cp $srcdir/Modules/Setup.dist Modules/Setup fi +mv Modules/Setup Modules/Setup~ +sed -e "s/@POSIX@/$POSIX/g" < Modules/Setup~ > Modules/Setup + echo "creating Modules/Setup.local" if test ! -f Modules/Setup.local diff -ubBr Python-2.7.18.orig/Include/osdefs.h Python-2.7.18/Include/osdefs.h --- Python-2.7.18.orig/Include/osdefs.h 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Include/osdefs.h 2021-08-21 15:42:17.997177096 +0200 @@ -9,7 +9,7 @@ /* Mod by chrish: QNX has WATCOM, but isn't DOS */ #if !defined(__QNX__) -#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2) +#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2) || defined(__MINGW32__) #if defined(PYOS_OS2) && defined(PYCC_GCC) #define MAXPATHLEN 260 #define SEP '/' @@ -18,6 +18,7 @@ #define SEP '\\' #define ALTSEP '/' #define MAXPATHLEN 256 +#define ROOTSEP ':' #endif #define DELIM ';' #endif diff -ubBr Python-2.7.18.orig/Include/pyport.h Python-2.7.18/Include/pyport.h --- Python-2.7.18.orig/Include/pyport.h 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Include/pyport.h 2021-08-21 15:42:17.997177096 +0200 @@ -203,10 +203,6 @@ /* Smallest negative value of type Py_ssize_t. */ #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) -#if SIZEOF_PID_T > SIZEOF_LONG -# error "Python doesn't support sizeof(pid_t) > sizeof(long)" -#endif - /* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf * format to convert an argument with the width of a size_t or Py_ssize_t. * C99 introduced "z" for this purpose, but not all platforms support that; @@ -237,6 +233,8 @@ # define PY_FORMAT_SIZE_T "l" # elif defined(MS_WINDOWS) # define PY_FORMAT_SIZE_T "I" +# elif defined(__MINGW32__) +# define PY_FORMAT_SIZE_T "z" # else # error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T" # endif @@ -760,19 +758,19 @@ BeOS and cygwin are the only other autoconf platform requiring special linkage handling and both of these use __declspec(). */ -#if defined(__CYGWIN__) || defined(__BEOS__) +#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BEOS__) # define HAVE_DECLSPEC_DLL #endif /* only get special linkage if built as shared or platform is Cygwin */ -#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) +#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) || defined(__MINGW32__) # if defined(HAVE_DECLSPEC_DLL) # ifdef Py_BUILD_CORE # define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE # define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE /* module init functions inside the core need no external linkage */ /* except for Cygwin to handle embedding (FIXME: BeOS too?) */ -# if defined(__CYGWIN__) +# if defined(__CYGWIN__) || defined(__MINGW32__) # define PyMODINIT_FUNC __declspec(dllexport) void # else /* __CYGWIN__ */ # define PyMODINIT_FUNC void @@ -783,7 +781,7 @@ /* Under Cygwin, auto-import functions to prevent compilation */ /* failures similar to those described at the bottom of 4.1: */ /* http://docs.python.org/extending/windows.html#a-cookbook-approach */ -# if !defined(__CYGWIN__) +# if !defined(__CYGWIN__) && !defined(__MINGW32__) # define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE # endif /* !__CYGWIN__ */ # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE diff -ubBr Python-2.7.18.orig/Lib/distutils/command/build_ext.py Python-2.7.18/Lib/distutils/command/build_ext.py --- Python-2.7.18.orig/Lib/distutils/command/build_ext.py 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Lib/distutils/command/build_ext.py 2021-08-21 15:42:17.997177096 +0200 @@ -675,6 +675,8 @@ ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8] # extensions in debug_mode are named 'module_d.pyd' under windows so_ext = get_config_var('SO') + if os.environ.get('CROSS_COMPILING') == 'yes': + so_ext = os.environ.get('SO') if os.name == 'nt' and self.debug: return os.path.join(*ext_path) + '_d' + so_ext return os.path.join(*ext_path) + so_ext @@ -726,7 +728,7 @@ # don't extend ext.libraries, it may be shared with other # extensions, it is a reference to the original list return ext.libraries + [pythonlib] - elif sys.platform[:6] == "cygwin": + elif sys.platform[:6] == "cygwin" or sys.platform[:5] == "mingw": template = "python%d.%d" pythonlib = (template % (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) diff -ubBr Python-2.7.18.orig/Lib/test/test_future5.py Python-2.7.18/Lib/test/test_future5.py --- Python-2.7.18.orig/Lib/test/test_future5.py 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Lib/test/test_future5.py 2021-08-21 15:42:17.997177096 +0200 @@ -13,7 +13,7 @@ def test_print_function(self): with test_support.captured_output("stderr") as s: - print("foo", file=sys.stderr) + print >> sys.stderr, "foo" self.assertEqual(s.getvalue(), "foo\n") diff -ubBr Python-2.7.18.orig/Makefile.pre.in Python-2.7.18/Makefile.pre.in --- Python-2.7.18.orig/Makefile.pre.in 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Makefile.pre.in 2021-08-21 15:42:17.997177096 +0200 @@ -18,6 +18,8 @@ # # See also the section "Build instructions" in the README file. +DELIM=@DELIM@ + # === Variables set by makesetup === MODOBJS= _MODOBJS_ @@ -88,6 +90,16 @@ # C flags used for building the interpreter object files PY_CFLAGS= $(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE +# For cross compile: build compiler options +CC_FOR_BUILD= @CC_FOR_BUILD@ +CROSS_COMPILING= @cross_compiling@ +EXEEXT_FOR_BUILD= @EXEEXT_FOR_BUILD@ +O_FOR_BUILD= @O_FOR_BUILD@ + +CFLAGS_FOR_BUILD= @CFLAGS_FOR_BUILD@ +CPPFLAGS_FOR_BUILD= @CPPFLAGS_FOR_BUILD@ -I$(srcdir)/Include +LDFLAGS_FOR_BUILD= @LDFLAGS_FOR_BUILD@ +LIBS_FOR_BUILD= @LIBS_FOR_BUILD@ # Machine-dependent subdirectories MACHDEP= @MACHDEP@ @@ -126,6 +138,10 @@ LDCXXSHARED= @LDCXXSHARED@ DESTSHARED= $(BINLIBDEST)/lib-dynload +comma=, +BLDFLAGS=$(subst -Wl$(comma),,$(LDFLAGS)) + + # Executable suffix (.exe on Windows and Mac OS X) EXE= @EXEEXT@ BUILDEXE= @BUILDEXEEXT@ @@ -197,7 +213,8 @@ UNICODE_OBJS= @UNICODE_OBJS@ PYTHON= python$(EXE) -BUILDPYTHON= python$(BUILDEXE) +BUILDPYTHON= python$(EXE) +PYTHON_FOR_BUILD= @PYTHON_FOR_BUILD@ PYTHON_FOR_REGEN=@PYTHON_FOR_REGEN@ PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ @@ -239,7 +256,7 @@ ########################################################################## # Parser -PGEN= Parser/pgen$(EXE) +PGEN_FOR_BUILD= Parser/pgen$(EXEEXT_FOR_BUILD) PSRCS= \ Parser/acceler.c \ @@ -277,20 +294,29 @@ Parser/printgrammar.c \ Parser/pgenmain.c -PGOBJS= \ - Objects/obmalloc.o \ - Python/mysnprintf.o \ - Python/pyctype.o \ - Parser/tokenizer_pgen.o \ - Parser/printgrammar.o \ - Parser/pgenmain.o - -PARSER_HEADERS= \ - Parser/parser.h \ - Parser/tokenizer.h +POBJS_FOR_BUILD= \ + Parser/acceler.$(O_FOR_BUILD) \ + Parser/grammar1.$(O_FOR_BUILD) \ + Parser/listnode.$(O_FOR_BUILD) \ + Parser/node.$(O_FOR_BUILD) \ + Parser/parser.$(O_FOR_BUILD) \ + Parser/parsetok.$(O_FOR_BUILD) \ + Parser/bitset.$(O_FOR_BUILD) \ + Parser/metagrammar.$(O_FOR_BUILD) \ + Parser/firstsets.$(O_FOR_BUILD) \ + Parser/grammar.$(O_FOR_BUILD) \ + Parser/pgen.$(O_FOR_BUILD) + +PGOBJS_FOR_BUILD= \ + Objects/obmalloc.$(O_FOR_BUILD) \ + Python/mysnprintf.$(O_FOR_BUILD) \ + Python/pyctype.$(O_FOR_BUILD) \ + Parser/tokenizer_pgen.$(O_FOR_BUILD) \ + Parser/printgrammar.$(O_FOR_BUILD) \ + Parser/pgenmain.$(O_FOR_BUILD) PGENSRCS= $(PSRCS) $(PGSRCS) -PGENOBJS= $(POBJS) $(PGOBJS) +PGENOBJS= $(POBJS_FOR_BUILD) $(PGOBJS_FOR_BUILD) ########################################################################## PYTHON_OBJS= \ @@ -662,10 +688,14 @@ Modules/grpmodule.o: $(srcdir)/Modules/grpmodule.c $(srcdir)/Modules/posixmodule.h -Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h +$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN_FOR_BUILD) $(GRAMMAR_INPUT) + -@$(INSTALL) -d Include + -$(PGEN_FOR_BUILD) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) + +$(PGEN_FOR_BUILD): $(PGENOBJS) + $(CC_FOR_BUILD) $(OPT) $(LDFLAGS_FOR_BUILD) $(PGENOBJS) $(LIBS_FOR_BUILD) -o $(PGEN_FOR_BUILD) -$(PGEN): $(PGENOBJS) - $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) +Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h .PHONY: regen-grammar regen-grammar: $(PGEN) @@ -749,6 +779,13 @@ $(STRINGLIB_HEADERS) ############################################################################ +# Cross compile rules + +.SUFFIXES: .x +.c.x: + $(CC_FOR_BUILD) -c $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ $< + +############################################################################ # Header files PYTHON_HEADERS= \ @@ -854,7 +891,7 @@ TESTOPTS= -l $(EXTRATESTOPTS) TESTPROG= $(srcdir)/Lib/test/regrtest.py -TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -Wd -3 -E -tt $(TESTPYTHONOPTS) +TESTPYTHON= $(RUNSHARED) $(PYTHON_FOR_BUILD) -Wd -3 -E -tt $(TESTPYTHONOPTS) # Remove "test_python_*" directories of previous failed test jobs. # Pass TESTOPTS options because it can contain --tempdir option. @@ -1077,7 +1114,7 @@ unittest unittest/test \ lib-old \ curses pydoc_data $(MACHDEPS) -libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c +libinstall: build_all $(srcdir)/Lib/$(PLATDIR) @CROSS_COMMENT@ $(srcdir)/Modules/xxmodule.c @for i in $(SCRIPTDIR) $(LIBDEST); \ do \ if test ! -d $(DESTDIR)$$i; then \ @@ -1164,9 +1201,9 @@ $(srcdir)/Lib/$(PLATDIR): mkdir $(srcdir)/Lib/$(PLATDIR) cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen - export PATH; PATH="`pwd`:$$PATH"; \ - export PYTHONPATH; PYTHONPATH="$(srcdir)/Lib:$(abs_builddir)/`cat pybuilddir.txt`"; \ - export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ + @CROSS_COMMENT@ export PATH; PATH="`pwd`:$$PATH"; \ + @CROSS_COMMENT@ export PYTHONPATH; PYTHONPATH="$(srcdir)/Lib:$(abs_builddir)/`cat pybuilddir.txt`"; \ + @CROSS_COMMENT@ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ export EXE; EXE="$(BUILDEXE)"; \ if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \ export PYTHON_FOR_BUILD; \ @@ -1270,6 +1307,7 @@ # Install the dynamically loadable modules # This goes into $(exec_prefix) sharedinstall: sharedmods + CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING='$(CROSS_COMPILING)' \ $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \ --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ @@ -1415,11 +1453,12 @@ find . -name '*.dyn' -exec rm -f {} ';' clobber: clean profile-removal - -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ + -rm -f $(BUILDPYTHON) $(PGEN_FOR_BUILD) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ tags TAGS \ config.cache config.log pyconfig.h Modules/config.c -rm -rf build platform -rm -rf $(PYTHONFRAMEWORKDIR) + -rm -rf buildpython # Make things extra clean, before making a distribution: # remove all generated files, even Makefile[.pre] diff -ubBr Python-2.7.18.orig/Modules/addrinfo.h Python-2.7.18/Modules/addrinfo.h --- Python-2.7.18.orig/Modules/addrinfo.h 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/addrinfo.h 2021-08-21 15:42:17.997177096 +0200 @@ -123,7 +123,7 @@ #endif /* !HAVE_GETNAMEINFO */ -#ifndef HAVE_ADDRINFO +#if !defined(HAVE_ADDRINFO) && !defined(_WIN32) struct addrinfo { int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ int ai_family; /* PF_xxx */ @@ -136,7 +136,7 @@ }; #endif /* !HAVE_ADDRINFO */ -#ifndef HAVE_SOCKADDR_STORAGE +#if !defined(HAVE_SOCKADDR_STORAGE) && !defined(_WIN32) /* * RFC 2553: protocol-independent placeholder for socket addresses */ diff -ubBr Python-2.7.18.orig/Modules/_ctypes/libffi/fficonfig.py.in Python-2.7.18/Modules/_ctypes/libffi/fficonfig.py.in --- Python-2.7.18.orig/Modules/_ctypes/libffi/fficonfig.py.in 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/_ctypes/libffi/fficonfig.py.in 2021-08-21 15:42:38.333165470 +0200 @@ -9,6 +9,7 @@ 'X86': ['src/x86/ffi.c', 'src/x86/sysv.S', 'src/x86/win32.S'], 'X86_FREEBSD': ['src/x86/ffi.c', 'src/x86/freebsd.S'], 'X86_WIN32': ['src/x86/ffi.c', 'src/x86/win32.S'], + 'X86_WIN64': ['src/x86/ffi.c', 'src/x86/win64.S'], 'SPARC': ['src/sparc/ffi.c', 'src/sparc/v8.S', 'src/sparc/v9.S'], 'ALPHA': ['src/alpha/ffi.c', 'src/alpha/osf.S'], 'IA64': ['src/ia64/ffi.c', 'src/ia64/unix.S'], diff -ubBr Python-2.7.18.orig/Modules/datetimemodule.c Python-2.7.18/Modules/datetimemodule.c --- Python-2.7.18.orig/Modules/datetimemodule.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/datetimemodule.c 2021-08-21 15:42:17.997177096 +0200 @@ -10,6 +10,10 @@ #include <time.h> +#ifdef MS_WINDOWS +#include <winsock2.h> +#endif + #include "timefuncs.h" /* Differentiate between building the core module and building extension diff -ubBr Python-2.7.18.orig/Modules/getpath.c Python-2.7.18/Modules/getpath.c --- Python-2.7.18.orig/Modules/getpath.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/getpath.c 2021-08-21 15:42:18.001177094 +0200 @@ -104,6 +104,14 @@ #define LANDMARK "os.py" #endif +#ifndef __MINGW32__ +#define IS_ABSOLUTE(x) (x[0] == SEP) +#else /* __MINGW32__ */ +#define IS_ABSOLUTE(x) (x[0] == SEP || x[0] == ALTSEP\ + || (x[1] && x[1] == ROOTSEP\ + && x[2] && (x[2] == SEP || x[2] == ALTSEP))) +#endif /* __MINGW32__ */ + static char prefix[MAXPATHLEN+1]; static char exec_prefix[MAXPATHLEN+1]; static char progpath[MAXPATHLEN+1]; @@ -114,7 +122,12 @@ reduce(char *dir) { size_t i = strlen(dir); - while (i > 0 && dir[i] != SEP) + while (i > 0 + && dir[i] != SEP +#ifdef ALTSEP + && dir[i] != ALTSEP +#endif /* ALTSEP */ + ) --i; dir[i] = '\0'; } @@ -187,11 +200,16 @@ joinpath(char *buffer, char *stuff) { size_t n, k; - if (stuff[0] == SEP) + if (IS_ABSOLUTE(stuff)) n = 0; else { n = strlen(buffer); - if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN) + if (n > 0 + && buffer[n-1] != SEP +#ifdef ALTSEP + && buffer[n-1] != ALTSEP +#endif /* ALTSEP */ + && n < MAXPATHLEN) buffer[n++] = SEP; } if (n > MAXPATHLEN) @@ -208,7 +226,7 @@ static void copy_absolute(char *path, char *p) { - if (p[0] == SEP) + if (IS_ABSOLUTE(p)) strcpy(path, p); else { if (!getcwd(path, MAXPATHLEN)) { @@ -216,7 +234,11 @@ strcpy(path, p); return; } +#ifdef ALTSEP + if (p[0] == '.' && (p[1] == SEP || p[1] == ALTSEP)) +#else if (p[0] == '.' && p[1] == SEP) +#endif p += 2; joinpath(path, p); } @@ -228,7 +250,7 @@ { char buffer[MAXPATHLEN + 1]; - if (path[0] == SEP) + if (IS_ABSOLUTE(path)) return; copy_absolute(buffer, path); strcpy(path, buffer); @@ -389,13 +411,23 @@ #endif #endif - /* If there is no slash in the argv0 path, then we have to - * assume python is on the user's $PATH, since there's no - * other way to find a directory to start the search from. If - * $PATH isn't exported, you lose. + /* If PROG is an absolute name, then we're done. If PROG is not + * an absolute name and contains SEP/ALTSEP, then it must be + * reachable from CWD. Otherwise, python is on the user's $PATH, + * since there's no other way to find a directory to start the + * search from. If $PATH isn't exported, you lose. */ - if (strchr(prog, SEP)) + if (IS_ABSOLUTE(prog)) strncpy(progpath, prog, MAXPATHLEN); + else if (strchr(prog, SEP) +#ifdef ALTSEP + || strchr(prog, ALTSEP) +#endif /* ALTSEP */ + ) + { + getcwd(progpath, MAXPATHLEN); + joinpath(progpath, prog); + } #ifdef __APPLE__ /* On Mac OS X, if a script uses an interpreter of the form * "#!/opt/python2.3/bin/python", the kernel only passes "python" @@ -411,6 +443,9 @@ ; #endif /* __APPLE__ */ else if (path) { +#ifdef __MINGW32__ + char const *ext = strchr(prog, '.') ? "" : ".exe"; +#endif while (1) { char *delim = strchr(path, DELIM); @@ -425,6 +460,9 @@ strncpy(progpath, path, MAXPATHLEN); joinpath(progpath, prog); +#ifdef __MINGW32__ + strcat(progpath, ext); +#endif if (isxfile(progpath)) break; @@ -483,7 +521,7 @@ while (linklen != -1) { /* It's not null terminated! */ tmpbuffer[linklen] = '\0'; - if (tmpbuffer[0] == SEP) + if (IS_ABSOLUTE(tmpbuffer)) /* tmpbuffer should never be longer than MAXPATHLEN, but extra check does not hurt */ strncpy(argv0_path, tmpbuffer, MAXPATHLEN + 1); @@ -550,7 +588,7 @@ while (1) { char *delim = strchr(defpath, DELIM); - if (defpath[0] != SEP) + if (!IS_ABSOLUTE(defpath)) /* Paths are relative to prefix */ bufsz += prefixsz; @@ -595,7 +633,7 @@ while (1) { char *delim = strchr(defpath, DELIM); - if (defpath[0] != SEP) { + if (!IS_ABSOLUTE(defpath)) { strcat(buf, prefix); if (prefixsz >= 2 && prefix[prefixsz - 2] != SEP && defpath[0] != (delim ? DELIM : L'\0')) { /* not empty */ diff -ubBr Python-2.7.18.orig/Modules/posixmodule.c Python-2.7.18/Modules/posixmodule.c --- Python-2.7.18.orig/Modules/posixmodule.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/posixmodule.c 2021-08-21 15:42:18.001177094 +0200 @@ -102,6 +102,11 @@ #include <sys/loadavg.h> #endif +/* Additional defines for the mingw32 build */ +#if defined(__MINGW32__) +#undef HAVE_DEV_PTMX +#endif + /* Various compilers have only certain posix functions */ /* XXX Gosh I wish these were all moved into pyconfig.h */ #if defined(PYCC_VACPP) && defined(PYOS_OS2) @@ -136,6 +141,9 @@ #define HAVE_CWAIT 1 #define HAVE_FSYNC 1 #define fsync _commit +#elif defined(__MINGW32__) /* MINGW32 (cross-)compiler*/ +#define HAVE_FSYNC 1 +#define fsync _commit #else #if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS) /* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */ @@ -162,12 +170,12 @@ #define HAVE_WAIT 1 #define HAVE_TTYNAME 1 #endif /* PYOS_OS2 && PYCC_GCC && __VMS */ -#endif /* _MSC_VER */ +#endif /* __MINGW32__ */ #endif /* __BORLANDC__ */ #endif /* ! __WATCOMC__ || __QNX__ */ #endif /* ! __IBMC__ */ -#ifndef _MSC_VER +#if !defined(_MSC_VER) && !defined(__MINGW32__) #if defined(__sgi)&&_COMPILER_VERSION>=700 /* declare ctermid_r if compiling with MIPSPro 7.x in ANSI C mode @@ -179,7 +187,7 @@ #if defined(PYCC_VACPP) extern int mkdir(char *); #else -#if ( defined(__WATCOMC__) || defined(_MSC_VER) ) && !defined(__QNX__) +#if ( defined(__WATCOMC__) || defined(_MSC_VER) || defined(__MINGW32__)) && !defined(__QNX__) extern int mkdir(const char *); #else extern int mkdir(const char *, mode_t); @@ -219,7 +227,7 @@ #endif /* HAVE_LSTAT */ #endif /* !HAVE_UNISTD_H */ -#endif /* !_MSC_VER */ +#endif /* !_MSC_VER && !__MINGW32__ */ #ifdef HAVE_UTIME_H #include <utime.h> @@ -264,7 +272,7 @@ #endif #endif -#ifdef _MSC_VER +#if defined (_MSC_VER) || defined (__MINGW32__) #ifdef HAVE_DIRECT_H #include <direct.h> #endif @@ -280,7 +288,7 @@ #include <shellapi.h> /* for ShellExecute() */ #define popen _popen #define pclose _pclose -#endif /* _MSC_VER */ +#endif /* _MSC_VER || __MINGW32__ */ #if defined(PYCC_VACPP) && defined(PYOS_OS2) #include <io.h> @@ -1019,7 +1027,7 @@ #undef STAT #undef FSTAT #undef STRUCT_STAT -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#if defined(MS_WIN64) || defined(MS_WINDOWS) || defined(__MINGW32__) # define STAT win32_stat # define FSTAT win32_fstat # define STRUCT_STAT struct win32_stat @@ -1029,7 +1037,7 @@ # define STRUCT_STAT struct stat #endif -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) /* The CRT of Windows has a number of flaws wrt. its stat() implementation: - time stamps are restricted to second resolution - file modification times suffer from forth-and-back conversions between @@ -1275,7 +1283,7 @@ return 0; } -#endif /* MS_WINDOWS */ +#endif /* MS_WINDOWS and __MINGW32__ */ PyDoc_STRVAR(stat_result__doc__, "stat_result: Result from stat or lstat.\n\n\ @@ -1487,7 +1495,7 @@ #else PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st->st_ino)); #endif -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) PyStructSequence_SET_ITEM(v, 2, PyLong_FromUnsignedLong(st->st_dev)); #else PyStructSequence_SET_ITEM(v, 2, _PyInt_FromDev(st->st_dev)); @@ -1574,7 +1582,7 @@ return v; } -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) /* IsUNCRoot -- test whether the supplied path is of the form \\SERVER\SHARE\, where / can be used in place of \ and the trailing slash is optional. @@ -1632,7 +1640,7 @@ #undef ISSLASH } -#endif /* MS_WINDOWS */ +#endif /* MS_WINDOWS and __MINGW32__ */ static PyObject * posix_do_stat(PyObject *self, PyObject *args, @@ -1677,7 +1685,7 @@ Py_END_ALLOW_THREADS if (res != 0) { -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) result = win32_error("stat", pathfree); #else result = posix_error_with_filename(pathfree); @@ -1821,7 +1829,7 @@ static PyObject * posix_chdir(PyObject *self, PyObject *args) { -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) return win32_1str(args, "chdir", "s:chdir", win32_chdir, "U:chdir", win32_wchdir); #elif defined(PYOS_OS2) && defined(PYCC_GCC) return posix_1str(args, "et:chdir", _chdir2); @@ -2289,7 +2297,7 @@ { /* XXX Should redo this putting the (now four) versions of opendir in separate files instead of having them all here... */ -#if defined(MS_WINDOWS) && !defined(HAVE_OPENDIR) +#if (defined(MS_WINDOWS) || defined(__MINGW32__)) && !defined(HAVE_OPENDIR) PyObject *d, *v; HANDLE hFindFile; @@ -2602,7 +2610,7 @@ #endif /* which OS */ } /* end of posix_listdir */ -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) /* A helper function for abspath on win32 */ static PyObject * posix__getfullpathname(PyObject *self, PyObject *args) @@ -2654,7 +2662,7 @@ } return PyString_FromString(outbuf); } /* end of posix__getfullpathname */ -#endif /* MS_WINDOWS */ +#endif /* MS_WINDOWS and __MINGW32__ */ PyDoc_STRVAR(posix_mkdir__doc__, "mkdir(path [, mode=0777])\n\n\ @@ -2765,7 +2773,7 @@ static PyObject * posix_rename(PyObject *self, PyObject *args) { -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) PyObject *o1, *o2; char *p1, *p2; BOOL result; @@ -2811,7 +2819,7 @@ static PyObject * posix_rmdir(PyObject *self, PyObject *args) { -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) return win32_1str(args, "rmdir", "s:rmdir", RemoveDirectoryA, "U:rmdir", RemoveDirectoryW); #else return posix_1str(args, "et:rmdir", rmdir); @@ -2826,7 +2834,7 @@ static PyObject * posix_stat(PyObject *self, PyObject *args) { -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) return posix_do_stat(self, args, "et:stat", STAT, "u:stat", win32_wstat); #else return posix_do_stat(self, args, "et:stat", STAT, NULL, NULL); @@ -2882,7 +2890,7 @@ static PyObject * posix_unlink(PyObject *self, PyObject *args) { -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) return win32_1str(args, "remove", "s:remove", DeleteFileA, "U:remove", DeleteFileW); #else return posix_1str(args, "et:remove", unlink); @@ -5195,7 +5203,7 @@ #endif /* PYCC_??? */ -#elif defined(MS_WINDOWS) +#elif defined(MS_WINDOWS) || defined(__MINGW32__) /* * Portable 'popen' replacement for Win32. @@ -6335,7 +6343,7 @@ #ifdef HAVE_LSTAT return posix_do_stat(self, args, "et:lstat", lstat, NULL, NULL); #else /* !HAVE_LSTAT */ -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) return posix_do_stat(self, args, "et:lstat", STAT, "u:lstat", win32_wstat); #else return posix_do_stat(self, args, "et:lstat", STAT, NULL, NULL); @@ -6468,7 +6476,7 @@ #endif /* HAVE_TIMES */ -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) #define HAVE_TIMES /* so the method table will pick it up */ static PyObject * posix_times(PyObject *self, PyObject *noargs) @@ -6492,7 +6500,7 @@ (double)0, (double)0); } -#endif /* MS_WINDOWS */ +#endif /* MS_WINDOWS and __MINGW32__ */ #ifdef HAVE_TIMES PyDoc_STRVAR(posix_times__doc__, @@ -6609,7 +6617,7 @@ int mode = 0777; int fd; -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) Py_UNICODE *wpath; if (PyArg_ParseTuple(args, "ui|i:mkdir", &wpath, &flag, &mode)) { Py_BEGIN_ALLOW_THREADS @@ -6736,7 +6744,7 @@ posix_lseek(PyObject *self, PyObject *args) { int fd, how; -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#if defined(MS_WIN64) || defined(MS_WINDOWS) || defined(__MINGW32__) PY_LONG_LONG pos, res; #else off_t pos, res; @@ -6765,7 +6773,7 @@ if (!_PyVerify_fd(fd)) return posix_error(); Py_BEGIN_ALLOW_THREADS -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#if defined(MS_WIN64) || defined(MS_WINDOWS) || defined(__MINGW32__) res = _lseeki64(fd, pos, how); #else res = lseek(fd, pos, how); @@ -6873,7 +6881,7 @@ res = FSTAT(fd, &st); Py_END_ALLOW_THREADS if (res != 0) { -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) return win32_error("fstat", NULL); #else return posix_error(); @@ -6941,7 +6949,7 @@ return NULL; } Py_BEGIN_ALLOW_THREADS -#if !defined(MS_WINDOWS) && defined(HAVE_FCNTL_H) +#if !defined(MS_WINDOWS) || !defined(__MINGW32__) && defined(HAVE_FCNTL_H) if (mode[0] == 'a') { /* try to make sure the O_APPEND flag is set */ int flags; @@ -7006,7 +7014,7 @@ return Py_BuildValue("(ii)", read, write); #else -#if !defined(MS_WINDOWS) +#if !defined(MS_WINDOWS) || !defined(__MINGW32__) int fds[2]; int res; Py_BEGIN_ALLOW_THREADS @@ -7015,7 +7023,7 @@ if (res != 0) return posix_error(); return Py_BuildValue("(ii)", fds[0], fds[1]); -#else /* MS_WINDOWS */ +#else /* MS_WINDOWS and __MINGW32__ */ HANDLE read, write; int read_fd, write_fd; BOOL ok; @@ -7589,7 +7597,7 @@ "use the tempfile module", 1) < 0) return NULL; -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) name = _tempnam(dir, pfx); #else name = tempnam(dir, pfx); @@ -8655,7 +8663,7 @@ return NULL; } -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) PyDoc_STRVAR(win32_startfile__doc__, "startfile(filepath [, operation]) - Start a file with its associated\n\ application.\n\ @@ -8990,7 +8998,7 @@ #endif /* HAVE_PLOCK */ #ifdef HAVE_POPEN {"popen", posix_popen, METH_VARARGS, posix_popen__doc__}, -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) {"popen2", win32_popen2, METH_VARARGS}, {"popen3", win32_popen3, METH_VARARGS}, {"popen4", win32_popen4, METH_VARARGS}, @@ -9159,7 +9167,7 @@ {"pathconf", posix_pathconf, METH_VARARGS, posix_pathconf__doc__}, #endif {"abort", posix_abort, METH_NOARGS, posix_abort__doc__}, -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) || defined(__MINGW32__) {"_getfullpathname", posix__getfullpathname, METH_VARARGS, NULL}, {"_isdir", posix__isdir, METH_VARARGS, posix__isdir__doc__}, #endif @@ -9464,7 +9472,7 @@ } -#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__) +#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) && !defined(__QNX__) #define INITFUNC initnt #define MODNAME "nt" diff -ubBr Python-2.7.18.orig/Modules/pwdmodule.c Python-2.7.18/Modules/pwdmodule.c --- Python-2.7.18.orig/Modules/pwdmodule.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/pwdmodule.c 2021-08-21 15:42:18.001177094 +0200 @@ -1,10 +1,12 @@ - /* UNIX password file access module */ #include "Python.h" #include "structseq.h" #include "posixmodule.h" +#ifndef __MINGW32__ + +#include <sys/types.h> #include <pwd.h> static PyStructSequence_Field struct_pwd_type_fields[] = { @@ -206,3 +208,9 @@ PyModule_AddObject(m, "struct_pwent", (PyObject *) &StructPwdType); initialized = 1; } +#else +PyMODINIT_FUNC +initpwd(void) +{ +} +#endif // !__MINGW32__ diff -ubBr Python-2.7.18.orig/Modules/readline.c Python-2.7.18/Modules/readline.c --- Python-2.7.18.orig/Modules/readline.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/readline.c 2021-08-21 15:42:18.001177094 +0200 @@ -11,6 +11,14 @@ #include <errno.h> #include <sys/time.h> +#ifdef MS_WINDOWS +# include <winsock2.h> +#endif + +#ifndef SIGWINCH +#define SIGWINCH 28 +#endif + #if defined(HAVE_SETLOCALE) /* GNU readline() mistakenly sets the LC_CTYPE locale. * This is evil. Only the user or the app's main() should do this! diff -ubBr Python-2.7.18.orig/Modules/Setup.dist Python-2.7.18/Modules/Setup.dist --- Python-2.7.18.orig/Modules/Setup.dist 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/Setup.dist 2021-08-21 15:42:18.001177094 +0200 @@ -91,12 +91,12 @@ TESTPATH= # Path components for machine- or system-dependent modules and shared libraries -MACHDEPPATH=:$(PLATDIR) +MACHDEPPATH=$(DELIM)plat-$(MACHDEP) EXTRAMACHDEPPATH= # Path component for the Tkinter-related modules # The TKPATH variable is always enabled, to save you the effort. -TKPATH=:lib-tk +TKPATH=$(DELIM)lib-tk # Path component for old modules. OLDPATH=:lib-old @@ -112,7 +112,7 @@ # This only contains the minimal set of modules required to run the # setup.py script in the root of the Python source tree. -posix posixmodule.c # posix (UNIX) system calls +@POSIX@ posixmodule.c # posix (UNIX) system calls errno errnomodule.c # posix (UNIX) errno values pwd pwdmodule.c # this is needed to find out the user's home dir # if $HOME is not set @@ -163,33 +163,34 @@ # it, depending on your system -- see the GNU readline instructions. # It's okay for this to be a shared library, too. -#readline readline.c -lreadline -ltermcap +readline readline.c -lreadline -ltermcap # Modules that should always be present (non UNIX dependent): -#array arraymodule.c # array objects -#cmath cmathmodule.c _math.c # -lm # complex math library functions -#math mathmodule.c _math.c # -lm # math library functions, e.g. sin() -#_struct _struct.c # binary structure packing/unpacking -#time timemodule.c # -lm # time operations and variables -#operator operator.c # operator.add() and similar goodies -#_testcapi _testcapimodule.c # Python C API test module -#_random _randommodule.c # Random number generator -#_collections _collectionsmodule.c # Container types -#_heapq _heapqmodule.c # Heapq type -#itertools itertoolsmodule.c # Functions creating iterators for efficient looping -#strop stropmodule.c # String manipulations -#_functools _functoolsmodule.c # Tools for working with functions and callable objects -#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator +array arraymodule.c # array objects +cmath cmathmodule.c _math.c # -lm # complex math library functions +math mathmodule.c _math.c # -lm # math library functions, e.g. sin() +_struct _struct.c # binary structure packing/unpacking +time timemodule.c # -lm # time operations and variables +operator operator.c # operator.add() and similar goodies +_weakref _weakref.c # basic weak reference support +_testcapi _testcapimodule.c # Python C API test module +_random _randommodule.c # Random number generator +_collections _collectionsmodule.c # Container types +_heapq _heapqmodule.c # Heapq type +itertools itertoolsmodule.c # Functions creating iterators for efficient looping +strop stropmodule.c # String manipulations +_functools _functoolsmodule.c # Tools for working with functions and callable objects +_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator #_pickle _pickle.c # pickle accelerator -#datetime datetimemodule.c # date/time type -#_bisect _bisectmodule.c # Bisection algorithms +datetime datetimemodule.c # date/time type +_bisect _bisectmodule.c # Bisection algorithms -#unicodedata unicodedata.c # static Unicode character database +unicodedata unicodedata.c # static Unicode character database # access to ISO C locale support -#_locale _localemodule.c # -lintl +_locale _localemodule.c -lintl # Standard I/O baseline #_io -I$(srcdir)/Modules/_io _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c @@ -202,16 +203,16 @@ #fcntl fcntlmodule.c # fcntl(2) and ioctl(2) #spwd spwdmodule.c # spwd(3) #grp grpmodule.c # grp(3) -#select selectmodule.c # select(2); not on ancient System V +select selectmodule.c -lws2_32 -lwsock32 # select(2); not on ancient System V # Memory-mapped files (also works on Win32). -#mmap mmapmodule.c +mmap mmapmodule.c # CSV file helper -#_csv _csv.c +_csv _csv.c # Socket module helper for socket(2) -#_socket socketmodule.c timemodule.c +_socket socketmodule.c timemodule.c -lws2_32 -lwsock32 # Socket module helper for SSL support; you must comment out the other # socket line above, and possibly edit the SSL variable: @@ -252,14 +253,14 @@ # Message-Digest Algorithm, described in RFC 1321. The necessary files # md5.c and md5.h are included here. -#_md5 md5module.c md5.c +_md5 md5module.c md5.c # The _sha module implements the SHA checksum algorithms. # (NIST's Secure Hash Algorithms.) -#_sha shamodule.c -#_sha256 sha256module.c -#_sha512 sha512module.c +_sha shamodule.c +_sha256 sha256module.c +_sha512 sha512module.c # SGI IRIX specific modules -- off by default. @@ -311,7 +312,7 @@ # George Neville-Neil's timing module: -#timing timingmodule.c +timing timingmodule.c # The _tkinter module. @@ -415,11 +416,11 @@ # # Edit the variables DB and DBLIBVERto point to the db top directory # and the subdirectory of PORT where you built it. -#DB=/usr/local/BerkeleyDB.4.0 -#DBLIBVER=4.0 -#DBINC=$(DB)/include -#DBLIB=$(DB)/lib -#_bsddb _bsddb.c -I$(DBINC) -L$(DBLIB) -ldb-$(DBLIBVER) +DB=$(prefix) +DBLIBVER=6.2 +DBINC=$(DB)/include +DBLIB=$(DB)/lib +_bsddb _bsddb.c -I$(DBINC) -L$(DBLIB) -ldb-$(DBLIBVER) # Historical Berkeley DB 1.85 # @@ -434,14 +435,14 @@ # Helper module for various ascii-encoders -#binascii binascii.c +binascii binascii.c # Fred Drake's interface to the Python parser -#parser parsermodule.c +parser parsermodule.c # cStringIO and cPickle -#cStringIO cStringIO.c -#cPickle cPickle.c +cStringIO cStringIO.c +cPickle cPickle.c # Lee Busby's SIGFPE modules. @@ -464,25 +465,24 @@ # Andrew Kuchling's zlib module. # This require zlib 1.1.3 (or later). # See http://www.gzip.org/zlib/ -#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz +zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz # Interface to the Expat XML parser # More information on Expat can be found at www.libexpat.org. -# #pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI # Hye-Shik Chang's CJKCodecs # multibytecodec is required for all the other CJK codec modules -#_multibytecodec cjkcodecs/multibytecodec.c +_multibytecodec cjkcodecs/multibytecodec.c -#_codecs_cn cjkcodecs/_codecs_cn.c -#_codecs_hk cjkcodecs/_codecs_hk.c -#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c -#_codecs_jp cjkcodecs/_codecs_jp.c -#_codecs_kr cjkcodecs/_codecs_kr.c -#_codecs_tw cjkcodecs/_codecs_tw.c +_codecs_cn cjkcodecs/_codecs_cn.c +_codecs_hk cjkcodecs/_codecs_hk.c +_codecs_iso2022 cjkcodecs/_codecs_iso2022.c +_codecs_jp cjkcodecs/_codecs_jp.c +_codecs_kr cjkcodecs/_codecs_kr.c +_codecs_tw cjkcodecs/_codecs_tw.c # Example -- included for reference only: # xx xxmodule.c diff -ubBr Python-2.7.18.orig/Modules/signalmodule.c Python-2.7.18/Modules/signalmodule.c --- Python-2.7.18.orig/Modules/signalmodule.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/signalmodule.c 2021-08-21 15:42:18.001177094 +0200 @@ -7,7 +7,7 @@ #include "intrcheck.h" #ifdef MS_WINDOWS -#include <Windows.h> +#include <windows.h> #ifdef HAVE_PROCESS_H #include <process.h> #endif diff -ubBr Python-2.7.18.orig/Modules/socketmodule.c Python-2.7.18/Modules/socketmodule.c --- Python-2.7.18.orig/Modules/socketmodule.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/socketmodule.c 2021-08-21 15:42:18.001177094 +0200 @@ -3355,7 +3355,11 @@ if (h->h_addrtype != af) { /* Let's get real error message to return */ PyErr_SetString(socket_error, +#ifdef _WIN32 + (char *)strerror(WSAEAFNOSUPPORT)); +#else (char *)strerror(EAFNOSUPPORT)); +#endif return NULL; } diff -ubBr Python-2.7.18.orig/Modules/socketmodule.h Python-2.7.18/Modules/socketmodule.h --- Python-2.7.18.orig/Modules/socketmodule.h 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/socketmodule.h 2021-08-21 15:42:18.001177094 +0200 @@ -21,7 +21,7 @@ * I use SIO_GET_MULTICAST_FILTER to detect a decent SDK. */ # ifdef SIO_GET_MULTICAST_FILTER -# include <MSTcpIP.h> /* for SIO_RCVALL */ +# include <mstcpip.h> /* for SIO_RCVALL */ # define HAVE_ADDRINFO # define HAVE_SOCKADDR_STORAGE # define HAVE_GETADDRINFO diff -ubBr Python-2.7.18.orig/Modules/_testcapimodule.c Python-2.7.18/Modules/_testcapimodule.c --- Python-2.7.18.orig/Modules/_testcapimodule.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/_testcapimodule.c 2021-08-21 15:42:18.001177094 +0200 @@ -8,6 +8,7 @@ #include "Python.h" #include <float.h> #include "structmember.h" +#undef Py_BUILD_CORE #include "datetime.h" #include "marshal.h" #include <signal.h> @@ -1961,7 +1962,6 @@ PyDateTime_IMPORT; if (PyDateTimeAPI) Py_RETURN_NONE; - else return NULL; } #endif diff -ubBr Python-2.7.18.orig/Modules/timemodule.c Python-2.7.18/Modules/timemodule.c --- Python-2.7.18.orig/Modules/timemodule.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/timemodule.c 2021-08-21 15:42:18.001177094 +0200 @@ -42,6 +42,10 @@ #include <windows.h> #include "pythread.h" +#ifdef MS_WINDOWS +#include <winsock2.h> +#endif + /* helper to allow us to interrupt sleep() on Windows*/ static HANDLE hInterruptEvent = NULL; static BOOL WINAPI PyCtrlHandler(DWORD dwCtrlType) @@ -973,7 +977,9 @@ If Ctrl+C event delivered while not sleeping it will be ignored. */ +#ifdef WITH_THREAD main_thread = PyThread_get_thread_ident(); +#endif hInterruptEvent = CreateEvent(NULL, TRUE, FALSE, NULL); SetConsoleCtrlHandler( PyCtrlHandler, TRUE); #endif /* MS_WINDOWS */ @@ -1075,8 +1081,11 @@ * by Guido, only the main thread can be interrupted. */ ul_millis = (unsigned long)millisecs; - if (ul_millis == 0 || - main_thread != PyThread_get_thread_ident()) + if (ul_millis == 0 +#ifdef WITH_THREAD + || main_thread != PyThread_get_thread_ident() +#endif + ) Sleep(ul_millis); else { DWORD rc; diff -ubBr Python-2.7.18.orig/Modules/xxsubtype.c Python-2.7.18/Modules/xxsubtype.c --- Python-2.7.18.orig/Modules/xxsubtype.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Modules/xxsubtype.c 2021-08-21 15:42:18.001177094 +0200 @@ -1,6 +1,10 @@ #include "Python.h" #include "structmember.h" +#ifndef CLOCKS_PER_SEC +#include <bits/time.h> +#endif + PyDoc_STRVAR(xxsubtype__doc__, "xxsubtype is an example module showing how to subtype builtin types from C.\n" "test_descr.py in the standard test suite requires it in order to complete.\n" diff -ubBr Python-2.7.18.orig/Objects/exceptions.c Python-2.7.18/Objects/exceptions.c --- Python-2.7.18.orig/Objects/exceptions.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Objects/exceptions.c 2021-08-21 15:42:18.001177094 +0200 @@ -818,7 +818,7 @@ * WindowsError extends OSError */ #ifdef MS_WINDOWS -#include "errmap.h" +#include "PC/errmap.h" static int WindowsError_clear(PyWindowsErrorObject *self) diff -ubBr Python-2.7.18.orig/Python/dynload_shlib.c Python-2.7.18/Python/dynload_shlib.c --- Python-2.7.18.orig/Python/dynload_shlib.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Python/dynload_shlib.c 2021-08-21 15:42:18.005177091 +0200 @@ -32,7 +32,7 @@ const struct filedescr _PyImport_DynLoadFiletab[] = { -#ifdef __CYGWIN__ +#if defined(__CYGWIN__) || defined(__MINGW32__) {".dll", "rb", C_EXTENSION}, {"module.dll", "rb", C_EXTENSION}, #else diff -ubBr Python-2.7.18.orig/Python/dynload_win.c Python-2.7.18/Python/dynload_win.c --- Python-2.7.18.orig/Python/dynload_win.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Python/dynload_win.c 2021-08-21 15:42:18.005177091 +0200 @@ -1,7 +1,112 @@ /* Support for dynamic loading of extension modules */ +/* +Entry point for the Windows NT DLL. + +About the only reason for having this, is so initall() can automatically +be called, removing that burden (and possible source of frustration if +forgotten) from the programmer. + +*/ + #include "Python.h" +#include "windows.h" + +#ifdef Py_ENABLE_SHARED +char dllVersionBuffer[16] = ""; // a private buffer + +// Python Globals +HMODULE PyWin_DLLhModule = NULL; +const char *PyWin_DLLVersionString = dllVersionBuffer; + +// Windows "Activation Context" work: +// Our .pyd extension modules are generally built without a manifest (ie, +// those included with Python and those built with a default distutils. +// This requires we perform some "activation context" magic when loading our +// extensions. In summary: +// * As our DLL loads we save the context being used. +// * Before loading our extensions we re-activate our saved context. +// * After extension load is complete we restore the old context. +// As an added complication, this magic only works on XP or later - we simply +// use the existence (or not) of the relevant function pointers from kernel32. +// See bug 4566 (http://python.org/sf/4566) for more details. + +typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *); +typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *); +typedef BOOL (WINAPI * PFN_DEACTIVATEACTCTX)(DWORD, ULONG_PTR); +typedef BOOL (WINAPI * PFN_ADDREFACTCTX)(HANDLE); +typedef BOOL (WINAPI * PFN_RELEASEACTCTX)(HANDLE); + +// locals and function pointers for this activation context magic. +static HANDLE PyWin_DLLhActivationContext = NULL; // one day it might be public +static PFN_GETCURRENTACTCTX pfnGetCurrentActCtx = NULL; +static PFN_ACTIVATEACTCTX pfnActivateActCtx = NULL; +static PFN_DEACTIVATEACTCTX pfnDeactivateActCtx = NULL; +static PFN_ADDREFACTCTX pfnAddRefActCtx = NULL; +static PFN_RELEASEACTCTX pfnReleaseActCtx = NULL; + +void _LoadActCtxPointers() +{ + HINSTANCE hKernel32 = GetModuleHandleW(L"kernel32.dll"); + if (hKernel32) + pfnGetCurrentActCtx = (PFN_GETCURRENTACTCTX) GetProcAddress(hKernel32, "GetCurrentActCtx"); + // If we can't load GetCurrentActCtx (ie, pre XP) , don't bother with the rest. + if (pfnGetCurrentActCtx) { + pfnActivateActCtx = (PFN_ACTIVATEACTCTX) GetProcAddress(hKernel32, "ActivateActCtx"); + pfnDeactivateActCtx = (PFN_DEACTIVATEACTCTX) GetProcAddress(hKernel32, "DeactivateActCtx"); + pfnAddRefActCtx = (PFN_ADDREFACTCTX) GetProcAddress(hKernel32, "AddRefActCtx"); + pfnReleaseActCtx = (PFN_RELEASEACTCTX) GetProcAddress(hKernel32, "ReleaseActCtx"); + } +} + +ULONG_PTR _Py_ActivateActCtx() +{ + ULONG_PTR ret = 0; + if (PyWin_DLLhActivationContext && pfnActivateActCtx) + if (!(*pfnActivateActCtx)(PyWin_DLLhActivationContext, &ret)) { + OutputDebugString("Python failed to activate the activation context before loading a DLL\n"); + ret = 0; // no promise the failing function didn't change it! + } + return ret; +} + +void _Py_DeactivateActCtx(ULONG_PTR cookie) +{ + if (cookie && pfnDeactivateActCtx) + if (!(*pfnDeactivateActCtx)(0, cookie)) + OutputDebugString("Python failed to de-activate the activation context\n"); +} + +BOOL WINAPI DllMain (HANDLE hInst, + ULONG ul_reason_for_call, + LPVOID lpReserved) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + PyWin_DLLhModule = hInst; + // 1000 is a magic number I picked out of the air. Could do with a #define, I spose... + LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); + + // and capture our activation context for use when loading extensions. + _LoadActCtxPointers(); + if (pfnGetCurrentActCtx && pfnAddRefActCtx) + if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) + if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext)) + OutputDebugString("Python failed to load the default activation context\n"); + break; + + case DLL_PROCESS_DETACH: + if (pfnReleaseActCtx) + (*pfnReleaseActCtx)(PyWin_DLLhActivationContext); + break; + } + return TRUE; +} + +#endif /* Py_ENABLE_SHARED */ + #ifdef HAVE_DIRECT_H #include <direct.h> @@ -28,6 +133,9 @@ /* Case insensitive string compare, to avoid any dependencies on particular C RTL implementations */ +#ifdef __MINGW32__ +#define strcasecmp py_strcasecmp +#endif static int strcasecmp (char *string1, char *string2) { int first, second; diff -ubBr Python-2.7.18.orig/Python/frozenmain.c Python-2.7.18/Python/frozenmain.c --- Python-2.7.18.orig/Python/frozenmain.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Python/frozenmain.c 2021-08-21 15:42:18.005177091 +0200 @@ -3,7 +3,7 @@ #include "Python.h" -#ifdef MS_WINDOWS +#if defined (MS_WINDOWS) && ! defined (__MINGW32__) extern void PyWinFreeze_ExeInit(void); extern void PyWinFreeze_ExeTerm(void); extern int PyInitFrozenExtensions(void); @@ -32,13 +32,13 @@ setbuf(stderr, (char *)NULL); } -#ifdef MS_WINDOWS +#if defined (MS_WINDOWS) && ! defined (__MINGW32__) PyInitFrozenExtensions(); #endif /* MS_WINDOWS */ if (argc >= 1) Py_SetProgramName(argv[0]); Py_Initialize(); -#ifdef MS_WINDOWS +#if defined (MS_WINDOWS) && ! defined (__MINGW32__) PyWinFreeze_ExeInit(); #endif @@ -61,7 +61,7 @@ if (inspect && isatty((int)fileno(stdin))) sts = PyRun_AnyFile(stdin, "<stdin>") != 0; -#ifdef MS_WINDOWS +#if defined (MS_WINDOWS) && ! defined (__MINGW32__) PyWinFreeze_ExeTerm(); #endif Py_Finalize(); diff -ubBr Python-2.7.18.orig/Python/pythonrun.c Python-2.7.18/Python/pythonrun.c --- Python-2.7.18.orig/Python/pythonrun.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Python/pythonrun.c 2021-08-21 15:42:18.005177091 +0200 @@ -37,6 +37,16 @@ #include "windows.h" #endif +#ifdef __MINGW32__ +#include <minwindef.h> +#include <libloaderapi.h> +#endif + +#ifdef __MINGW32__ +#include <minwindef.h> +#include <libloaderapi.h> +#endif + #ifdef __cplusplus extern "C" { #endif @@ -698,12 +708,43 @@ default_home = home; } +#ifdef __MINGW32__ +static char * +get_home_path(void) +{ + static char path[MAX_PATH*2]; + HMODULE hm = NULL; + + if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCSTR) &Py_SetPythonHome, &hm) == 0) + { + return NULL; + } + if (GetModuleFileName(hm, path, sizeof(path)) == 0) + { + return NULL; + } + char *p = strstr(path, "\\bin\\"); + if (p) + *p = '\0'; + return path; +} +#endif + char * Py_GetPythonHome(void) { char *home = default_home; if (home == NULL && !Py_IgnoreEnvironmentFlag) home = Py_GETENV("PYTHONHOME"); +#ifdef __MINGW32__ + if (home == NULL) { + char *path = get_home_path(); + if (path) + home = path; + } +#endif return home; } diff -ubBr Python-2.7.18.orig/Python/thread.c Python-2.7.18/Python/thread.c --- Python-2.7.18.orig/Python/thread.c 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/Python/thread.c 2021-08-21 15:42:18.005177091 +0200 @@ -61,6 +61,13 @@ #endif /* _POSIX_THREADS */ +#ifdef __MINGW32__ +#ifdef _POSIX_THREADS +#undef _POSIX_THREADS +#endif +#define NT_THREADS +#endif + #ifdef Py_DEBUG static int thread_debug = 0; diff -ubBr Python-2.7.18.orig/README Python-2.7.18/README --- Python-2.7.18.orig/README 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/README 2021-08-21 15:42:18.005177091 +0200 @@ -1177,6 +1177,37 @@ do this. +Cross Compiling +--------------- + +Python can be cross compiled by supplying different --build and --host +parameters to configure. Python is compiled on the "build" system and +executed on the "host" system. Cross compiling python requires a +native Python on the build host, and a natively compiled tool `Pgen'. + +Before cross compiling, Python must first be compiled and installed on +the build host. The configure script will use `cc' and `python', or +environment variables CC_FOR_BUILD or PYTHON_FOR_BUILD, eg: + + CC_FOR_BUILD=gcc-3.3 \ + PYTHON_FOR_BUILD=python2.4 \ + .../configure --build=i686-linux --host=i586-mingw32 + +Cross compiling has been tested under linux, mileage may vary for +other platforms. + +A few reminders on using configure to cross compile: +- Cross compile tools must be in PATH, +- Cross compile tools must be prefixed with the host type + (ie i586-mingw32-gcc, i586-mingw32-ranlib, ...), +- CC, CXX, AR, and RANLIB must be undefined when running configure, + they will be auto-detected. + +If you need a cross compiler, Debian ships several several (eg: avr, +m68hc1x, mingw32), while dpkg-cross easily creates others. Otherwise, +check out Dan Kegel's crosstool: http://www.kegel.com/crosstool . + + Miscellaneous issues ==================== diff -ubBr Python-2.7.18.orig/setup.py Python-2.7.18/setup.py --- Python-2.7.18.orig/setup.py 2020-04-19 23:13:39.000000000 +0200 +++ Python-2.7.18/setup.py 2021-08-21 15:49:52.540963628 +0200 @@ -35,6 +35,10 @@ # This global variable is used to hold the list of modules to be disabled. disabled_module_list = [] +import sysconfig +sysconfig.get_config_vars().update(os.environ) + + def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (at the front) if 1) 'dir' is not already in 'dirlist' @@ -240,6 +244,8 @@ # Fix up the autodetected modules, prefixing all the source files # with Modules/ and adding Python's include directory to the path. (srcdir,) = sysconfig.get_config_vars('srcdir') + if os.environ.get('CROSS_COMPILING') == 'yes': + srcdir = os.environ.get('SRCDIR') if not srcdir: # Maybe running on Windows but not using CYGWIN? raise ValueError("No source directory; cannot proceed.") @@ -382,6 +388,10 @@ self.announce('WARNING: skipping import check for Cygwin-based "%s"' % ext.name) return + if os.environ.get('CROSS_COMPILING') == 'yes': + self.announce('WARNING: skipping import check for cross compiled "%s"' + % ext.name) + return ext_filename = os.path.join( self.build_lib, self.get_ext_filename(self.get_ext_fullname(ext.name))) @@ -499,6 +509,16 @@ finally: os.unlink(tmpfile) + def get_platform(self): + # Get value of target's sys.platform + p = sys.platform + if os.environ.get('CROSS_COMPILING') == 'yes': + p = os.environ.get('CROSS_TARGET') + for platform in ['cygwin', 'mingw', 'beos', 'darwin', 'atheos', 'osf1']: + if p.startswith(platform): + return platform + return p + def detect_modules(self): # Ensure that /usr/local is always used if not cross_compiling: @@ -2148,6 +2168,8 @@ elif host_platform.startswith('hp-ux'): extra_link_args.append('-fPIC') + elif host_platform.startswith('mingw'): + extra_link_args.append('-ldl') ext = Extension('_ctypes', include_dirs=include_dirs, @@ -2260,6 +2282,8 @@ # mode 755. All installed directories will get mode 755. so_ext = sysconfig.get_config_var("SO") + if os.environ.get('CROSS_COMPILING') == 'yes': + so_ext = os.environ.get('SO') def install(self): outfiles = install_lib.install(self)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor