Lines Matching +full:binutils +full:- +full:mingw +full:- +full:w64
1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
4 --- /dev/null
6 @@ -0,0 +1,418 @@
9 +# gh-84728: "paths-ignore" is not used to skip documentation-only PRs, because
11 +# mandatory but not scheduled because of "paths-ignore".
16 + - 'main'
17 + - '3.11'
18 + - '3.10'
19 + - '3.9'
20 + - '3.8'
21 + - '3.7'
24 + - 'main'
25 + - '3.11'
26 + - '3.10'
27 + - '3.9'
28 + - '3.8'
29 + - '3.7'
35 + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
36 + cancel-in-progress: true
41 + runs-on: ubuntu-latest
42 + timeout-minutes: 10
48 + - uses: actions/checkout@v3
49 + - name: Check for source changes
52 + if [ -z "$GITHUB_BASE_REF" ]; then
56 + git fetch origin $GITHUB_BASE_REF --depth=1
60 + # "git fetch --depth=1").
69 + # https://github.com/python/core-workflow/issues/373
70 + git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && ec…
71 + git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE '(ssl|hashlib|hmac|^.github)…
73 + - name: Compute hash for config cache key
80 + runs-on: ubuntu-20.04
84 + - uses: actions/checkout@v2
85 + - uses: actions/setup-python@v2
86 + - name: Install Dependencies
88 + sudo ./.github/workflows/posix-deps-apt.sh
89 + sudo apt-get install -yq abigail-tools
90 + - name: Build CPython
92 + CFLAGS: -g3 -O0
95 + ./configure --enable-shared
96 + make -j4
97 + - name: Check for changes in the ABI
100 + if ! make check-abidump; then
106 … echo "To learn more about this check: https://devguide.python.org/setup/#regenerate-the-abi-dump"
110 + - name: Generate updated ABI files
113 + make regen-abidump
114 + - uses: actions/upload-artifact@v3
118 + name: abi-data
123 + runs-on: ubuntu-latest
124 + timeout-minutes: 60
128 + - uses: actions/checkout@v3
129 + - name: Restore config.cache
133 + key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
134 + - uses: actions/setup-python@v3
135 + - name: Install Dependencies
136 + run: sudo ./.github/workflows/posix-deps-apt.sh
137 + - name: Add ccache to PATH
139 + - name: Configure ccache action
140 + uses: hendrikmuhs/ccache-action@v1.2
141 + - name: Check Autoconf version 2.69 and aclocal 1.16.3
145 + grep -q "runstatedir" configure
146 + grep -q "PKG_PROG_PKG_CONFIG" aclocal.m4
147 + - name: Configure CPython
150 + ./configure --config-cache --with-pydebug --enable-shared
151 + - name: Regenerate autoconf files with container image
152 + run: make regen-configure
153 + - name: Build CPython
156 + # so we run it before regen-global-objects gets rum (in regen-all).
157 + make regen-deepfreeze
158 + make -j4 regen-all
159 + make regen-stdlib-module-names
160 + - name: Check for changes
162 + git add -u
163 + changes=$(git status --porcelain)
165 + if test -n "$changes"; then
167 + echo "Perhaps you forgot to run make regen-all or build.bat --regen. ;)"
171 + git diff --staged || true
174 + - name: Check exported libpython symbols
176 + - name: Check limited ABI symbols
177 + run: make check-limited-abi
181 + runs-on: windows-latest
182 + timeout-minutes: 60
188 + - uses: actions/checkout@v3
189 + - name: Build CPython
190 + run: .\PCbuild\build.bat -e -d -p Win32
191 + - name: Display build info
192 + run: .\python.bat -m test.pythoninfo
193 + - name: Tests
194 + run: .\PCbuild\rt.bat -p Win32 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
198 + runs-on: windows-latest
199 + timeout-minutes: 60
205 + - uses: actions/checkout@v3
206 + - name: Register MSVC problem matcher
207 + run: echo "::add-matcher::.github/problem-matchers/msvc.json"
208 + - name: Build CPython
209 + run: .\PCbuild\build.bat -e -d -p x64
210 + - name: Display build info
211 + run: .\python.bat -m test.pythoninfo
212 + - name: Tests
213 + run: .\PCbuild\rt.bat -p x64 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
217 + runs-on: macos-latest
218 + timeout-minutes: 60
227 + - uses: actions/checkout@v3
228 + - name: Restore config.cache
232 + key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
233 + - name: Install Homebrew dependencies
234 + run: brew install pkg-config openssl@1.1 xz gdbm tcl-tk
235 + - name: Configure CPython
237 + CFLAGS="-I$(brew --prefix gdbm)/include -I$(brew --prefix xz)/include" \
238 + LDFLAGS="-L$(brew --prefix gdbm)/lib -I$(brew --prefix xz)/lib" \
239 + PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
241 + --config-cache \
242 + --with-pydebug \
243 + --prefix=/opt/python-dev \
244 + --with-openssl="$(brew --prefix openssl@1.1)"
245 + - name: Build CPython
246 + run: make -j4
247 + - name: Display build info
249 + - name: Tests
250 + run: make buildbottest TESTOPTS="-j4 -uall,-cpu"
254 + runs-on: ubuntu-20.04
255 + timeout-minutes: 60
262 + - uses: actions/checkout@v3
263 + - name: Register gcc problem matcher
264 + run: echo "::add-matcher::.github/problem-matchers/gcc.json"
265 + - name: Install Dependencies
266 + run: sudo ./.github/workflows/posix-deps-apt.sh
267 + - name: Configure OpenSSL env vars
272 + - name: 'Restore OpenSSL build'
273 + id: cache-openssl
277 + key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
278 + - name: Install OpenSSL
279 + if: steps.cache-openssl.outputs.cache-hit != 'true'
280 …run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $…
281 + - name: Add ccache to PATH
284 + - name: Configure ccache action
285 + uses: hendrikmuhs/ccache-action@v1.2
286 + - name: Setup directory envs for out-of-tree builds
288 + echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHU…
289 + echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_…
290 + - name: Create directories for read-only out-of-tree builds
291 + run: mkdir -p $CPYTHON_RO_SRCDIR $CPYTHON_BUILDDIR
292 + - name: Bind mount sources read-only
293 + run: sudo mount --bind -o ro $GITHUB_WORKSPACE $CPYTHON_RO_SRCDIR
294 + - name: Restore config.cache
298 + key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
299 + - name: Configure CPython out-of-tree
300 + working-directory: ${{ env.CPYTHON_BUILDDIR }}
302 + ../cpython-ro-srcdir/configure \
303 + --config-cache \
304 + --with-pydebug \
305 + --with-openssl=$OPENSSL_DIR
306 + - name: Build CPython out-of-tree
307 + working-directory: ${{ env.CPYTHON_BUILDDIR }}
308 + run: make -j4
309 + - name: Display build info
310 + working-directory: ${{ env.CPYTHON_BUILDDIR }}
312 + - name: Remount sources writable for tests
314 + run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
315 + - name: Tests
316 + working-directory: ${{ env.CPYTHON_BUILDDIR }}
317 + run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
321 + runs-on: ubuntu-20.04
322 + timeout-minutes: 60
326 + fail-fast: false
335 + - uses: actions/checkout@v3
336 + - name: Restore config.cache
340 + key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
341 + - name: Register gcc problem matcher
342 + run: echo "::add-matcher::.github/problem-matchers/gcc.json"
343 + - name: Install Dependencies
344 + run: sudo ./.github/workflows/posix-deps-apt.sh
345 + - name: Configure OpenSSL env vars
350 + - name: 'Restore OpenSSL build'
351 + id: cache-openssl
355 + key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
356 + - name: Install OpenSSL
357 + if: steps.cache-openssl.outputs.cache-hit != 'true'
358 …run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $…
359 + - name: Add ccache to PATH
362 + - name: Configure ccache action
363 + uses: hendrikmuhs/ccache-action@v1.2
364 + - name: Configure CPython
365 + run: ./configure --config-cache --with-pydebug --with-openssl=$OPENSSL_DIR
366 + - name: Build CPython
367 + run: make -j4
368 + - name: Display build info
370 + - name: SSL tests
375 + runs-on: ubuntu-20.04
376 + timeout-minutes: 60
384 + - uses: actions/checkout@v3
385 + - name: Restore config.cache
389 + key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
390 + - name: Register gcc problem matcher
391 + run: echo "::add-matcher::.github/problem-matchers/gcc.json"
392 + - name: Install Dependencies
393 + run: sudo ./.github/workflows/posix-deps-apt.sh
394 + - name: Set up GCC-10 for ASAN
395 + uses: egor-tensin/setup-gcc@v1
398 + - name: Configure OpenSSL env vars
403 + - name: 'Restore OpenSSL build'
404 + id: cache-openssl
408 + key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
409 + - name: Install OpenSSL
410 + if: steps.cache-openssl.outputs.cache-hit != 'true'
411 …run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $…
412 + - name: Add ccache to PATH
415 + - name: Configure ccache action
416 + uses: hendrikmuhs/ccache-action@v1.2
417 + - name: Configure CPython
418 + run: ./configure --config-cache --with-address-sanitizer --without-pymalloc
419 + - name: Build CPython
420 + run: make -j4
421 + - name: Display build info
423 + - name: Tests
424 + run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
425 diff --git a/.gitignore b/.gitignore
427 --- a/.gitignore
429 @@ -114,6 +114,7 @@ PCbuild/win32/
437 @@ -150,6 +151,3 @@ Python/frozen_modules/MANIFEST
441 -
442 -# main branch only: ABI files are not checked/maintained
443 -Doc/data/python*.abi
444 diff --git a/Include/bytesobject.h b/Include/bytesobject.h
446 --- a/Include/bytesobject.h
448 @@ -35,9 +35,9 @@ PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
452 - Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
455 - Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
460 diff --git a/Include/fileobject.h b/Include/fileobject.h
462 --- a/Include/fileobject.h
464 @@ -30,7 +30,7 @@ PyAPI_DATA(int) Py_UTF8Mode;
467 /* A routine to check if a file descriptor can be select()-ed. */
468 -#ifdef _MSC_VER
470 /* On Windows, any socket fd can be select()-ed, no matter how high */
473 diff --git a/Include/internal/pycore_condvar.h b/Include/internal/pycore_condvar.h
475 --- a/Include/internal/pycore_condvar.h
477 @@ -5,6 +5,12 @@
490 @@ -39,6 +45,10 @@
500 /* non-emulated condition variables are provided for those that want
501 diff --git a/Include/iscygpty.h b/Include/iscygpty.h
504 --- /dev/null
506 @@ -0,0 +1,41 @@
508 + * iscygpty.h -- part of ptycheck
509 + * https://github.com/k-takata/ptycheck
511 + * Copyright (c) 2015-2017 K.Takata
548 diff --git a/Include/osdefs.h b/Include/osdefs.h
550 --- a/Include/osdefs.h
552 @@ -10,7 +10,6 @@ extern "C" {
556 -#define MAXPATHLEN 256
560 diff --git a/Include/py_curses.h b/Include/py_curses.h
562 --- a/Include/py_curses.h
564 @@ -36,6 +36,13 @@
578 diff --git a/Include/pyerrors.h b/Include/pyerrors.h
580 --- a/Include/pyerrors.h
582 @@ -315,9 +315,9 @@ PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
586 - Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
589 - Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
594 diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h
596 --- a/Include/pylifecycle.h
598 @@ -21,6 +21,15 @@ PyAPI_FUNC(int) Py_IsInitialized(void);
612 /* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
614 diff --git a/Include/pyport.h b/Include/pyport.h
616 --- a/Include/pyport.h
618 @@ -53,6 +53,21 @@
623 +/* Translate GCC[mingw*] platform specific defines to those
638 Symbols and macros to supply platform-independent interfaces to basic
640 @@ -509,12 +524,12 @@ extern char * _getpty(int *, int, mode_t, int);
644 - All windows ports, except cygwin, are handled in PC/pyconfig.h.
647 - Cygwin is the only other autoconf platform requiring special
648 + Cygwin and Mingw is the only other autoconf platform requiring special
651 -#if defined(__CYGWIN__)
656 @@ -527,21 +542,23 @@ extern char * _getpty(int *, int, mode_t, int);
660 - /* except for Cygwin to handle embedding */
661 -# if defined(__CYGWIN__)
662 + /* except for Cygwin/Mingw to handle embedding */
665 -# else /* __CYGWIN__ */
668 -# endif /* __CYGWIN__ */
673 /* Under Cygwin, auto-import functions to prevent compilation */
675 /* http://docs.python.org/extending/windows.html#a-cookbook-approach */
676 -# if !defined(__CYGWIN__)
681 -# endif /* !__CYGWIN__ */
686 @@ -641,6 +658,12 @@ extern char * _getpty(int *, int, mode_t, int);
699 diff --git a/Include/pythread.h b/Include/pythread.h
701 --- a/Include/pythread.h
703 @@ -7,6 +7,12 @@ typedef void *PyThread_type_lock;
714 * backwards compatibility, ie failure -> 0, success -> 1. */
716 diff --git a/Include/sysmodule.h b/Include/sysmodule.h
718 --- a/Include/sysmodule.h
720 @@ -15,9 +15,9 @@ Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
724 - Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
727 - Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
732 diff --git a/Lib/compileall.py b/Lib/compileall.py
734 --- a/Lib/compileall.py
736 @@ -38,6 +38,8 @@ def _walk_dir(dir, maxlevels, quiet=0):
745 diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
747 --- a/Lib/ctypes/__init__.py
749 @@ -458,7 +458,9 @@ def LoadLibrary(self, name):
753 -if _os.name == "nt":
760 diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
762 --- a/Lib/ctypes/util.py
764 @@ -31,6 +31,12 @@ def _get_build_version():
777 @@ -54,6 +60,9 @@ def find_msvcrt():
782 + if sysconfig.get_platform().startswith('mingw'):
787 diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
789 --- a/Lib/distutils/ccompiler.py
791 @@ -9,7 +9,7 @@
795 -from distutils.util import split_quoted, execute
800 @@ -948,6 +948,8 @@ def get_default_compiler(osname=None, platform=None):
804 + if get_platform().startswith('mingw'):
809 diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
811 --- a/Lib/distutils/command/build_ext.py
813 @@ -186,7 +186,7 @@ def finalize_options(self):
817 - if os.name == 'nt':
818 + if os.name == 'nt' and not self.plat_name.startswith(('mingw')):
819 # the 'libs' directory is for binary installs - we assume that
821 # cross-compiling via a binary install anyway, so we let it go.
822 @@ -218,15 +218,16 @@ def finalize_options(self):
826 - if sys.platform[:6] == 'cygwin':
827 - if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
828 + if sys.platform[:6] == 'cygwin' or self.plat_name.startswith(('mingw')):
834 - "config"))
838 - self.library_dirs.append('.')
843 @@ -237,7 +238,7 @@ def finalize_options(self):
847 - self.library_dirs.append('.')
851 # it has to be a list of 2-tuples. All the preprocessor symbols
852 @@ -712,6 +713,20 @@ def get_libraries(self, ext):
858 + # cross-compilation (at least for mingw build).
859 + if self.plat_name.startswith('mingw'):
866 + if lib.startswith('-l'):
873 diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
875 --- a/Lib/distutils/command/install.py
877 @@ -72,8 +72,8 @@
881 - 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
882 - 'scripts': '$userbase/Python$py_version_nodot/Scripts',
888 @@ -81,7 +81,7 @@
892 - '$userbase/include/python$py_version_short$abiflags/$dist_name',
897 @@ -311,6 +311,7 @@ def finalize_options(self):
901 … 'py_version_short_plat': f'{sys.version_info[0]}.{sys.version_info[1]}-{get_platform()}' if …
905 @@ -363,7 +364,8 @@ def finalize_options(self):
907 # Convert directories from Unix /-separated syntax to the local
909 - self.convert_paths('lib', 'purelib', 'platlib',
915 diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
917 --- a/Lib/distutils/cygwinccompiler.py
919 @@ -44,12 +44,13 @@
920 # (ld supports -shared)
921 # * mingw gcc 3.2/ld 2.13 works
922 # (ld supports -shared)
923 +# * llvm-mingw with Clang 11 works
924 +# (lld supports -shared)
929 -from subprocess import Popen, PIPE, check_output
930 -import re
935 @@ -57,6 +58,7 @@
943 @@ -91,6 +93,7 @@ class CygwinCCompiler(UnixCCompiler):
951 @@ -109,50 +112,28 @@ def __init__(self, verbose=0, dry_run=0, force=0):
955 - self.gcc_version, self.ld_version, self.dllwrap_version = \
956 - get_versions()
957 - self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" %
958 - (self.gcc_version,
959 - self.ld_version,
960 - self.dllwrap_version) )
961 -
962 - # ld_version >= "2.10.90" and < "2.13" should also be able to use
963 - # gcc -mdll instead of dllwrap
964 - # Older dllwraps had own version numbers, newer ones use the
965 - # same as the rest of binutils ( also ld )
966 - # dllwrap 2.10.90 is buggy
967 - if self.ld_version >= "2.10.90":
968 - self.linker_dll = "gcc"
969 - else:
970 - self.linker_dll = "dllwrap"
974 - # ld_version >= "2.13" support -shared so use it instead of
975 - # -mdll -static
976 - if self.ld_version >= "2.13":
977 - shared_option = "-shared"
978 - else:
979 - shared_option = "-mdll -static"
980 -
981 - # Hard-code GCC because that's what this is all about.
982 - # XXX optimization, warnings etc. should be customizable.
983 - self.set_executables(compiler='gcc -mcygwin -O -Wall',
984 - compiler_so='gcc -mcygwin -mdll -O -Wall',
985 - compiler_cxx='g++ -mcygwin -O -Wall',
986 - linker_exe='gcc -mcygwin',
994 + shared_option = "-shared"
996 + self.set_executables(compiler='%s -mcygwin -O -Wall' % self.cc,
997 + compiler_so='%s -mcygwin -mdll -O -Wall' % self.cc,
998 + compiler_cxx='%s -mcygwin -O -Wall' % self.cxx,
999 + linker_exe='%s -mcygwin' % self.cc,
1000 linker_so=('%s -mcygwin %s' %
1003 - # cygwin and mingw32 need different sets of libraries
1004 - if self.gcc_version == "2.91.57":
1005 - # cygwin shouldn't need msvcrt, but without the dlls will crash
1006 - # (gcc version 2.91.57) -- perhaps something about initialization
1007 - self.dll_libraries=["msvcrt"]
1008 - self.warn(
1009 - "Consider upgrading to a newer version of gcc")
1010 - else:
1011 - # Include the appropriate MSVC runtime library if Python was built
1012 - # with MSVC 7.0 or later.
1013 - self.dll_libraries = get_msvcr()
1020 @@ -162,6 +143,28 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
1021 self.spawn(["windres", "-i", src, "-o", obj])
1028 + # * '-h dir' specifies the directory for the generated include file
1029 + # * '-r dir' specifies the target directory of the generated RC file and the binary …
1032 + # we use the source-directory for the include file and
1039 + self.spawn(['windmc'] + ['-h', h_dir, '-r', rc_dir] + [src])
1043 + self.spawn(['windres', '-i', rc_file, '-o', obj])
1046 else: # for other files use the C-compiler
1048 self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
1049 @@ -214,28 +217,21 @@ def link(self, target_desc, objects, output_filename, output_dir=None,
1051 # next add options for def-file and to creating import libraries
1053 - # dllwrap uses different options than gcc/ld
1054 - if self.linker_dll == "dllwrap":
1055 - extra_preargs.extend(["--output-lib", lib_file])
1056 - # for dllwrap we have to use a special option
1057 - extra_preargs.extend(["--def", def_file])
1058 - # we use gcc/ld here and can be sure ld is >= 2.9.10
1059 - else:
1060 - # doesn't work: bfd_close build\...\libfoo.a: Invalid operation
1061 - #extra_preargs.extend(["-Wl,--out-implib,%s" % lib_file])
1062 - # for gcc/ld the def-file is specified as any object files
1063 - objects.append(def_file)
1065 + #extra_preargs.extend(["-Wl,--out-implib,%s" % lib_file])
1066 + # for gcc/ld the def-file is specified as any object files
1074 - # otherwise we let dllwrap/ld strip the output file
1079 - if not debug:
1081 extra_preargs.append("-s")
1084 @@ -253,11 +249,16 @@ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
1088 - # use normcase to make sure '.rc' is really '.rc' and not '.RC'
1089 - base, ext = os.path.splitext(os.path.normcase(src_name))
1090 - if ext not in (self.src_extensions + ['.rc','.res']):
1104 @@ -279,31 +280,18 @@ def __init__(self, verbose=0, dry_run=0, force=0):
1108 - # ld_version >= "2.13" support -shared so use it instead of
1109 - # -mdll -static
1110 - if self.ld_version >= "2.13":
1111 - shared_option = "-shared"
1112 - else:
1113 - shared_option = "-mdll -static"
1114 -
1115 - # A real mingw32 doesn't need to specify a different entry point,
1116 - # but cygwin 2.91.57 in no-cygwin-mode needs it.
1117 - if self.gcc_version <= "2.91.57":
1118 - entry_point = '--entry _DllMain@12'
1119 - else:
1120 - entry_point = ''
1121 + shared_option = "-shared"
1123 - if is_cygwingcc():
1126 'Cygwin gcc cannot be used with --compiler=mingw32')
1128 - self.set_executables(compiler='gcc -O -Wall',
1129 - compiler_so='gcc -mdll -O -Wall',
1130 - compiler_cxx='g++ -O -Wall',
1131 - linker_exe='gcc',
1132 - linker_so='%s %s %s'
1133 - % (self.linker_dll, shared_option,
1134 - entry_point))
1135 + self.set_executables(compiler='%s -O2 -Wall' % self.cc,
1136 + compiler_so='%s -mdll -O2 -Wall' % self.cc,
1137 + compiler_cxx='%s -O2 -Wall' % self.cxx,
1141 # Maybe we should also append -mthreads, but then the finished
1143 # (-mthreads: Support thread-safe exception handling on `Mingw32')
1144 @@ -313,7 +301,7 @@ def __init__(self, verbose=0, dry_run=0, force=0):
1148 - self.dll_libraries = get_msvcr()
1153 @@ -351,6 +339,10 @@ def check_config_h():
1164 @@ -366,38 +358,8 @@ def check_config_h():
1168 -RE_VERSION = re.compile(br'(\d+\.\d+(\.\d+)*)')
1169 -
1170 -def _find_exe_version(cmd):
1171 - """Find the version of an executable by running `cmd` in the shell.
1172 -
1173 - If the command is not found, or the output does not match
1174 - `RE_VERSION`, returns None.
1175 - """
1176 - executable = cmd.split()[0]
1177 - if find_executable(executable) is None:
1178 - return None
1179 - out = Popen(cmd, shell=True, stdout=PIPE).stdout
1180 - try:
1181 - out_string = out.read()
1182 - finally:
1183 - out.close()
1184 - result = RE_VERSION.search(out_string)
1185 - if result is None:
1186 - return None
1187 - # LooseVersion works with strings
1188 - # so we need to decode our bytes
1189 - return LooseVersion(result.group(1).decode())
1190 -
1191 -def get_versions():
1192 - """ Try to find out the versions of gcc, ld and dllwrap.
1193 -
1194 - If not possible it returns None for it.
1195 - """
1196 - commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version']
1197 - return tuple([_find_exe_version(cmd) for cmd in commands])
1199 -def is_cygwingcc():
1200 - '''Try to determine if the gcc that would be used is from cygwin.'''
1201 - out_string = check_output(['gcc', '-dumpmachine'])
1204 + out_string = check_output(shlex.split(cc) + ['-dumpmachine'])
1206 diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py
1208 --- a/Lib/distutils/msvc9compiler.py
1210 @@ -291,8 +291,6 @@ def query_vcvarsall(version, arch="x86"):
1214 -if VERSION < 8.0:
1215 - raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
1219 @@ -327,6 +325,8 @@ class MSVCCompiler(CCompiler) :
1228 diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
1230 --- a/Lib/distutils/sysconfig.py
1232 @@ -64,8 +64,23 @@ def parse_config_h(fp, g=None):
1236 -_init_nt = partial(_init_non_posix, _config_vars)
1239 + # GCC[mingw*] use posix build system
1243 + if host_platform.startswith('mingw'):
1257 @@ -196,7 +211,23 @@ def customize_compiler(compiler):
1261 - if compiler.compiler_type == "unix":
1271 + _config_vars['OPT'] = "-fwrapv -O3 -Wall -Wstrict-prototypes"
1274 + _config_vars['LDSHARED'] = "gcc -shared -Wl,--enable-auto-image-base"
1280 # Perform first-time customization of compiler-related
1282 @@ -274,7 +305,7 @@ def get_python_inc(plat_specific=0, prefix=None):
1286 - if os.name == "posix":
1291 @@ -321,7 +352,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
1295 - if os.name == "posix":
1298 # Platform-specific modules (any module from a non-pure-Python
1300 diff --git a/Lib/distutils/tests/test_cygwinccompiler.py b/Lib/distutils/tests/test_cygwinccompiler…
1302 --- a/Lib/distutils/tests/test_cygwinccompiler.py
1304 @@ -8,7 +8,7 @@
1308 - CONFIG_H_UNCERTAIN, get_versions,
1313 @@ -81,40 +81,6 @@ def test_check_config_h(self):
1317 - def test_get_versions(self):
1318 -
1319 - # get_versions calls distutils.spawn.find_executable on
1320 - # 'gcc', 'ld' and 'dllwrap'
1321 - self.assertEqual(get_versions(), (None, None, None))
1322 -
1323 - # Let's fake we have 'gcc' and it returns '3.4.5'
1324 - self._exes['gcc'] = b'gcc (GCC) 3.4.5 (mingw special)\nFSF'
1325 - res = get_versions()
1326 - self.assertEqual(str(res[0]), '3.4.5')
1327 -
1328 - # and let's see what happens when the version
1329 - # doesn't match the regular expression
1330 - # (\d+\.\d+(\.\d+)*)
1331 - self._exes['gcc'] = b'very strange output'
1332 - res = get_versions()
1333 - self.assertEqual(res[0], None)
1334 -
1335 - # same thing for ld
1336 - self._exes['ld'] = b'GNU ld version 2.17.50 20060824'
1337 - res = get_versions()
1338 - self.assertEqual(str(res[1]), '2.17.50')
1339 - self._exes['ld'] = b'@(#)PROGRAM:ld PROJECT:ld64-77'
1340 - res = get_versions()
1341 - self.assertEqual(res[1], None)
1342 -
1343 - # and dllwrap
1344 - self._exes['dllwrap'] = b'GNU dllwrap 2.17.50 20060824\nFSF'
1345 - res = get_versions()
1346 - self.assertEqual(str(res[2]), '2.17.50')
1347 - self._exes['dllwrap'] = b'Cheese Wrap'
1348 - res = get_versions()
1349 - self.assertEqual(res[2], None)
1350 -
1354 diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
1356 --- a/Lib/distutils/unixccompiler.py
1358 @@ -249,9 +249,13 @@ def runtime_library_dir_option(self, dir):
1359 # -Wl whenever gcc was used in the past it is probably
1362 - # GNU ld needs an extra option to get a RUNPATH
1365 - return "-Wl,--enable-new-dtags,-R" + dir
1367 + "mingw" in compiler:
1370 + return "-Wl,--enable-new-dtags,-R" + dir
1372 return "-Wl,-R" + dir
1374 diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
1376 --- a/Lib/distutils/util.py
1378 @@ -37,6 +37,22 @@ def get_host_platform():
1399 return 'win-amd64'
1401 @@ -130,6 +146,13 @@ def convert_path (pathname):
1415 @@ -140,6 +163,10 @@ def change_root (new_root, pathname):
1426 @@ -149,9 +176,20 @@ def change_root (new_root, pathname):
1430 - if path[0] == '\\':
1433 - return os.path.join(new_root, path)
1449 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
1451 --- a/Lib/importlib/_bootstrap_external.py
1453 @@ -42,6 +42,10 @@
1459 + path_separators = path_separators[::-1]
1464 diff --git a/Lib/ntpath.py b/Lib/ntpath.py
1466 --- a/Lib/ntpath.py
1468 @@ -11,9 +11,7 @@
1472 -sep = '\\'
1474 -altsep = '/'
1478 @@ -23,6 +21,14 @@
1493 @@ -34,9 +40,33 @@
1497 - return b'\\/'
1524 - return '\\/'
1529 @@ -58,14 +88,14 @@ def normcase(s):
1533 - s = s.decode(encoding, 'surrogateescape').replace('/', '\\')
1541 - s.replace('/', '\\'))
1546 @@ -74,8 +104,8 @@ def normcase(s):
1550 - return os.fsencode(os.fsdecode(s).replace('/', '\\').lower())
1551 - return s.replace('/', '\\').lower()
1557 @@ -87,14 +117,9 @@ def normcase(s):
1561 - if isinstance(s, bytes):
1562 - sep = b'\\'
1563 - altsep = b'/'
1564 - colon_sep = b':\\'
1565 - else:
1566 - sep = '\\'
1567 - altsep = '/'
1568 - colon_sep = ':\\'
1575 @@ -106,14 +131,9 @@ def isabs(s):
1579 - if isinstance(path, bytes):
1580 - sep = b'\\'
1581 - seps = b'\\/'
1582 - colon = b':'
1583 - else:
1584 - sep = '\\'
1585 - seps = '\\/'
1586 - colon = ':'
1593 @@ -172,16 +192,10 @@ def splitdrive(p):
1597 - if isinstance(p, bytes):
1598 - sep = b'\\'
1599 - altsep = b'/'
1600 - colon = b':'
1601 - unc_prefix = b'\\\\?\\UNC\\'
1602 - else:
1603 - sep = '\\'
1604 - altsep = '/'
1605 - colon = ':'
1606 - unc_prefix = '\\\\?\\UNC\\'
1614 @@ -231,9 +245,9 @@ def split(p):
1618 - return genericpath._splitext(p, b'\\', b'/', b'.')
1621 - return genericpath._splitext(p, '\\', '/', '.')
1626 @@ -334,7 +348,7 @@ def expanduser(path):
1630 - return path
1635 @@ -361,7 +375,7 @@ def expanduser(path):
1639 - return userhome + path[i:]
1644 @@ -496,14 +510,12 @@ def expandvars(path):
1651 - sep = b'\\'
1652 - altsep = b'/'
1656 - sep = '\\'
1657 - altsep = '/'
1661 @@ -570,7 +582,7 @@ def _abspath_fallback(path):
1665 - return _getfullpathname(normpath(path))
1670 @@ -719,6 +731,7 @@ def realpath(path, *, strict=False):
1678 @@ -729,12 +742,11 @@ def realpath(path, *, strict=False):
1684 - sep = b'\\'
1688 - sep = '\\'
1692 @@ -789,13 +801,11 @@ def commonpath(paths):
1699 - sep = b'\\'
1700 - altsep = b'/'
1703 - sep = '\\'
1704 - altsep = '/'
1708 diff --git a/Lib/pathlib.py b/Lib/pathlib.py
1710 --- a/Lib/pathlib.py
1712 @@ -115,6 +115,8 @@ class _WindowsFlavour(_Flavour):
1721 diff --git a/Lib/site.py b/Lib/site.py
1723 --- a/Lib/site.py
1725 @@ -88,6 +88,12 @@
1731 +# GCC[mingw*] use posix build system
1738 @@ -273,7 +279,7 @@ def _getuserbase():
1742 - if os.name == "nt":
1747 @@ -283,14 +289,36 @@ def joinuser(*args):
1751 +# Copy of sysconfig.get_platform() but only for MinGW
1777 - ver_nodot = sys.winver.replace('.', '')
1778 - return f'{userbase}\\Python{ver_nodot}\\site-packages'
1781 + return f'{userbase}\\Python{ver_nodot}\\site-packages'
1782 + return f'{userbase}/lib/python{version[0]}.{version[1]}-{_get_platform()}/site-packages'
1785 return f'{userbase}/lib/python/site-packages'
1786 @@ -361,7 +389,7 @@ def getsitepackages(prefixes=None):
1790 - if os.sep == '/':
1795 @@ -392,7 +420,7 @@ def setquit():
1799 - if os.sep == '\\':
1801 eof = 'Ctrl-Z plus Return'
1803 eof = 'Ctrl-D (i.e. EOF)'
1804 diff --git a/Lib/ssl.py b/Lib/ssl.py
1806 --- a/Lib/ssl.py
1808 @@ -254,7 +254,7 @@ class _TLSMessageType:
1812 -if sys.platform == "win32":
1813 +if sys.platform == "win32" and sys.version.find("GCC") == -1:
1817 @@ -591,7 +591,7 @@ def _load_windows_store_certs(self, storename, purpose):
1821 - if sys.platform == "win32":
1822 + if sys.platform == "win32" and sys.version.find("GCC") == -1:
1826 diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
1828 --- a/Lib/sysconfig.py
1830 @@ -2,6 +2,7 @@
1838 @@ -47,13 +48,13 @@
1842 - 'stdlib': '{installed_base}/Lib',
1843 - 'platstdlib': '{base}/Lib',
1844 - 'purelib': '{base}/Lib/site-packages',
1845 - 'platlib': '{base}/Lib/site-packages',
1846 - 'include': '{installed_base}/Include',
1847 - 'platinclude': '{installed_base}/Include',
1848 - 'scripts': '{base}/Scripts',
1851 + 'purelib': '{base}/lib/python{py_version_short}/site-packages',
1852 + 'platlib': '{base}/lib/python{py_version_short}/site-packages',
1859 @@ -97,13 +98,18 @@
1863 +# GCC[mingw*] use posix build system
1867 # For the OS-native venv scheme, we essentially provide an alias:
1868 -if os.name == 'nt':
1879 @@ -118,7 +124,7 @@ def _getuserbase():
1883 - if os.name == "nt":
1888 @@ -134,20 +140,20 @@ def joinuser(*args):
1892 - 'stdlib': '{userbase}/Python{py_version_nodot_plat}',
1893 - 'platstdlib': '{userbase}/Python{py_version_nodot_plat}',
1894 - 'purelib': '{userbase}/Python{py_version_nodot_plat}/site-packages',
1895 - 'platlib': '{userbase}/Python{py_version_nodot_plat}/site-packages',
1896 - 'include': '{userbase}/Python{py_version_nodot_plat}/Include',
1897 - 'scripts': '{userbase}/Python{py_version_nodot_plat}/Scripts',
1900 + 'purelib': '{userbase}/lib/python{py_version_short_plat}/site-packages',
1901 + 'platlib': '{userbase}/lib/python{py_version_short_plat}/site-packages',
1907 - 'stdlib': '{userbase}/{platlibdir}/python{py_version_short}',
1908 - 'platstdlib': '{userbase}/{platlibdir}/python{py_version_short}',
1909 - 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
1910 - 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
1911 - 'include': '{userbase}/include/python{py_version_short}',
1914 + 'purelib': '{userbase}/lib/python{py_version_short_plat}/site-packages',
1915 + 'platlib': '{userbase}/lib/python{py_version_short_plat}/site-packages',
1920 @@ -277,7 +283,7 @@ def _expand_vars(scheme, vars):
1924 - if os.name == 'nt':
1929 @@ -435,6 +441,14 @@ def _parse_makefile(filename, vars=None, keep_unresolved=True):
1939 + done[k[:-4]]=v
1944 @@ -514,11 +528,30 @@ def _generate_posix_vars():
1958 + prefix = build_time_vars['BINDIR'][:-4]
1973 # Create file used for sys.path fixup -- see Modules/getpath.c
1975 @@ -541,7 +574,7 @@ def _init_non_posix(vars):
1979 - vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
1984 @@ -587,7 +620,7 @@ def parse_config_h(fp, vars=None):
1988 - if os.name == "nt":
1993 @@ -662,11 +695,15 @@ def get_config_vars(*args):
1998 + _CONFIG_VARS['py_version_short_plat'] = f'{_PY_VERSION_SHORT}-{get_platform()}'
2002 - if os.name == 'nt':
2006 - if os.name == 'posix':
2011 @@ -676,7 +713,7 @@ def get_config_vars(*args):
2015 - if os.name == 'posix':
2020 @@ -714,7 +751,7 @@ def get_config_var(name):
2024 -
2029 @@ -737,6 +774,22 @@ def get_platform():
2050 return 'win-amd64'
2052 diff --git a/Lib/test/__main__.py b/Lib/test/__main__.py
2054 --- a/Lib/test/__main__.py
2056 @@ -1,2 +1,10 @@
2067 diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
2069 --- a/Lib/test/test_bytes.py
2071 @@ -1105,7 +1105,7 @@ def test_from_format(self):
2075 - ptr_format = '0x%0{}X'.format(2 * sizeof_ptr)
2080 diff --git a/Lib/test/test_getpath.py b/Lib/test/test_getpath.py
2082 --- a/Lib/test/test_getpath.py
2084 @@ -838,6 +838,7 @@ def test_symlink_buildpath_macos(self):
2092 @@ -877,6 +878,7 @@ def __init__(self, *a, argv0=None, config=None, **kw):
2098 self["PYWINVER"] = "9.8-XY"
2100 @@ -912,6 +914,9 @@ def __missing__(self, key):
2110 @@ -1053,6 +1058,7 @@ def __init__(self, *a, argv0=None, config=None, **kw):
2118 @@ -1089,6 +1095,9 @@ def __missing__(self, key):
2128 diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
2130 --- a/Lib/test/test_httpservers.py
2132 @@ -442,10 +442,10 @@ def test_undecodable_filename(self):
2136 - self.assertRegex(response, f'listing for {self.base_url}/\?x=123'.encode('latin1'))
2140 - self.assertRegex(response, f'listing for {self.base_url}/\?x=\xef\xbf\xbd'.encode('latin1'…
2145 diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py
2147 --- a/Lib/test/test_importlib/test_windows.py
2149 @@ -24,6 +24,23 @@ def get_platform():
2150 'x64' : 'win-amd64',
2151 'arm' : 'win-arm32',
2173 diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
2175 --- a/Lib/test/test_sysconfig.py
2177 @@ -17,7 +17,7 @@
2181 - _expand_vars, _get_preferred_schemes, _main)
2186 @@ -180,7 +180,7 @@ def test_nt_venv_scheme(self):
2190 - if sys.platform == 'win32':
2195 @@ -371,6 +371,10 @@ def test_user_similar(self):
2202 + f'python{sysconfig.get_python_version()}-{get_platform()}')
2203 # bpo-44860: platlib of posix_user doesn't use sys.platlibdir,
2206 diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
2208 --- a/Lib/venv/__init__.py
2210 @@ -11,7 +11,7 @@
2214 -
2219 @@ -301,7 +301,7 @@ def setup_python(self, context):
2223 - if self.symlinks:
2228 @@ -325,6 +325,12 @@ def setup_python(self, context):
2241 @@ -349,6 +355,7 @@ def _call_new_python(self, context, *py_args, **kwargs):
2249 diff --git a/Lib/venv/scripts/common/activate b/Lib/venv/scripts/common/activate
2251 --- a/Lib/venv/scripts/common/activate
2253 @@ -38,7 +38,7 @@ deactivate () {
2257 -VIRTUAL_ENV="__VENV_DIR__"
2262 diff --git a/Makefile.pre.in b/Makefile.pre.in
2264 --- a/Makefile.pre.in
2266 @@ -39,6 +39,7 @@ CXX= @CXX@
2274 @@ -123,6 +124,7 @@ PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE
2276 # Strict or non-strict aliasing flags used to compile dtoa.c, see above
2281 # Machine-dependent subdirectories
2282 @@ -141,6 +143,12 @@ exec_prefix= @exec_prefix@
2286 +# Locations needed for semi-native fixup of sysconfig.
2295 @@ -158,10 +166,12 @@ BINLIBDEST= @BINLIBDEST@
2308 @@ -268,6 +278,8 @@ LIBRARY_DEPS= @LIBRARY_DEPS@
2317 @@ -284,6 +296,7 @@ LIBOBJS= @LIBOBJS@
2325 @@ -344,6 +357,7 @@ IO_OBJS= \
2333 @@ -390,7 +404,7 @@ PYTHON_OBJS= \
2337 - Python/frozenmain.o \
2342 @@ -402,6 +416,7 @@ PYTHON_OBJS= \
2350 @@ -584,8 +599,8 @@ LIBEXPAT_HEADERS= \
2354 -build_all: check-clean-src $(BUILDPYTHON) platform oldsharedmods sharedmods \
2355 - gdbhooks Programs/_testembed python-config
2356 +build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) platform oldsharedmods sharedmods \
2357 + gdbhooks Programs/_testembed python-config $(ABI3DLLLIBRARY) $(ABI3LDLIBRARY)
2358 build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config
2361 @@ -700,9 +715,30 @@ coverage-report: regen-token regen-frozen
2362 clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
2363 $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
2366 + $(WINDRES) $(RCFLAGS) -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_exe.rc $@
2369 + $(WINDRES) $(RCFLAGS) -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pythonw_exe.rc $@
2372 + $(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/P…
2375 + $(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(ABI3DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdi…
2378 + $(WINDRES) $(RCFLAGS) -DPY_ICON -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pylauncher.rc…
2381 + $(WINDRES) $(RCFLAGS) -DPYW_ICON -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pylauncher.r…
2384 + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -mwindows -o $@ Programs/python.o $(BLDLI…
2387 -$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS)
2388 - $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS)…
2390 + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(LINK_PYTHON_OBJ…
2393 …$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%…
2394 @@ -806,13 +842,17 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
2398 -$(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
2400 if test -n "$(DLLLIBRARY)"; then \
2401 $(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
2402 - $(LIBS) $(MODLIBS) $(SYSLIBS); \
2408 + $(LDSHARED) -DPYTHON_DLL_NAME=\"$(DLLLIBRARY)\" $(srcdir)/PC/python3dll.c -Wl,--out-implib=$(ABI3…
2411 # wasm32-emscripten browser build
2413 # --preload-file turns a relative asset path into an absolute path.
2414 @@ -974,7 +1014,7 @@ BOOTSTRAP_HEADERS = \
2418 - $(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ $(LIBRARY_OBJS_OMIT_FROZEN) \
2419 + $(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ -municode -mwindows $(LIBRARY_OBJS_OMIT_FROZEN) \
2423 @@ -1276,9 +1316,15 @@ Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
2424 -DSHLIB_EXT='"$(EXT_SUFFIX)"' \
2425 -o $@ $(srcdir)/Python/dynload_hpux.c
2428 + $(CC) -c $(PY_CORE_CFLAGS) \
2429 + -DPYD_PLATFORM_TAG='"$(PYD_PLATFORM_TAG)"' \
2430 + -o $@ $(srcdir)/Python/dynload_win.c
2433 $(CC) -c $(PY_CORE_CFLAGS) \
2434 -DABIFLAGS='"$(ABIFLAGS)"' \
2435 + -DVPATH='"$(VPATH)"' \
2437 -o $@ $(srcdir)/Python/sysmodule.c
2439 @@ -1496,6 +1542,7 @@ PYTHON_HEADERS= \
2447 @@ -1791,7 +1838,7 @@ $(DESTSHARED):
2451 - @for i in $(BINDIR) $(LIBDIR); \
2454 if test ! -d $(DESTDIR)$$i; then \
2456 @@ -1801,6 +1848,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
2458 if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
2464 @@ -1814,6 +1862,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
2465 if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
2466 if test -n "$(DLLLIBRARY)" ; then \
2472 @@ -1924,6 +1973,7 @@ LIBSUBDIRS= asyncio \
2480 @@ -2223,8 +2273,9 @@ libainstall: all python-config
2482 if test -d $(LIBRARY); then :; else \
2483 if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
2484 - if test "$(SHLIB_SUFFIX)" = .dll; then \
2485 - $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
2486 + if test "$(SHLIB_SUFFIX)" = .dll -o "$(SHLIB_SUFFIX)" = .pyd; then \
2492 @@ -2263,16 +2314,23 @@ libainstall: all python-config
2496 +ifeq ($(shell uname -o),Msys)
2505 + MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
2507 --prefix=$(prefix) \
2508 --install-scripts=$(BINDIR) \
2509 --install-platlib=$(DESTSHARED) \
2510 - --root=$(DESTDIR)/
2511 - -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py
2512 - -rm -r $(DESTDIR)$(DESTSHARED)/__pycache__
2513 + --root=$(DESTDIRFINAL)
2514 + -rm $(DESTDIRFINAL)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py
2515 + -rm -r $(DESTDIRFINAL)$(DESTSHARED)/__pycache__
2518 # framework-based Python. frameworkinstall installs everything, the
2519 @@ -2464,7 +2522,7 @@ clean: clean-retain-profile
2523 - -rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
2524 + -rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY)$(ABI3LDLIBRARY) $(ABI3DLLLIBRARY) \
2527 -rm -rf build platform
2528 diff --git a/Misc/NEWS.d/3.11.4.rst b/Misc/NEWS.d/3.11.4.rst
2531 --- /dev/null
2533 @@ -0,0 +1,785 @@
2534 +.. date: 2023-06-01-03-24-58
2535 +.. gh-issue: 103142
2537 +.. release date: 2023-06-06
2545 +.. date: 2023-05-02-17-56-32
2546 +.. gh-issue: 99889
2555 +.. date: 2023-05-01-15-03-25
2556 +.. gh-issue: 104049
2560 +Do not expose the local on-disk location in directory indexes produced by
2565 +.. date: 2023-03-07-20-59-17
2566 +.. gh-issue: 102153
2572 +response to CVE-2023-24329. Patch by Illia Volochii.
2576 +.. date: 2023-05-31-19-35-22
2577 +.. gh-issue: 105164
2586 +.. date: 2023-05-18-13-00-21
2587 +.. gh-issue: 104615
2596 +.. date: 2023-05-14-18-56-54
2597 +.. gh-issue: 104482
2606 +.. date: 2023-05-13-06-22-52
2607 +.. gh-issue: 102818
2619 +.. date: 2023-05-12-00-19-02
2620 +.. gh-issue: 104405
2629 +.. date: 2023-05-01-12-03-52
2630 +.. gh-issue: 104018
2634 +Disallow the "z" format specifier in %-format of bytes objects.
2638 +.. date: 2023-04-28-18-57-13
2639 +.. gh-issue: 103971
2648 +.. date: 2023-04-21-17-03-14
2649 +.. gh-issue: 102310
2657 +.. date: 2023-04-21-16-12-41
2658 +.. gh-issue: 103590
2662 +Do not wrap a single exception raised from a ``try-except*`` construct in an
2667 +.. date: 2023-04-14-22-35-23
2668 +.. gh-issue: 101517
2669 +.. nonce: 5EqM-S
2677 +.. date: 2023-04-08-17-13-07
2678 +.. gh-issue: 103242
2683 +OpenSSL APIs. Patch by Dong-hee Na.
2687 +.. date: 2023-04-01-00-46-31
2688 +.. gh-issue: 102700
2692 +Allow built-in modules to be submodules. This allows submodules to be
2697 +.. date: 2023-02-12-22-40-22
2698 +.. gh-issue: 101857
2707 +.. date: 2022-11-08-12-36-25
2708 +.. gh-issue: 99184
2717 +.. date: 2022-09-27-11-59-13
2718 +.. gh-issue: 96670
2728 +.. date: 2019-12-01-12-58-31
2737 +.. date: 2023-06-02-02-38-26
2738 +.. gh-issue: 105080
2747 +.. date: 2023-05-24-09-34-23
2748 +.. gh-issue: 104874
2757 +.. date: 2023-05-17-20-03-01
2758 +.. gh-issue: 104340
2770 +.. date: 2023-05-17-08-01-36
2771 +.. gh-issue: 104372
2781 +.. date: 2023-05-16-11-02-44
2782 +.. gh-issue: 75367
2790 +.. date: 2023-05-16-10-07-16
2791 +.. gh-issue: 104536
2801 +.. date: 2023-05-11-23-03-00
2802 +.. gh-issue: 104399
2813 +.. date: 2023-05-08-20-57-17
2814 +.. gh-issue: 104307
2823 +.. date: 2023-05-08-15-39-00
2824 +.. gh-issue: 87695
2833 +.. date: 2023-05-07-19-56-45
2834 +.. gh-issue: 104265
2845 +.. date: 2023-05-01-16-43-28
2846 +.. gh-issue: 104035
2850 +Do not ignore user-defined ``__getstate__`` and ``__setstate__`` methods for
2855 +.. date: 2023-04-29-18-23-16
2856 +.. gh-issue: 103987
2860 +In :mod:`mmap`, fix several bugs that could lead to access to memory-mapped
2865 +.. date: 2023-04-27-20-03-08
2866 +.. gh-issue: 103935
2875 +.. date: 2023-04-27-00-45-41
2876 +.. gh-issue: 100370
2881 +for 32-bit builds. Patch by Erlend E. Aasland.
2885 +.. date: 2023-04-26-09-54-25
2886 +.. gh-issue: 103848
2895 +.. date: 2023-04-26-09-38-47
2896 +.. gh-issue: 103872
2904 +.. date: 2023-04-25-19-58-13
2905 +.. gh-issue: 103861
2914 +.. date: 2023-04-24-00-34-23
2915 +.. gh-issue: 103685
2924 +.. date: 2023-04-22-22-14-09
2925 +.. gh-issue: 81403
2935 +.. date: 2023-04-16-18-29-04
2936 +.. gh-issue: 103578
2946 +.. date: 2023-04-15-12-19-14
2947 +.. gh-issue: 103556
2948 +.. nonce: TEf-2m
2951 +Now creating :class:`inspect.Signature` objects with positional-only
2952 +parameter with a default followed by a positional-or-keyword parameter
2957 +.. date: 2023-04-15-11-21-38
2958 +.. gh-issue: 103559
2966 +.. date: 2023-04-12-17-59-55
2967 +.. gh-issue: 103365
2975 +.. date: 2023-04-12-13-04-16
2976 +.. gh-issue: 103472
2986 +.. date: 2023-04-11-21-38-39
2987 +.. gh-issue: 103449
2988 +.. nonce: -nxmhb
2995 +.. date: 2023-04-06-17-28-36
2996 +.. gh-issue: 103256
3003 +built-in. This could happen when, for example, your OpenSSL does not include
3009 +.. date: 2023-04-05-01-28-53
3010 +.. gh-issue: 103225
3014 +Fix a bug in :mod:`pdb` when displaying line numbers of module-level source
3019 +.. date: 2023-04-04-12-43-38
3020 +.. gh-issue: 93910
3028 +.. date: 2023-04-03-23-44-34
3029 +.. gh-issue: 102978
3039 +.. date: 2023-04-02-23-05-22
3040 +.. gh-issue: 103204
3045 +preceded by '+', or '-', or with digit-separating '_' characters. The
3050 +.. date: 2023-03-23-15-24-38
3051 +.. gh-issue: 102953
3058 +directory. See :ref:`tarfile-extraction-filter` for details.
3062 +.. date: 2023-02-09-22-24-34
3063 +.. gh-issue: 101640
3072 +.. date: 2022-09-07-09-32-07
3073 +.. gh-issue: 96522
3081 +.. date: 2022-08-27-21-41-41
3082 +.. gh-issue: 87474
3083 +.. nonce: 9X-kxt
3090 +.. date: 2023-05-28-21-01-00
3091 +.. gh-issue: 89455
3101 +.. date: 2023-05-28-19-08-42
3102 +.. gh-issue: 89412
3111 +.. date: 2023-05-25-22-34-31
3112 +.. gh-issue: 104943
3120 +.. date: 2023-05-14-12-11-28
3121 +.. gh-issue: 67056
3130 +.. date: 2023-04-25-22-58-08
3131 +.. gh-issue: 48241
3140 +.. date: 2023-05-15-02-22-44
3141 +.. gh-issue: 104494
3150 +.. date: 2023-05-14-03-00-00
3151 +.. gh-issue: 104461
3156 +variable and ``-screen`` option for toplevels are not useful on Tk for Win32
3161 +.. date: 2023-04-08-00-50-23
3162 +.. gh-issue: 103329
3171 +.. date: 2023-02-11-22-36-10
3172 +.. gh-issue: 85984
3180 +.. date: 2022-11-06-18-42-38
3181 +.. gh-issue: 75729
3190 +.. date: 2023-06-06-09-08-10
3191 +.. gh-issue: 90005
3200 +.. date: 2023-05-04-10-56-14
3201 +.. gh-issue: 104106
3202 +.. nonce: -W9BJS
3205 +Add gcc fallback of mkfifoat/mknodat for macOS. Patch by Dong-hee Na.
3209 +.. date: 2023-02-11-05-31-05
3210 +.. gh-issue: 99069
3220 +.. date: 2023-05-31-16-14-31
3221 +.. gh-issue: 105146
3230 +.. date: 2023-05-18-22-46-03
3231 +.. gh-issue: 104623
3239 +.. date: 2023-03-24-11-25-28
3240 +.. gh-issue: 102997
3248 +.. date: 2023-03-18-21-38-00
3249 +.. gh-issue: 88013
3258 +.. date: 2023-05-30-23-30-46
3259 +.. gh-issue: 103142
3267 +.. date: 2023-05-18-22-31-49
3268 +.. gh-issue: 104623
3276 +.. date: 2023-03-24-11-20-47
3277 +.. gh-issue: 102997
3285 +.. date: 2023-05-23-17-19-49
3286 +.. gh-issue: 104719
3287 +.. nonce: rvYXH-
3295 +.. date: 2023-05-17-17-32-21
3296 +.. gh-issue: 104499
3304 +.. date: 2023-05-17-15-11-11
3305 +.. gh-issue: 104496
3306 +.. nonce: wjav-y
3313 +.. date: 2023-04-30-20-01-18
3314 +.. gh-issue: 88496
3319 diff --git a/Misc/config_mingw b/Misc/config_mingw
3322 --- /dev/null
3324 @@ -0,0 +1,15 @@
3325 +# configure defaults for mingw* hosts
3327 +# mingw functions to ignore
3330 +# mingw-w64 functions to ignore
3338 +# force detection of winsock2 functionality - require wxp or newer
3340 diff --git a/Misc/cross_mingw32 b/Misc/cross_mingw32
3343 --- /dev/null
3345 @@ -0,0 +1,11 @@
3346 +# configure defaults for mingw32 host if cross-build
3357 diff --git a/Misc/python-config.sh.in b/Misc/python-config.sh.in
3359 --- a/Misc/python-config.sh.in
3360 +++ b/Misc/python-config.sh.in
3361 @@ -1,32 +1,44 @@
3364 -# Keep this script in sync with python-config.in
3365 -
3368 …echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--h…
3369 - exit $1
3373 +# Really, python-config.py (and thus .sh) should be called directly, but
3374 +# sometimes software (e.g. GDB) calls python-config.sh as if it were the
3375 +# Python executable, passing python-config.py as the first argument.
3384 - exit_with_usage 1
3391 - RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
3392 - if which readlink >/dev/null 2>&1 ; then
3393 - if readlink -f "$RESULT" >/dev/null 2>&1; then
3394 - RESULT=$(readlink -f "$RESULT")
3395 - fi
3396 + local RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
3398 + RESULT=$(readlink -f "$RESULT")
3401 + # we keep all paths in Windows-land since MSYS2 can handle that
3402 + # while native tools can't handle paths in MSYS2-land.
3404 + RESULT=$(cd "$RESULT" && pwd -W)
3411 -# Use sed to fix paths from their built-to locations to their installed-to
3412 +# Use sed to fix paths from their built-to locations to their installed to
3416 @@ -41,13 +53,17 @@ LIBM="@LIBM@"
3425 LIBS_EMBED="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS"
3427 -LDLIBRARY="@LDLIBRARY@"
3435 @@ -61,7 +77,7 @@ for ARG in $*
3438 --help)
3439 - exit_with_usage 0
3442 --embed)
3444 @@ -69,7 +85,7 @@ do
3445 …--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--config…
3448 - exit_with_usage 1
3453 @@ -80,37 +96,37 @@ fi
3457 - case "$ARG" in
3459 --prefix)
3460 - echo "$prefix_real"
3461 + echo -ne "$prefix_real"
3463 --exec-prefix)
3464 - echo "$exec_prefix_real"
3465 + echo -ne "$exec_prefix_real "
3467 --includes)
3468 - echo "$INCDIR $PLATINCDIR"
3469 + echo -ne "$INCDIR $PLATINCDIR"
3471 --cflags)
3472 - echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
3473 + echo -ne "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
3475 --libs)
3476 - echo "$LIBS"
3477 + echo -ne "$LIBS"
3479 --ldflags)
3482 LIBPLUSED="-L$LIBPL"
3484 - echo "$LIBPLUSED -L$libdir $LIBS"
3485 + echo -ne "$LIBPLUSED -L$libdir $LIBS "
3487 --extension-suffix)
3488 - echo "$SO"
3489 + echo -ne "$SO "
3491 --abiflags)
3492 - echo "$ABIFLAGS"
3493 + echo -ne "$ABIFLAGS "
3495 --configdir)
3496 - echo "$LIBPL"
3497 + echo -ne "$LIBPL "
3501 diff --git a/Misc/python.pc.in b/Misc/python.pc.in
3503 --- a/Misc/python.pc.in
3505 @@ -9,5 +9,5 @@ Description: Build a C extension for Python
3509 -Libs:
3510 +Libs: -L${libdir} -lpython@VERSION@@ABIFLAGS@
3511 Cflags: -I${includedir}/python@VERSION@@ABIFLAGS@
3512 diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in
3514 --- a/Modules/Setup.bootstrap.in
3516 @@ -8,15 +8,15 @@
3520 -posix posixmodule.c
3521 -_signal signalmodule.c
3523 +_signal signalmodule.c -lws2_32
3530 -_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stri…
3535 @@ -33,3 +33,8 @@ _symtable symtablemodule.c
3540 +# build-in modules for windows platform:
3542 +@MODULE_MSVCRT_TRUE@msvcrt -DPy_BUILD_CORE ../PC/msvcrtmodule.c
3544 diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
3546 --- a/Modules/_ctypes/_ctypes.c
3548 @@ -3403,6 +3403,18 @@ static PPROC FindAddress(void *handle, const char *name, PyObject *type)
3557 + * - If a python module is build with gcc option --add-stdcall-alias
3560 + * - Distutil may use compiler to create def-file, to modify it as
3562 + * - Or may be just to search for function without underscore.
3567 @@ -3410,6 +3422,13 @@ static PPROC FindAddress(void *handle, const char *name, PyObject *type)
3581 diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c
3583 --- a/Modules/_gdbmmodule.c
3585 @@ -12,7 +12,7 @@
3589 -#if defined(WIN32) && !defined(__CYGWIN__)
3594 diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
3596 --- a/Modules/_io/fileio.c
3598 @@ -20,6 +20,7 @@
3606 @@ -1129,7 +1130,7 @@ _io_FileIO_isatty_impl(fileio *self)
3610 - res = isatty(self->fd);
3611 + res = isatty(self->fd) || is_cygpty(self->fd);
3615 diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
3617 --- a/Modules/_localemodule.c
3619 @@ -12,6 +12,13 @@ This software comes with no warranty. Use at your own risk.
3624 +/* The header libintl.h and library libintl may exist on mingw host.
3633 diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
3635 --- a/Modules/_multiprocessing/multiprocessing.c
3637 @@ -172,7 +172,7 @@ static PyMethodDef module_methods[] = {
3641 -#if !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__)
3646 diff --git a/Modules/_multiprocessing/multiprocessing.h b/Modules/_multiprocessing/multiprocessing.h
3648 --- a/Modules/_multiprocessing/multiprocessing.h
3650 @@ -21,7 +21,10 @@
3654 -# define HAVE_MP_SEMAPHORE
3662 diff --git a/Modules/_winapi.c b/Modules/_winapi.c
3664 --- a/Modules/_winapi.c
3666 @@ -41,7 +41,9 @@
3676 @@ -957,7 +959,7 @@ getattributelist(PyObject *obj, const char *name, AttributeList *attribute_list)
3680 - Py_ssize_t handle_list_size;
3685 diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c
3687 --- a/Modules/_xxsubinterpretersmodule.c
3689 @@ -1765,7 +1765,7 @@ PyDoc_STRVAR(channelid_doc,
3693 - PyVarObject_HEAD_INIT(&PyType_Type, 0)
3698 diff --git a/Modules/getpath.c b/Modules/getpath.c
3700 --- a/Modules/getpath.c
3702 @@ -54,6 +54,25 @@
3720 + r = PyUnicode_FromWideChar(_Py_normpath(buffer, len), -1);
3728 @@ -88,6 +107,12 @@ getpath_basename(PyObject *Py_UNUSED(self), PyObject *args)
3731 Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1);
3735 + pos = PyUnicode_FindChar(path, ALTSEP, 0, end, -1);
3741 @@ -104,6 +129,12 @@ getpath_dirname(PyObject *Py_UNUSED(self), PyObject *args)
3744 Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1);
3748 + pos = PyUnicode_FindChar(path, ALTSEP, 0, end, -1);
3754 @@ -513,6 +544,7 @@ getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args)
3762 @@ -884,6 +916,11 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
3774 @@ -910,6 +947,9 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
3775 !funcs_to_dict(dict, config->pathconfig_warnings) ||
3784 diff --git a/Modules/getpath.py b/Modules/getpath.py
3786 --- a/Modules/getpath.py
3788 @@ -30,6 +30,7 @@
3791 # os_name -- [in] one of 'nt', 'posix', 'darwin'
3792 +# is_mingw -- [in] True if targeting MinGW
3793 # PREFIX -- [in] sysconfig.get_config_var(...)
3794 # EXEC_PREFIX -- [in] sysconfig.get_config_var(...)
3795 # PYTHONPATH -- [in] sysconfig.get_config_var(...)
3796 @@ -51,6 +52,7 @@
3797 # ENV_PYTHONHOME -- [in] getenv(...)
3798 # ENV_PYTHONEXECUTABLE -- [in] getenv(...)
3799 # ENV___PYVENV_LAUNCHER__ -- [in] getenv(...)
3800 +# ENV_MSYSTEM -- [in] getenv(...)
3803 # config -- [in/out] dict of the PyConfig structure
3804 @@ -185,8 +187,27 @@
3810 -elif os_name == 'nt':
3817 + PLATSTDLIB_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}/lib-dynload'
3833 @@ -199,6 +220,7 @@
3841 @@ -211,6 +233,8 @@ def search_up(prefix, *landmarks, test=isfile):
3850 @@ -263,10 +287,10 @@ def search_up(prefix, *landmarks, test=isfile):
3854 -if not executable and SEP in program_name:
3859 -
3863 @@ -497,15 +521,15 @@ def search_up(prefix, *landmarks, test=isfile):
3867 - if os_name == 'nt':
3875 - if os_name == 'nt':
3876 - # QUIRK: No searching for more landmarks on Windows
3882 @@ -552,6 +576,9 @@ def search_up(prefix, *landmarks, test=isfile):
3887 + # QUIRK: On Windows, mingw Python DLLs are in the bin directory
3892 @@ -597,7 +624,7 @@ def search_up(prefix, *landmarks, test=isfile):
3896 - if os_name == 'nt':
3899 # gh-100320: Our PYDs are assumed to be relative to the Lib directory
3901 @@ -607,7 +634,7 @@ def search_up(prefix, *landmarks, test=isfile):
3905 - if os_name == 'nt':
3910 @@ -645,7 +672,7 @@ def search_up(prefix, *landmarks, test=isfile):
3914 - config['module_search_paths'] = py_setpath.split(DELIM)
3919 @@ -660,7 +687,7 @@ def search_up(prefix, *landmarks, test=isfile):
3923 - if os_name == 'nt':
3928 @@ -673,7 +700,7 @@ def search_up(prefix, *landmarks, test=isfile):
3932 - if os_name == 'nt' and use_environment and winreg:
3937 @@ -714,7 +741,7 @@ def search_up(prefix, *landmarks, test=isfile):
3941 - if os_name == 'nt':
3946 @@ -732,7 +759,7 @@ def search_up(prefix, *landmarks, test=isfile):
3950 - config['module_search_paths'] = pythonpath
3955 @@ -742,8 +769,8 @@ def search_up(prefix, *landmarks, test=isfile):
3957 # QUIRK: Non-Windows replaces prefix/exec_prefix with defaults when running
3959 -if os_name != 'nt' and build_prefix:
3960 - prefix = config.get('prefix') or PREFIX
3966 @@ -767,23 +794,23 @@ def search_up(prefix, *landmarks, test=isfile):
3970 - config['module_search_paths'] = pythonpath
3978 -config['program_name'] = program_name
3979 -config['home'] = home
3980 -config['executable'] = executable
3981 -config['base_executable'] = base_executable
3982 -config['prefix'] = prefix
3983 -config['exec_prefix'] = exec_prefix
3984 -config['base_prefix'] = base_prefix or prefix
3985 -config['base_exec_prefix'] = base_exec_prefix or exec_prefix
3995 -config['platlibdir'] = platlibdir
3998 -config['stdlib_dir'] = stdlib_dir or ''
3999 -config['platstdlib_dir'] = platstdlib_dir or ''
4002 diff --git a/Modules/main.c b/Modules/main.c
4004 --- a/Modules/main.c
4006 @@ -7,6 +7,7 @@
4014 @@ -92,7 +93,7 @@ static inline int config_run_code(const PyConfig *config)
4018 - return (isatty(fileno(stdin)) || config->interactive);
4019 + return (isatty(fileno(stdin)) || config->interactive || is_cygpty(fileno(stdin)));
4023 diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
4025 --- a/Modules/posixmodule.c
4027 @@ -50,6 +50,7 @@
4035 @@ -350,6 +351,32 @@ corresponding Unix manual entries for more information on calls.");
4040 +/* getlogin is detected by configure on mingw-w64 */
4042 +/* opendir is detected by configure on mingw-w64, and for some reason
4045 +un-defining, this, os.listdir will use the one which uses native
4048 +/*# define HAVE_GETCWD 1 - detected by configure*/
4054 +/*# define HAVE_EXECV 1 - detected by configure*/
4068 @@ -428,7 +455,7 @@ extern char *ctermid_r(char *);
4072 -#ifdef _MSC_VER
4077 @@ -439,7 +466,7 @@ extern char *ctermid_r(char *);
4081 -#endif /* _MSC_VER */
4086 @@ -1593,9 +1620,9 @@ win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag)
4090 -#elif !defined(_MSC_VER) && (!defined(__WATCOMC__) || defined(__QNX__) || defined(__VXWORKS__))
4093 -#endif /* !_MSC_VER */
4098 @@ -3815,6 +3842,7 @@ posix_getcwd(int use_bytes)
4106 @@ -4419,6 +4447,7 @@ os__getfinalpathname_impl(PyObject *module, path_t *path)
4112 if (result && path->narrow) {
4114 @@ -5467,7 +5496,7 @@ os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns,
4118 - HANDLE hFile;
4123 @@ -10194,7 +10223,7 @@ os_isatty_impl(PyObject *module, int fd)
4127 - return_value = isatty(fd);
4132 @@ -14682,7 +14711,7 @@ os__add_dll_directory_impl(PyObject *module, path_t *path)
4136 - !(AddDllDirectory = (PAddDllDirectory)GetProcAddress(
4139 !(cookie = (*AddDllDirectory)(path->wide))) {
4141 @@ -14732,7 +14761,7 @@ os__remove_dll_directory_impl(PyObject *module, PyObject *cookie)
4145 - !(RemoveDllDirectory = (PRemoveDllDirectory)GetProcAddress(
4150 diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
4152 --- a/Modules/selectmodule.c
4154 @@ -146,9 +146,9 @@ seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
4156 if (v == -1) goto finally;
4158 -#if defined(_MSC_VER)
4161 -#else /* !_MSC_VER */
4166 @@ -156,7 +156,7 @@ seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
4170 -#endif /* _MSC_VER */
4175 diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
4177 --- a/Modules/socketmodule.c
4179 @@ -274,7 +274,7 @@ shutdown(how) -- shut down traffic in one or both directions\n\
4183 -#ifdef MS_WINDOWS
4188 @@ -305,7 +305,7 @@ shutdown(how) -- shut down traffic in one or both directions\n\
4192 -#endif /* MS_WINDOWS */
4197 @@ -404,6 +404,10 @@ remove_unusable_flags(PyObject *m)
4208 diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h
4210 --- a/Modules/socketmodule.h
4212 @@ -68,8 +68,10 @@ struct SOCKADDR_BTH_REDEF {
4223 diff --git a/Modules/timemodule.c b/Modules/timemodule.c
4225 --- a/Modules/timemodule.c
4227 @@ -783,7 +783,7 @@ time_strftime(PyObject *module, PyObject *args)
4231 -#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) || defined(__VXWORKS…
4236 diff --git a/Objects/fileobject.c b/Objects/fileobject.c
4238 --- a/Objects/fileobject.c
4240 @@ -3,6 +3,7 @@
4248 @@ -387,7 +388,7 @@ stdprinter_isatty(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
4252 - res = isatty(self->fd);
4253 + res = isatty(self->fd) || is_cygpty(self->fd);
4257 diff --git a/PC/_testconsole.c b/PC/_testconsole.c
4259 --- a/PC/_testconsole.c
4261 @@ -10,7 +10,7 @@
4265 -#include "..\modules\_io\_iomodule.h"
4270 @@ -108,7 +108,7 @@ _testconsole_read_output_impl(PyObject *module, PyObject *file)
4274 -#include "clinic\_testconsole.c.h"
4279 diff --git a/PC/launcher.c b/PC/launcher.c
4281 --- a/PC/launcher.c
4283 @@ -155,12 +155,12 @@ static wchar_t * get_env(wchar_t * key)
4287 -#define PYTHON_EXECUTABLE L"pythonw.exe"
4293 -#define PYTHON_EXECUTABLE L"python.exe"
4298 @@ -925,7 +925,7 @@ static COMMAND path_command;
4302 - size_t varsize;
4307 @@ -942,18 +942,23 @@ static COMMAND * find_on_path(wchar_t * name)
4310 /* No extension - search using registered extensions. */
4311 - rc = _wdupenv_s(&pathext, &varsize, L"PATHEXT");
4312 - if (rc == 0) {
4313 - extension = wcstok_s(pathext, L";", &context);
4314 - while (extension) {
4315 - len = SearchPathW(NULL, name, extension, MSGSIZE, path_command.value, NULL);
4316 - if (len) {
4317 - result = &path_command;
4318 - break;
4322 + /* No extension - search using registered extensions. */
4334 - extension = wcstok_s(NULL, L";", &context);
4337 - free(pathext);
4341 @@ -1913,7 +1918,7 @@ process(int argc, wchar_t ** argv)
4345 - cb = fread_s(buffer, sizeof(buffer), sizeof(buffer[0]),
4350 diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
4352 --- a/PC/msvcrtmodule.c
4354 @@ -22,7 +22,9 @@
4364 diff --git a/PC/pylauncher.rc b/PC/pylauncher.rc
4366 --- a/PC/pylauncher.rc
4368 @@ -12,17 +12,17 @@
4372 -1 ICON DISCARDABLE "icons\python.ico"
4375 -1 ICON DISCARDABLE "icons\pythonw.ico"
4378 -1 ICON DISCARDABLE "icons\launcher.ico"
4379 -2 ICON DISCARDABLE "icons\py.ico"
4380 -3 ICON DISCARDABLE "icons\pyc.ico"
4381 -4 ICON DISCARDABLE "icons\pyd.ico"
4382 -5 ICON DISCARDABLE "icons\python.ico"
4383 -6 ICON DISCARDABLE "icons\pythonw.ico"
4384 -7 ICON DISCARDABLE "icons\setup.ico"
4394 1 USAGE "launcher-usage.txt"
4395 @@ -64,4 +64,4 @@ BEGIN
4399 -END
4402 diff --git a/PC/python3dll.c b/PC/python3dll.c
4404 --- a/PC/python3dll.c
4406 @@ -3,6 +3,7 @@
4414 @@ -13,6 +14,13 @@
4421 + asm(".section .drectve\n\t.ascii \" -export:" #name "=\\\"" PYTHON_DLL_NAME "." #name "\\\" \"…
4423 + asm(".section .drectve\n\t.ascii \" -export:" #name "=\\\"" PYTHON_DLL_NAME "." #name "\\\",DA…
4428 diff --git a/PC/python_exe.rc b/PC/python_exe.rc
4430 --- a/PC/python_exe.rc
4432 @@ -12,7 +12,7 @@
4436 -1 ICON DISCARDABLE "icons\python.ico"
4441 diff --git a/PC/pythonw_exe.rc b/PC/pythonw_exe.rc
4443 --- a/PC/pythonw_exe.rc
4445 @@ -12,7 +12,7 @@
4449 -1 ICON DISCARDABLE "icons\pythonw.ico"
4454 diff --git a/PC/winreg.c b/PC/winreg.c
4456 --- a/PC/winreg.c
4458 @@ -18,6 +18,25 @@
4484 @@ -806,6 +825,7 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
4492 diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
4494 --- a/Python/bltinmodule.c
4496 @@ -1,6 +1,7 @@
4497 /* Built-in functions */
4504 @@ -2135,7 +2136,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
4508 - tty = fd == fileno(stdin) && isatty(fd);
4513 @@ -2148,7 +2149,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
4517 - tty = fd == fileno(stdout) && isatty(fd);
4522 diff --git a/Python/dynamic_annotations.c b/Python/dynamic_annotations.c
4524 --- a/Python/dynamic_annotations.c
4526 @@ -27,7 +27,7 @@
4530 -#ifdef _MSC_VER
4535 diff --git a/Python/dynload_win.c b/Python/dynload_win.c
4537 --- a/Python/dynload_win.c
4539 @@ -4,6 +4,7 @@
4547 @@ -170,8 +171,7 @@ static char *GetPythonImport (HINSTANCE hModule)
4551 -static int
4552 -_Py_CheckPython3(void)
4557 @@ -224,7 +224,21 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
4561 - _Py_CheckPython3();
4580 @@ -248,9 +262,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
4584 - hDLL = LoadLibraryExW(wpathname, NULL,
4585 - LOAD_LIBRARY_SEARCH_DEFAULT_DIRS |
4586 - LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
4591 diff --git a/Python/fileutils.c b/Python/fileutils.c
4593 --- a/Python/fileutils.c
4595 @@ -1,4 +1,5 @@
4601 @@ -71,7 +72,7 @@ _Py_device_encoding(int fd)
4605 - valid = isatty(fd);
4610 @@ -1809,12 +1810,12 @@ _Py_write_impl(int fd, const void *buf, size_t count, int gil_held)
4614 - if (isatty(fd)) {
4620 - if (isatty(fd)) {
4625 @@ -2004,19 +2005,31 @@ int
4638 - HRESULT hr = PathCchSkipRoot(path, &tail);
4639 - if (FAILED(hr) || path == tail) {
4645 - if (tail == &path[1] && (path[0] == SEP || path[0] == ALTSEP)) {
4651 - if (tail == &path[2] && path[1] == L':') {
4653 // Exclude drive-relative paths (e.g. C:filename.ext)
4661 @@ -2049,7 +2062,11 @@ _Py_abspath(const wchar_t *path, wchar_t **abspath_p)
4665 - return _PyOS_getfullpathname(path, abspath_p);
4667 + return -1;
4669 + *abspath_p = _Py_normpath(*abspath_p, -1);
4673 cwd[Py_ARRAY_LENGTH(cwd) - 1] = 0;
4674 @@ -2093,6 +2110,8 @@ join_relfile(wchar_t *buffer, size_t bufsize,
4682 return -1;
4683 @@ -2195,11 +2214,16 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize)
4685 wchar_t lastC = L'\0'; // the last ljusted character, p2[-1] in most cases
4694 -#define IS_SEP(x) (*(x) == SEP || *(x) == ALTSEP)
4697 -#define IS_SEP(x) (*(x) == SEP)
4702 @@ -2210,7 +2234,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize)
4706 - lastC = SEP;
4711 @@ -2224,13 +2248,13 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize)
4715 - *p2++ = SEP;
4716 - *p2++ = SEP;
4722 --sepCount;
4723 - *p2++ = lastC = SEP;
4728 @@ -2243,7 +2267,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize)
4731 minP2 = p2 - 1; // Absolute path has SEP at minP2
4732 - lastC = SEP;
4737 @@ -2251,18 +2275,18 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize)
4741 - if (c == ALTSEP) {
4742 - c = SEP;
4747 - if (lastC == SEP) {
4754 - while (p3 != minP2 && *--p3 == SEP) { }
4755 - while (p3 != minP2 && *(p3 - 1) != SEP) { --p3; }
4756 + while (p3 != minP2 && *--p3 == sep) { }
4757 + while (p3 != minP2 && *(p3 - 1) != sep) { --p3; }
4761 @@ -2271,7 +2295,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize)
4765 - } else if (p3[0] == SEP) {
4770 @@ -2282,7 +2306,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize)
4774 - } else if (c == SEP) {
4779 @@ -2292,7 +2316,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize)
4783 - while (--p2 != minP2 && *p2 == SEP) {
4784 + while (--p2 != minP2 && *p2 == sep) {
4788 diff --git a/Python/frozenmain.c b/Python/frozenmain.c
4790 --- a/Python/frozenmain.c
4792 @@ -3,6 +3,7 @@
4800 @@ -71,7 +72,7 @@ Py_FrozenMain(int argc, char **argv)
4804 - if (inspect && isatty((int)fileno(stdin))) {
4809 diff --git a/Python/getcompiler.c b/Python/getcompiler.c
4811 --- a/Python/getcompiler.c
4813 @@ -7,10 +7,40 @@
4817 -#if defined(__clang__)
4821 -#define COMPILER "[GCC " __VERSION__ "]"
4856 diff --git a/Python/initconfig.c b/Python/initconfig.c
4858 --- a/Python/initconfig.c
4860 @@ -176,7 +176,7 @@ static const char usage_envvars[] =
4861 "PYTHONVERBOSE : trace import statements (-v)\n"
4862 "PYTHONWARNINGS=arg : warning control (-W arg)\n";
4864 -#if defined(MS_WINDOWS)
4869 diff --git a/Python/iscygpty.c b/Python/iscygpty.c
4872 --- /dev/null
4874 @@ -0,0 +1,185 @@
4876 + * iscygpty.c -- part of ptycheck
4877 + * https://github.com/k-takata/ptycheck
4879 + * Copyright (c) 2015-2017 K.Takata
4919 + * http://www.microsoft.com/en-us/download/details.aspx?id=22599
4981 + (wcsncmp((s), (prefix), sizeof(prefix) / sizeof(WCHAR) - 1) == 0)
4990 + int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * (MAX_PATH - 1);
5009 + * '\{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master' */
5011 + nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = L'\0';
5012 + p = nameinfo->FileName;
5013 + if (is_wprefix(p, L"\\cygwin-")) { /* Cygwin */
5015 + } else if (is_wprefix(p, L"\\msys-")) { /* MSYS and MSYS2 */
5021 + while (*p && isxdigit(*p)) /* Skip 16-digit hexadecimal. */
5023 + if (is_wprefix(p, L"-pty")) {
5032 + if (is_wprefix(p, L"-from-master")) {
5034 + } else if (is_wprefix(p, L"-to-master")) {
5060 diff --git a/Python/pathconfig.c b/Python/pathconfig.c
5062 --- a/Python/pathconfig.c
5064 @@ -2,7 +2,7 @@
5068 -#include "osdefs.h" // DELIM
5073 @@ -18,6 +18,158 @@
5111 + /* https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx
5165 + /* https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx
5232 @@ -317,6 +469,7 @@ _Py_SetProgramFullPath(const wchar_t *program_full_path)
5240 @@ -509,7 +662,7 @@ _PyPathConfig_ComputeSysPath0(const PyWideStringList *argv, PyObject **path0_p)
5244 - PyObject *path0_obj = PyUnicode_FromWideChar(path0, n);
5245 + PyObject *path0_obj = PyUnicode_FromWideChar(_Py_normpath(path0, -1), n);
5247 return -1;
5249 diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
5251 --- a/Python/pylifecycle.c
5253 @@ -31,6 +31,7 @@
5261 @@ -2954,7 +2955,7 @@ Py_Exit(int sts)
5265 - if (isatty((int)fileno(fp)))
5270 @@ -2967,7 +2968,7 @@ Py_FdIsInteractive(FILE *fp, const char *filename)
5274 - if (isatty((int)fileno(fp))) {
5279 diff --git a/Python/sysmodule.c b/Python/sysmodule.c
5281 --- a/Python/sysmodule.c
5283 @@ -43,7 +43,7 @@ Data members:
5287 -#ifdef MS_COREDLL
5292 @@ -2923,7 +2923,7 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
5296 -#ifdef MS_COREDLL
5301 diff --git a/Python/thread_nt.h b/Python/thread_nt.h
5303 --- a/Python/thread_nt.h
5305 @@ -360,8 +360,9 @@ PyThread_release_lock(PyThread_type_lock aLock)
5309 - if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock)))
5316 diff --git a/Python/traceback.c b/Python/traceback.c
5318 --- a/Python/traceback.c
5320 @@ -323,7 +323,7 @@ _Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject *
5324 - tail = strrchr(filepath, SEP);
5329 diff --git a/configure.ac b/configure.ac
5331 --- a/configure.ac
5333 @@ -202,9 +202,11 @@ AC_SUBST([FREEZE_MODULE])
5337 +NATIVE_PYTHON_SEARCH_PATH_MINGW=`echo $host | grep -Eq 'mingw*' && echo "$MINGW_PREFIX/bin" || ech…
5340 - [python3])
5346 @@ -545,6 +547,9 @@ then
5347 *-*-cygwin*)
5350 + *-*-mingw*)
5351 + ac_sys_system=MINGW
5353 *-*-vxworks*)
5356 @@ -580,6 +585,7 @@ then
5360 + mingw*) MACHDEP="win32";;
5364 @@ -605,6 +611,9 @@ if test "$cross_compiling" = yes; then
5366 wasm32-*-* | wasm64-*-*)
5369 + *-*-mingw*)
5374 @@ -612,6 +621,14 @@ if test "$cross_compiling" = yes; then
5377 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
5380 + mingw*)
5382 + # we will use 'mingw' (in setup.py and etc.)
5383 + _PYTHON_HOST_PLATFORM=mingw
5389 @@ -723,6 +740,65 @@ then
5393 +# On 'semi-native' build systems (MSYS*/Cygwin targeting MinGW-w64)
5403 +# prefixes matching the non-b2h versions with the b2h equivalents.
5406 +# - in the 'semi-native' scenario only that is.)
5411 + mingw*)
5413 + mingw*) $1=$(cd $$2 && pwd -W) ;;
5419 + mingw*) $1=$(cygpath -w -m $$2) ;;
5447 + *-*-mingw*) INITSYS=nt;;
5452 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
5455 @@ -1163,6 +1239,28 @@ AC_CACHE_CHECK([for -Wl,--no-as-needed], [ac_cv_wl_no_as_needed], [
5462 + *-*-mingw*) py_config=mingw ;;
5464 +if test -n "$py_config" ; then
5469 +# initialize defaults for cross-builds
5475 + if test -f "$srcdir/Misc/cross_$py_config" ; then
5484 @@ -1275,6 +1373,7 @@ AC_ARG_WITH([suffix],
5488 + [MINGW*], [EXEEXT=.exe],
5492 @@ -1298,6 +1397,10 @@ else
5497 + [MINGW], [BUILDEXEEXT=".exe"]
5503 @@ -1475,6 +1578,11 @@ if test $enable_shared = "yes"; then
5507 + MINGW*)
5510 + BLDLIBRARY='-L. -lpython$(LDVERSION)'
5514 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
5515 @@ -1525,6 +1633,9 @@ else # shared is disabled
5519 + MINGW*)
5525 @@ -1618,6 +1729,10 @@ AC_SUBST(LINK_PYTHON_OBJS)
5535 if test -z "$ARFLAGS"
5536 @@ -2498,6 +2613,53 @@ then
5541 +dnl - GCC 4.4+ for mingw* require and use posix threads(pthreads-w32)
5542 +dnl - Host may contain installed pthreads-w32.
5543 +dnl - On windows platform only NT-thread model is supported.
5544 +dnl To avoid miss detection scipt first will check for NT-thread model
5548 +dnl If NT-thread model is enabled script skips some checks that
5553 +AC_MSG_CHECKING([for --with-nt-threads])
5554 +AC_ARG_WITH(nt-threads,
5555 + AS_HELP_STRING([--with-nt-threads], [build with windows threads (default is system-dep…
5564 + *-*-mingw*) with_nt_threads=yes;;
5571 +AC_MSG_CHECKING([whether linking with nt-threads work])
5576 + [AC_MSG_ERROR([failed to link with nt-threads])])
5590 @@ -2609,6 +2771,8 @@ int main(void){
5599 @@ -2629,6 +2793,10 @@ elif test "$ac_cv_pthread" = "yes"
5601 CXX="$CXX -pthread"
5610 @@ -2663,11 +2831,11 @@ AC_DEFINE(STDC_HEADERS, 1, [Define to 1 if you have the ANSI C header files…
5614 - alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h…
5618 - linux/tipc.h linux/wait.h netdb.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty…
5619 - sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \
5625 @@ -2675,9 +2843,24 @@ AC_CHECK_HEADERS([ \
5631 + *-*-mingw*) ;;
5647 # bluetooth/bluetooth.h has been known to not compile with -std=c99.
5650 @@ -2852,6 +3035,10 @@ dnl LFS does not work with Emscripten 3.1
5654 +dnl Activate on windows platforms (32&64-bit) where off_t(4) < fpos_t(8)
5656 + [MINGW], [have_largefile_support="yes"]
5661 @@ -2882,6 +3069,10 @@ elif test "$ac_cv_pthread" = "yes"
5662 then CC="$CC -pthread"
5666 + dnl skip check for pthread_t if NT-thread model is enabled
5672 @@ -2913,7 +3104,7 @@ AS_VAR_IF([ac_cv_pthread_key_t_is_arithmetic_type], [yes], [
5676 -
5681 @@ -3089,6 +3280,9 @@ if test -z "$SHLIB_SUFFIX"; then
5686 + mingw*) SHLIB_SUFFIX=.pyd;;
5691 @@ -3218,6 +3412,10 @@ then
5693 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
5694 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
5695 + MINGW*)
5696 + LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
5697 + LDCXXSHARED='$(CXX) -shared -Wl,--enable-auto-image-base'
5702 @@ -3341,6 +3539,11 @@ then
5704 LINKFORSHARED='-Wl,-export-dynamic';;
5707 + *-*-mingw*)
5708 + # for https://bugs.python.org/issue40458 on MINGW
5709 + LINKFORSHARED="-Wl,--stack,2000000";;
5714 @@ -3385,7 +3588,12 @@ AC_MSG_RESULT($SHLIBS)
5718 -AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
5721 + *-*-mingw*) ;;
5725 AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
5728 @@ -3448,16 +3656,30 @@ AS_VAR_IF([have_uuid], [missing], [
5733 + dnl do not search for sem_init if NT-thread model is enabled
5744 + *-*-mingw*)
5753 LIBS="-lintl $LIBS"])
5759 @@ -3645,7 +3867,7 @@ else
5762 if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
5763 - LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//…
5764 + LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ .*$/…
5768 @@ -3780,6 +4002,12 @@ AS_CASE([$ac_sys_system],
5772 +dnl On MINGW, you need to link against ws2_32 and iphlpapi for sockets to work
5774 + [MINGW], [SOCKET_LIBS="-lws2_32 -liphlpapi"],
5779 PY_CHECK_EMSCRIPTEN_PORT([LIBSQLITE3], [-sUSE_SQLITE3])
5781 @@ -4042,6 +4270,18 @@ AS_VAR_IF([with_dbmliborder], [error], [
5786 + *-*-mingw*)
5787 + CFLAGS_NODIST="$CFLAGS_NODIST -D_WIN32_WINNT=0x0602";;
5794 + *-*-mingw*) USE_WIN32_MODULE=;;
5800 @@ -4076,6 +4316,11 @@ then
5801 CXX="$CXX -pthread"
5810 if test ! -z "$withval" -a -d "$withval"
5811 then LDFLAGS="$LDFLAGS -L$withval"
5812 @@ -4450,11 +4695,14 @@ AC_MSG_RESULT($with_freelists)
5813 AC_MSG_CHECKING(for --with-c-locale-coercion)
5814 AC_ARG_WITH(c-locale-coercion,
5815 AS_HELP_STRING([--with-c-locale-coercion],
5816 - [enable C locale coercion to a UTF-8 based locale (default is yes)]))
5817 + [enable C locale coercion to a UTF-8 based locale (default is yes on Unix, no on Win…
5819 if test -z "$with_c_locale_coercion"
5821 - with_c_locale_coercion="yes"
5823 + *-*-mingw*) with_c_locale_coercion="no";;
5829 @@ -4555,12 +4803,36 @@ then
5834 + *-*-mingw*)
5837 + CFLAGS_NODIST="$CFLAGS_NODIST -DPY3_DLLNAME='L\"$DLLLIBRARY\"'"
5840 + CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"${VERSION}-32\"'"
5843 + CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"${VERSION}-arm32\"'"
5846 + CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"${VERSION}-arm64\"'"
5849 + CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"$VERSION\"'"
5865 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
5866 @@ -4580,13 +4852,22 @@ else
5871 + dnl GCC(mingw) 4.4+ require and use posix threads(pthreads-w32)
5872 + dnl and host may contain installed pthreads-w32.
5873 + dnl Skip checks for some functions declared in pthreads-w32 if
5874 + dnl NT-thread model is enabled.
5885 - getgrnam_r getgrouplist getgroups gethostname getitimer getloadavg getlogin \
5890 @@ -4599,7 +4880,7 @@ AC_CHECK_FUNCS([ \
5894 - setresuid setreuid setsid setuid setvbuf shutdown sigaction sigaltstack \
5899 @@ -4829,7 +5110,13 @@ PKG_CHECK_MODULES([LIBLZMA], [liblzma], [have_liblzma=yes], [
5903 -AC_DEFUN([PY_CHECK_NETDB_FUNC], [PY_CHECK_FUNC([$1], [#include <netdb.h>])])
5914 @@ -4838,13 +5125,19 @@ PY_CHECK_NETDB_FUNC([getservbyport])
5934 @@ -4945,6 +5238,9 @@ WITH_SAVE_ENV([
5939 + *-*-mingw*) ;;
5943 LIBS="$LIBS -lrt"
5944 @@ -4965,6 +5261,8 @@ AC_CHECK_FUNCS(clock_settime, [], [
5953 @@ -5163,18 +5461,33 @@ if test $ac_cv_header_time_altzone = yes; then
5959 -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
5970 - AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
5976 -# include <sys/types.h>
5977 -# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
5991 @@ -5508,6 +5821,10 @@ dnl actually works. For FreeBSD versions <= 7.2,
5996 + dnl skip posix semaphores test if NT-thread model is enabled
6002 @@ -5541,6 +5858,14 @@ AS_VAR_IF([ac_cv_posix_semaphores_enabled], [no], [
6007 + dnl Skip test if NT-thread model is enabled.
6008 + dnl NOTE the test case below fail for pthreads-w32 as:
6009 + dnl - SEM_FAILED is not defined;
6010 + dnl - sem_open is a stub;
6011 + dnl - sem_getvalue work(!).
6017 @@ -5577,7 +5902,10 @@ AS_VAR_IF([ac_cv_broken_sem_getvalue], [yes], [
6021 -AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEE…
6023 + *-*-mingw*) ;;
6029 @@ -5664,6 +5992,71 @@ esac
6034 +# Special case of PYD_PLATFORM_TAG with python build with mingw.
6039 +# gcc + x86_64 + msvcrt = cp{version number}-x86_64
6040 +# gcc + i686 + msvcrt = cp{version number}-i686
6041 +# gcc + x86_64 + ucrt = cp{version number}-x86_64-ucrt
6042 +# clang + x86_64 + ucrt = cp{version number}-x86_64-clang
6043 +# clang + i686 + ucrt = cp{version number}-i686-clang
6047 + *-*-mingw*)
6061 + mingw*)
6064 + i686-*-mingw*)
6065 + if test -n "${cc_is_clang}"; then
6076 + x86_64-*-mingw*)
6077 + if test -n "${cc_is_clang}"; then
6088 + aarch64-*-mingw*)
6091 + armv7-*-mingw*)
6101 @@ -5696,7 +6089,12 @@ if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then
6105 -EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX}
6106 +VERSION_NO_DOTS=$(echo $LDVERSION | tr -d .)
6107 +if test -n "${PYD_PLATFORM_TAG}"; then
6108 + EXT_SUFFIX=".cp${VERSION_NO_DOTS}-${PYD_PLATFORM_TAG}${SHLIB_SUFFIX}"
6115 @@ -5704,7 +6102,7 @@ AC_MSG_RESULT($LDVERSION)
6119 -if test -n "$ANDROID_API_LEVEL" -o "$MACHDEP" = "cygwin"; then
6120 +if test -n "$ANDROID_API_LEVEL" -o "$MACHDEP" = "cygwin" -o "$MACHDEP" = "win32"; then
6121 LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
6124 @@ -6073,11 +6471,16 @@ then
6128 +if test -n "$PKG_CONFIG"; then
6129 + NCURSESW_INCLUDEDIR="`"$PKG_CONFIG" ncursesw --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ …
6137 -if test "$cross_compiling" = no; then
6138 - CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
6139 -fi
6140 +CPPFLAGS="$CPPFLAGS -I$NCURSESW_INCLUDEDIR"
6144 @@ -6243,7 +6646,10 @@ fi
6148 - [Define to `int' if <sys/socket.h> does not define.]),[
6156 @@ -6333,6 +6739,27 @@ do
6161 + *-*-mingw*)
6166 + dnl (-I. at end is workaround for setup.py logic)
6167 + CPPFLAGS="-I\$(srcdir)/PC $CPPFLAGS -I."
6175 + *-*-mingw*)
6176 + dnl 'PC/frozen_dllmain.c' - not yet
6184 @@ -6354,6 +6781,10 @@ SRCDIRS="\
6189 + *-*-mingw*) SRCDIRS="$SRCDIRS PC";;
6194 if test ! -d $dir; then
6195 @@ -6362,6 +6793,38 @@ for dir in $SRCDIRS; do
6199 +# For mingw build need additional library for linking
6201 + *-*-mingw*)
6202 + LIBS="$LIBS -lversion -lshlwapi -lpathcch -lbcrypt"
6205 + awk_extra_flag="--non-decimal-data"
6218 + RCFLAGS="$RCFLAGS -DFIELD3=$FIELD3 -O COFF"
6221 + i686*) RCFLAGS="$RCFLAGS --target=pe-i386" ;;
6222 + x86_64*) RCFLAGS="$RCFLAGS --target=pe-x86-64" ;;
6231 # Availability of -O2:
6232 AC_CACHE_CHECK([for -O2], [ac_cv_compile_o2], [
6234 @@ -6971,7 +7434,6 @@ PY_STDLIB_MOD_SIMPLE([_json])
6238 -PY_STDLIB_MOD_SIMPLE([_posixsubprocess])
6242 @@ -6982,7 +7444,7 @@ PY_STDLIB_MOD_SIMPLE([_zoneinfo])
6246 - [], [test "$ac_cv_func_sem_unlink" = "yes"],
6247 + [], [test "$ac_cv_func_sem_unlink" = "yes" -o "$MACHDEP" = "win32"],
6248 [-I\$(srcdir)/Modules/_multiprocessing])
6251 @@ -7002,11 +7464,15 @@ PY_STDLIB_MOD([fcntl],
6252 [], [test "$ac_cv_header_sys_ioctl_h" = "yes" -a "$ac_cv_header_fcntl_h" = "yes"],
6255 - [], [test "$ac_cv_header_sys_mman_h" = "yes" -a "$ac_cv_header_sys_stat_h" = "yes"])
6257 + -a "$ac_cv_header_sys_stat_h" = "yes"
6258 + -o "$MACHDEP" = "win32"]))
6261 -a "$ac_cv_header_sys_types_h" = "yes"
6262 - -a "$ac_cv_header_netinet_in_h" = "yes"]))
6263 + -a "$ac_cv_header_netinet_in_h" = "yes"
6264 + -o "$MACHDEP" = "win32"]),
6268 PY_STDLIB_MOD([grp], [], [test "$ac_cv_func_getgrgid" = yes -o "$ac_cv_func_getgrgid_r" = yes])
6269 @@ -7021,6 +7487,7 @@ PY_STDLIB_MOD([_scproxy],
6270 PY_STDLIB_MOD([spwd], [], [test "$ac_cv_func_getspent" = yes -o "$ac_cv_func_getspnam" = yes])
6277 @@ -7083,25 +7550,35 @@ PY_STDLIB_MOD([_lzma], [], [test "$have_liblzma" = yes],
6281 - [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS])
6282 + [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS -lws2_32])
6290 + [-lmsi -lcabinet -lrpcrt4])
6292 + [-lwinmm])
6294 + [-lws2_32])
6299 -PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes])
6300 +PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes], [], [-DPY3_DLLNAME="\"$DLLLIBRARY…
6302 -PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = ye…
6303 -PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
6307 -PY_STDLIB_MOD([_ctypes_test], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes], [],…
6308 …_MOD([_ctypes_test], [test "$TEST_MODULES" = yes], [test "$have_dynamic_loading" = yes], [], [-lm])
6313 -PY_STDLIB_MOD([xxlimited], [test "$with_trace_refs" = "no"], [test "$ac_cv_func_dlopen" = yes])
6314 -PY_STDLIB_MOD([xxlimited_35], [test "$with_trace_refs" = "no"], [test "$ac_cv_func_dlopen" = yes])
6320 diff --git a/mingw_ignorefile.txt b/mingw_ignorefile.txt
6323 --- /dev/null
6325 @@ -0,0 +1,42 @@
6368 diff --git a/mingw_smoketests.py b/mingw_smoketests.py
6371 --- /dev/null
6373 @@ -0,0 +1,358 @@
6419 + # https://github.com/msys2-contrib/cpython-mingw/issues/32
6438 + # https://github.com/msys2/MINGW-packages/issues/9319
6556 + # Make sure --enable-loadable-sqlite-extensions is used
6573 + # This will not work in in-tree build
6578 + "-c",
6596 + self.assertTrue(sysconfig.get_platform().startswith("mingw"))
6597 + self.assertTrue(sysconfig.get_config_var('SOABI').startswith("cpython-"))
6600 + self.assertTrue("mingw" in ext_suffix)
6606 + self.assertEqual(sys.winver, ".".join(map(str, sys.version_info[:2])) + '-32')
6608 + self.assertEqual(sys.winver, ".".join(map(str, sys.version_info[:2])) + '-arm64')
6610 + self.assertEqual(sys.winver, ".".join(map(str, sys.version_info[:2])) + '-arm32')
6648 + subprocess.check_call([sys.executable, "-m", "ensurepip", "--user"])
6687 + -1,
6700 + [sys.executable, "-c", "import struct"],
6705 + "-m",
6714 + "-m",
6721 + [sys.executable, "-c", "import cwrapper"],
6732 diff --git a/pyconfig.h.in b/pyconfig.h.in
6734 --- a/pyconfig.h.in
6736 @@ -60,7 +60,7 @@
6740 -/* struct addrinfo (netdb.h) */
6745 @@ -1521,6 +1521,9 @@
6755 @@ -1836,7 +1839,7 @@
6759 -/* Define to `int' if <sys/socket.h> does not define. */
6764 diff --git a/setup.py b/setup.py
6766 --- a/setup.py
6768 @@ -77,9 +77,24 @@ def get_platform():
6779 + command_in_sh = 'sh.exe -c "%s"' % command.replace("\\", "\\\\")
6789 -MS_WINDOWS = (HOST_PLATFORM == 'win32')
6790 +MS_WINDOWS = (HOST_PLATFORM == 'win32' or HOST_PLATFORM == 'mingw')
6794 @@ -687,7 +702,7 @@ def check_extension_import(self, ext):
6798 - tmpfile = os.path.join(self.build_temp, 'multiarch')
6803 @@ -712,7 +727,7 @@ def add_multiarch_paths(self):
6806 opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE')
6807 - tmpfile = os.path.join(self.build_temp, 'multiarch')
6812 @@ -774,7 +789,7 @@ def add_search_path(line):
6816 - tmpfile = os.path.join(self.build_temp, 'ccpaths')
6820 # bpo-38472: With a German locale, GCC returns "gcc-Version 9.1.0
6821 @@ -796,14 +811,25 @@ def add_cross_compiling_paths(self):
6825 - for d in line.strip().split("=")[1].split(":"):
6828 - if '/gcc/' not in d:
6836 + ret = run_command('%s -print-search-dirs >%s' % (CC, tmpfile))
6849 @@ -849,10 +875,10 @@ def configure_compiler(self):
6857 - self.add_multiarch_paths()
6861 @@ -898,7 +924,7 @@ def init_inc_lib_dirs(self):
6862 if HOST_PLATFORM == 'hp-ux11':
6865 - if MACOS:
6867 # This should work on any unixy platform ;-)
6868 # If the user has bothered specifying additional -I and -L flags
6870 @@ -970,11 +996,15 @@ def detect_simple_extensions(self):
6874 - self.addext(Extension('_socket', ['socketmodule.c']))
6881 - self.addext(Extension('select', ['selectmodule.c']))
6886 # Memory-mapped files (also works on Win32).
6888 @@ -1033,12 +1063,15 @@ def detect_test_extensions(self):
6900 - tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib')
6905 @@ -1101,6 +1134,8 @@ def detect_readline_curses(self):
6914 @@ -1124,8 +1159,7 @@ def detect_readline_curses(self):
6918 - if not CROSS_COMPILING:
6919 - curses_includes.append('/usr/include/ncursesw')
6924 @@ -1209,7 +1243,7 @@ def detect_dbm_gdbm(self):
6926 dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":")
6928 - dbm_order = "gdbm:ndbm:bdb".split(":")
6933 @@ -1282,6 +1316,19 @@ def detect_platform_specific_exts(self):
6934 # macOS-only, needs SystemConfiguration and CoreFoundation framework
6937 + # Windows-only modules
6953 @@ -1329,9 +1376,10 @@ def detect_multiprocessing(self):
6957 - ):
6960 - self.addext(Extension('_multiprocessing', multiprocessing_srcs))
6966 @@ -1414,11 +1462,16 @@ def detect_ctypes(self):
6970 - libraries=[],
6979 - self.addext(Extension('_ctypes_test', ['_ctypes/_ctypes_test.c']))
6985 @@ -1568,7 +1621,7 @@ def copy_scripts(self):
6989 - os.rename(filename, newfilename)