msys2-contrib / cpython-mingw

A friendly fork of CPython which adds support for Mingw-w64 + clang/gcc. See https://github.com/msys2-contrib/cpython-mingw/wiki for details
https://github.com/msys2-contrib/cpython-mingw/wiki
Other
38 stars 12 forks source link

Python 3.11 #139

Closed naveen521kk closed 1 year ago

naveen521kk commented 1 year ago

https://gist.github.com/naveen521kk/19d01c3841a98bd7890aaaa94f6657b2

git range-diff v3.10.12...mingw-v3.10.12 v3.11.2...wip-mingw-v3.11.2 ``` 1: 72cb22a255 = 1: ee7014656b sysconfig: make _sysconfigdata.py relocatable 2: e5355d722a < -: ---------- restore setup config 3: 0e78138b41 ! 2: 529a549c50 build: add --with-nt-threads and make it default on mingw @@ Metadata ## Commit message ## build: add --with-nt-threads and make it default on mingw + Co-authored-by: Naveen M K Co-authored-by: Алексей Co-authored-by: Christoph Reiter @@ Modules/_multiprocessing/multiprocessing.h # endif # define SEM_HANDLE HANDLE # define SEM_VALUE_MAX LONG_MAX +-# define HAVE_MP_SEMAPHORE ++# define HAVE_MP_SEMAPHORE +# if defined(HAVE_SEM_OPEN) && defined(_POSIX_THREADS) -+# include ++# include +# endif #else # include /* O_CREAT and O_EXCL */ @@ configure.ac: then # On some compilers, pthreads are available without further options # (e.g. MacOS X). On some of these systems, the compiler will not # complain if unaccepted options are passed (e.g. gcc on Mac OS X). -@@ configure.ac: CC="$ac_save_cc"]) - AC_MSG_RESULT($ac_cv_pthread) +@@ configure.ac: int main(void){ + CC="$ac_save_cc"]) fi +fi @@ configure.ac: elif test "$ac_cv_pthread" = "yes" fi if test $ac_cv_cxx_thread = yes -@@ configure.ac: dnl AC_MSG_RESULT($cpp_type) - AC_HEADER_STDC - AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \ - fcntl.h grp.h \ --ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \ --sched.h shadow.h signal.h stropts.h termios.h \ -+ieeefp.h io.h langinfo.h libintl.h process.h \ -+shadow.h signal.h stropts.h termios.h \ - utime.h \ - poll.h sys/devpoll.h sys/epoll.h sys/poll.h \ - sys/audioio.h sys/xattr.h sys/bsdtty.h sys/event.h sys/file.h sys/ioctl.h \ -@@ configure.ac: sys/mman.h sys/eventfd.h) +@@ configure.ac: AC_CHECK_HEADERS([ \ + alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \ + ieeefp.h io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/memfd.h \ + linux/random.h linux/soundcard.h \ +- linux/tipc.h linux/wait.h netdb.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \ +- sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \ ++ linux/tipc.h linux/wait.h netdb.h netinet/in.h netpacket/packet.h poll.h process.h pty.h \ ++ setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \ + sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \ + sys/loadavg.h sys/lock.h sys/memfd.h sys/mkdev.h sys/mman.h sys/modem.h sys/param.h sys/poll.h \ + sys/random.h sys/resource.h sys/select.h sys/sendfile.h sys/socket.h sys/soundcard.h sys/stat.h \ +@@ configure.ac: AC_CHECK_HEADERS([ \ AC_HEADER_DIRENT AC_HEADER_MAJOR @@ configure.ac: sys/mman.h sys/eventfd.h) # bluetooth/bluetooth.h has been known to not compile with -std=c99. # http://permalink.gmane.org/gmane.linux.bluez.kernel/22294 SAVE_CFLAGS=$CFLAGS -@@ configure.ac: fi +@@ configure.ac: elif test "$ac_cv_pthread" = "yes" + then CC="$CC -pthread" + fi - AC_MSG_CHECKING(for pthread_t) - have_pthread_t=no +if test $with_nt_threads = yes ; then + dnl skip check for pthread_t if NT-thread model is enabled -+ have_pthread_t=skip ++ ac_cv_have_pthread_t=skip +else + AC_CACHE_CHECK([for pthread_t], [ac_cv_have_pthread_t], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[#include ]], [[pthread_t x; x = *(pthread_t*)0;]]) - ],[have_pthread_t=yes],[]) -@@ configure.ac: if test "$ac_cv_sizeof_pthread_key_t" -eq "$ac_cv_sizeof_int" ; then - else - AC_MSG_RESULT(no) - fi +@@ configure.ac: AS_VAR_IF([ac_cv_pthread_key_t_is_arithmetic_type], [yes], [ + AC_DEFINE(PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT, 1, + [Define if pthread_key_t is compatible with int.]) + ]) +- +fi CC="$ac_save_cc" AC_SUBST(OTHER_LIBTOOL_OPT) -@@ configure.ac: void *x = uuid_enc_be - [AC_MSG_RESULT(no)] - ) +@@ configure.ac: AS_VAR_IF([have_uuid], [missing], [ + + AS_VAR_IF([have_uuid], [missing], [have_uuid=no]) +if test $with_nt_threads = yes ; then + dnl do not search for sem_init if NT-thread model is enabled @@ configure.ac: else + ac_cv_func_sem_open=skip + ac_cv_func_sched_setscheduler=skip +fi - AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ - clock confstr close_range copy_file_range ctermid dup3 execv explicit_bzero \ - explicit_memset faccessat fchmod fchmodat fchown fchownat \ -@@ configure.ac: AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include ]]) - # the kernel module that provides POSIX semaphores - # isn't loaded by default, so an attempt to call - # sem_open results in a 'Signal 12' error. + AC_CHECK_FUNCS([ \ + accept4 alarm bind_textdomain_codeset chmod chown clock close_range confstr \ + copy_file_range ctermid dup dup3 execv explicit_bzero explicit_memset \ +@@ configure.ac: dnl actually works. For FreeBSD versions <= 7.2, + dnl the kernel module that provides POSIX semaphores + dnl isn't loaded by default, so an attempt to call + dnl sem_open results in a 'Signal 12' error. +if test $with_nt_threads = yes ; then + dnl skip posix semaphores test if NT-thread model is enabled + ac_cv_posix_semaphores_enabled=no +fi - AC_MSG_CHECKING(whether POSIX semaphores are enabled) - AC_CACHE_VAL(ac_cv_posix_semaphores_enabled, - AC_RUN_IFELSE([AC_LANG_SOURCE([[ -@@ configure.ac: fi + AC_CACHE_CHECK([whether POSIX semaphores are enabled], [ac_cv_posix_semaphores_enabled], + AC_RUN_IFELSE([ + AC_LANG_SOURCE([ +@@ configure.ac: AS_VAR_IF([ac_cv_posix_semaphores_enabled], [no], [ + ]) - # Multiprocessing check for broken sem_getvalue - AC_MSG_CHECKING(for broken sem_getvalue) + dnl Multiprocessing check for broken sem_getvalue +if test $with_nt_threads = yes ; then + dnl Skip test if NT-thread model is enabled. + dnl NOTE the test case below fail for pthreads-w32 as: @@ configure.ac: fi + dnl - sem_getvalue work(!). + ac_cv_broken_sem_getvalue=skip +fi - AC_CACHE_VAL(ac_cv_broken_sem_getvalue, - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include + AC_CACHE_CHECK([for broken sem_getvalue], [ac_cv_broken_sem_getvalue], + AC_RUN_IFELSE([ + AC_LANG_SOURCE([ ## pyconfig.h.in ## @@ 4: c29961c9ee ! 3: 31f0d6fe42 MINGW translate gcc internal defines to python platf @@ Metadata Author: Алексей ## Commit message ## - MINGW translate gcc internal defines to python platf + Define `MS_WINDOWS` (and others) when compiling with MINGW + + This is used throughout the Python code but is not defined + when compiling with Mingw-w64 compilers, so define it. Co-authored-by: Алексей Co-authored-by: Christoph Reiter 5: 7dc6a0c5aa ! 4: ac609b3e3c MINGW configure MACHDEP and platform for build @@ Metadata Author: Алексей ## Commit message ## - MINGW configure MACHDEP and platform for build + configure: add `MACHDEP` and `platform` on MINGW Co-authored-by: Алексей @@ configure.ac: then esac fi @@ configure.ac: if test "$cross_compiling" = yes; then - *-*-vxworks*) - _host_cpu=$host_cpu ;; + wasm32-*-* | wasm64-*-*) + _host_cpu=$host_cpu ++ ;; + *-*-mingw*) + _host_cpu= -+ ;; + ;; *) # for now, limit cross builds to known configurations - MACHDEP="unknown" +@@ configure.ac: if test "$cross_compiling" = yes; then AC_MSG_ERROR([cross build not supported for $host]) esac _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" 6: b915f58d34 ! 5: d74195995e MINGW preset configure defaults @@ Metadata Author: Алексей ## Commit message ## - MINGW preset configure defaults + Add default configuration for MINGW Co-authored-by: Алексей Co-authored-by: Christoph Reiter @@ Misc/cross_mingw32 (new) +ac_cv_have_size_t_format=no ## configure.ac ## -@@ configure.ac: if test x$MULTIARCH != x; then - fi - AC_SUBST(MULTIARCH_CPPFLAGS) +@@ configure.ac: AC_CACHE_CHECK([for -Wl,--no-as-needed], [ac_cv_wl_no_as_needed], [ + ]) + AC_SUBST(NO_AS_NEEDED) +# initialize default configuration +py_config= @@ configure.ac: if test x$MULTIARCH != x; then + fi +fi + - AC_MSG_CHECKING([for -Wl,--no-as-needed]) - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -Wl,--no-as-needed" + AC_MSG_CHECKING([for the Android API level]) + cat > conftest.c < 6: c4682f267f configure: enable largefile support by default for Mingw 8: 956daba7bc ! 7: 6d56dc1e2c MINGW add srcdir PC to CPPFLAGS @@ Metadata Author: Алексей ## Commit message ## - MINGW add srcdir PC to CPPFLAGS + Add `PC/` to `CPPFLAGS` and to `SRCDIRS` on Mingw - Co-authored-by: Алексей + Co-authored-by: Naveen M K ## configure.ac ## @@ configure.ac: do @@ configure.ac: do +esac + AC_SUBST(SRCDIRS) - SRCDIRS="Parser Objects Python Modules Modules/_io Programs" + SRCDIRS="\ + Modules \ +@@ configure.ac: SRCDIRS="\ + Python \ + Python/frozen_modules \ + Python/deepfreeze" +case $host in + *-*-mingw*) SRCDIRS="$SRCDIRS PC";; +esac ++ AC_MSG_CHECKING(for build directories) for dir in $SRCDIRS; do if test ! -d $dir; then 9: bc0e4176b4 ! 8: e59698bbbe MINGW init system calls @@ Metadata Author: Алексей ## Commit message ## - MINGW init system calls + posixmodule.c: Define necessary headers for compiling on MINGW - Co-authored-by: Алексей + Also, build `nt` module instead of `posix` when compiling + with MINGW. - ## Modules/Setup ## -@@ Modules/Setup: PYTHONPATH=$(COREPYTHONPATH) - # This only contains the minimal set of modules required to run the - # setup.py script in the root of the Python source tree. - --posix -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal 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 + Co-authored-by: Naveen M K + Co-authored-by: Алексей - ## Modules/Setup.config.in ## + ## Modules/Setup.bootstrap.in ## @@ - # The purpose of this file is to conditionally enable certain modules - # based on configure-time options. + # module C APIs are used in core + atexit atexitmodule.c + faulthandler faulthandler.c +-posix posixmodule.c ++@INITSYS@ posixmodule.c + _signal signalmodule.c + _tracemalloc _tracemalloc.c -+# init system calls(posix/nt/...) for INITFUNC (used by makesetup) -+@INITSYS@ -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c -+ ## Modules/posixmodule.c ## @@ Modules/posixmodule.c: corresponding Unix manual entries for more information on calls."); @@ Modules/posixmodule.c: corresponding Unix manual entries for more information on +# define HAVE_CWAIT 1 +# define HAVE_FSYNC 1 +# define fsync _commit -+# include +# include +# ifndef _MAX_ENV +# define _MAX_ENV 32767 +# endif - # else - /* Unix functions that the configure script doesn't check for */ - # ifndef __VXWORKS__ + # endif /* _MSC_VER */ + #endif /* ! __WATCOMC__ || __QNX__ */ + @@ Modules/posixmodule.c: extern char *ctermid_r(char *); # endif #endif 10: 962e83c299 ! 9: 530e93bce8 MINGW build in windows modules winreg @@ Metadata Author: Алексей ## Commit message ## - MINGW build in windows modules winreg + Build winreg by default when compiling for MINGW Co-authored-by: Алексей Co-authored-by: Christoph Reiter - ## Modules/Setup.config.in ## -@@ - # init system calls(posix/nt/...) for INITFUNC (used by makesetup) - @INITSYS@ -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c + ## Modules/Setup.bootstrap.in ## +@@ Modules/Setup.bootstrap.in: _symtable symtablemodule.c + # for systems without $HOME env, used by site._getuserbase() + @MODULE_PWD_TRUE@pwd pwdmodule.c ++ +# build-in modules for windows platform: +@USE_WIN32_MODULE@winreg ../PC/winreg.c -+ ## PC/winreg.c ## @@ @@ PC/winreg.c static PyObject *PyHKEY_FromHKEY(HKEY h); ## configure.ac ## -@@ configure.ac: else - fi]) +@@ configure.ac: AS_VAR_IF([with_dbmliborder], [error], [ + ]) AC_MSG_RESULT($with_dbmliborder) +# Determine if windows modules should be used. 11: e37277bf1e < -: ---------- MINGW determine if pwdmodule should be used 12: def2c6097b ! 10: 585cd7386c issue6672 v2 Add Mingw recognition to pyport.h to al @@ Metadata Author: Алексей ## Commit message ## - issue6672 v2 Add Mingw recognition to pyport.h to al + pyport.h: Add support for MINGW Co-authored-by: Алексей @@ Include/pyport.h: extern char * _getpty(int *, int, mode_t, int); # define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE /* module init functions outside the core must be exported */ # if defined(__cplusplus) - - ## setup.py ## -@@ setup.py: def build_extensions(self): - self.configure_compiler() - self.init_inc_lib_dirs() - -+ if MS_WINDOWS: -+ self.compiler.define_macro("Py_BUILD_CORE_MODULE") -+ - # Detect which modules should be compiled - self.detect_modules() - 13: f3de3128ea < -: ---------- MINGW configure for shared build -: ---------- > 11: 264da02393 configure: add options so that shared build is possible on MINGW 14: 307c5b0d41 ! 12: bf9aa0b7a9 MINGW dynamic loading support @@ Metadata Author: Алексей ## Commit message ## - MINGW dynamic loading support + Add dynamic loading support for MINGW Co-authored-by: Алексей 15: 91a3572eaa ! 13: 871435dc9a MINGW ignore main program for frozen scripts @@ Metadata Author: Алексей ## Commit message ## - MINGW ignore main program for frozen scripts + Ignore main program for frozen scripts on MINGW Co-authored-by: Алексей ## Makefile.pre.in ## @@ Makefile.pre.in: PYTHON_OBJS= \ - Python/context.o \ Python/dynamic_annotations.o \ Python/errors.o \ + Python/frame.o \ - Python/frozenmain.o \ + @PYTHON_OBJS_FROZENMAIN@ \ Python/future.o \ @@ configure.ac: case $host in +esac + AC_SUBST(SRCDIRS) - SRCDIRS="Parser Objects Python Modules Modules/_io Programs" - case $host in + SRCDIRS="\ + Modules \ 16: 6648f13969 < -: ---------- MINGW setup _multiprocessing module -: ---------- > 14: e3be69776a Add missing library for multiprocessing module 17: 6d7837fd3f ! 15: 9d0eab228e MINGW setup select module @@ ## Metadata ## -Author: Алексей +Author: Naveen M K ## Commit message ## - MINGW setup select module - - Co-authored-by: Алексей + selectmodule: add support for MINGW ## Modules/selectmodule.c ## @@ Modules/selectmodule.c: seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1]) @@ Modules/selectmodule.c: seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SET ## setup.py ## @@ setup.py: def detect_simple_extensions(self): - self.missing.append('spwd') + self.addext(Extension('spwd', ['spwdmodule.c'])) # select(2); not on ancient System V -- self.add(Extension('select', ['selectmodule.c'])) -+ select_libs = [] -+ if MS_WINDOWS: -+ select_libs += ['ws2_32'] -+ self.add(Extension('select', ['selectmodule.c'], -+ libraries=select_libs)) +- self.addext(Extension('select', ['selectmodule.c'])) ++ self.addext(Extension( ++ 'select', ['selectmodule.c'], ++ libraries=(['ws2_32'] if MS_WINDOWS else None))) # Memory-mapped files (also works on Win32). - self.add(Extension('mmap', ['mmapmodule.c'])) + self.addext(Extension('mmap', ['mmapmodule.c'])) 18: b9449118ee < -: ---------- MINGW setup _ctypes module with system libffi -: ---------- > 16: 0fb7e550f1 setup.py: add libraries to fix compile of ctypes on MINGW 19: 1cf1eb472a ! 17: 1d3b8fdcd3 MINGW defect winsock2 and setup _socket module @@ Metadata Author: Алексей ## Commit message ## - MINGW defect winsock2 and setup _socket module + Detect winsock2 and setup _socket module on MINGW Co-authored-by: Алексей @@ Modules/socketmodule.c: remove_unusable_flags(PyObject *m) #endif ## configure.ac ## -@@ configure.ac: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - ],[]) - AC_MSG_RESULT($was_it_defined) +@@ configure.ac: if test $ac_cv_header_time_altzone = yes; then + AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.]) + fi +AC_CHECK_HEADERS([ws2tcpip.h]) - AC_MSG_CHECKING(for addrinfo) - AC_CACHE_VAL(ac_cv_struct_addrinfo, + AC_CACHE_CHECK([for addrinfo], [ac_cv_struct_addrinfo], -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct addrinfo a]])], +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef HAVE_WS2TCPIP_H @@ configure.ac: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + [[struct addrinfo a]])], [ac_cv_struct_addrinfo=yes], [ac_cv_struct_addrinfo=no])) - AC_MSG_RESULT($ac_cv_struct_addrinfo) if test $ac_cv_struct_addrinfo = yes; then - AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)]) + AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo]) fi - AC_MSG_CHECKING(for sockaddr_storage) - AC_CACHE_VAL(ac_cv_struct_sockaddr_storage, + AC_CACHE_CHECK([for sockaddr_storage], [ac_cv_struct_sockaddr_storage], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -# include -# include ]], [[struct sockaddr_storage s]])], @@ configure.ac: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + [[struct sockaddr_storage s]])], [ac_cv_struct_sockaddr_storage=yes], [ac_cv_struct_sockaddr_storage=no])) - AC_MSG_RESULT($ac_cv_struct_sockaddr_storage) + if test $ac_cv_struct_sockaddr_storage = yes; then @@ configure.ac: fi AC_CHECK_TYPE(socklen_t,, @@ pyconfig.h.in /* Define to `int' if doesn't define. */ ## setup.py ## -@@ setup.py: def detect_socket(self): - if MACOS: - # Issue #35569: Expose RFC 3542 socket options. - kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542'] -+ if MS_WINDOWS: -+ kwargs['libraries'] = ['ws2_32', 'iphlpapi'] +@@ setup.py: def detect_simple_extensions(self): + # grp(3) + self.addext(Extension('grp', ['grpmodule.c'])) - self.add(Extension('_socket', ['socketmodule.c'], **kwargs)) +- self.addext(Extension('_socket', ['socketmodule.c'])) ++ self.addext(Extension( ++ '_socket', ['socketmodule.c'], ++ libraries=(['ws2_32', 'iphlpapi'] if MS_WINDOWS else None))) + self.addext(Extension('spwd', ['spwdmodule.c'])) + # select(2); not on ancient System V 20: e780e3d7ea < -: ---------- MINGW exclude unix only modules 21: 16c0a0f9fe ! 18: 40713bfeab MINGW setup msvcrt and _winapi modules @@ ## Metadata ## -Author: Алексей +Author: Naveen M K ## Commit message ## - MINGW setup msvcrt and _winapi modules + Enable some windows specific modules - Co-authored-by: Алексей + ## Modules/Setup.bootstrap.in ## +@@ Modules/Setup.bootstrap.in: _symtable symtablemodule.c + + # build-in modules for windows platform: + @USE_WIN32_MODULE@winreg ../PC/winreg.c ++@MODULE_MSVCRT_TRUE@msvcrt -DPy_BUILD_CORE ../PC/msvcrtmodule.c ++@MODULE__WINAPI_TRUE@_winapi _winapi.c ## Modules/_winapi.c ## @@ @@ Python/dynamic_annotations.c #endif + ## configure.ac ## +@@ configure.ac: PY_STDLIB_MOD([_ssl], [], [test "$ac_cv_working_openssl_ssl" = yes], + PY_STDLIB_MOD([_hashlib], [], [test "$ac_cv_working_openssl_hashlib" = yes], + [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS]) + ++dnl windows specific modules ++PY_STDLIB_MOD([msvcrt], [test "$MACHDEP" = "win32"]) ++PY_STDLIB_MOD([_winapi], [test "$MACHDEP" = "win32"]) ++PY_STDLIB_MOD([_msi], [test "$MACHDEP" = "win32"], [], [], ++ [-lmsi -lcabinet -lrpcrt4]) ++PY_STDLIB_MOD([winsound], [test "$MACHDEP" = "win32"], [], [], ++ [-lwinmm]) ++PY_STDLIB_MOD([_overlapped], [test "$MACHDEP" = "win32"], [], [], ++ [-lws2_32]) ++ + dnl test modules + PY_STDLIB_MOD([_testcapi], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_testclinic], [test "$TEST_MODULES" = yes]) + ## setup.py ## @@ setup.py: def detect_platform_specific_exts(self): - '-framework', 'SystemConfiguration', - '-framework', 'CoreFoundation'])) + # macOS-only, needs SystemConfiguration and CoreFoundation framework + self.addext(Extension('_scproxy', ['_scproxy.c'])) -+ # Modules with some Windows dependencies: ++ # Windows-only modules + if MS_WINDOWS: + srcdir = sysconfig.get_config_var('srcdir') + pc_srcdir = os.path.abspath(os.path.join(srcdir, 'PC')) + -+ self.add(Extension('msvcrt', [os.path.join(pc_srcdir, p) -+ for p in ['msvcrtmodule.c']])) -+ -+ self.add(Extension('_winapi', ['_winapi.c'])) -+ -+ self.add(Extension('_msi', [os.path.join(pc_srcdir, p) -+ for p in ['_msi.c']], -+ libraries=['msi','cabinet','rpcrt4'])) # To link with lib(msi|cabinet|rpcrt4).a ++ self.addext(Extension('_msi', ++ [os.path.join(pc_srcdir, '_msi.c')])) + -+ self.add(Extension('winsound', [os.path.join(pc_srcdir, p) -+ for p in ['winsound.c']], -+ libraries=['winmm'])) ++ self.addext(Extension('winsound', ++ [os.path.join(pc_srcdir, 'winsound.c')])) + -+ self.add(Extension('_overlapped', ['overlapped.c'], -+ libraries=['ws2_32'])) ++ self.addext(Extension('_overlapped', ['overlapped.c'])) + def detect_compress_exts(self): - # Andrew Kuchling's zlib module. Note that some versions of zlib - # 1.1.3 have security problems. See CERT Advisory CA-2002-07: + # Andrew Kuchling's zlib module. + self.addext(Extension('zlib', ['zlibmodule.c'])) 22: a10619d5b7 = 19: 46870e479b sysconfig: MINGW build extensions with GCC 23: 7c609c3d3e < -: ---------- MINGW setup _ssl module 24: 668489f513 ! 20: df037baa4e MINGW generalization of posix build in sysconfig.py @@ Metadata Author: Алексей ## Commit message ## - MINGW generalization of posix build in sysconfig.py + sysconfig: treat MINGW builds as POSIX builds Co-authored-by: Алексей @@ Lib/sysconfig.py +_POSIX_BUILD = os.name == 'posix' or \ + (os.name == "nt" and 'GCC' in sys.version) + -+ + # For the OS-native venv scheme, we essentially provide an alias: +-if os.name == 'nt': ++if os.name == 'nt' and not _POSIX_BUILD: + _INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['nt_venv'] + else: + _INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_venv'] + ++ # NOTE: site.py has copy of this function. # Sync it when modify this function. + def _getuserbase(): @@ Lib/sysconfig.py: def _getuserbase(): def joinuser(*args): return os.path.expanduser(os.path.join(*args)) @@ Lib/sysconfig.py: def _getuserbase(): base = os.environ.get("APPDATA") or "~" return joinuser(base, "Python") -@@ Lib/sysconfig.py: def joinuser(*args): - _findvar1_rx = r"\$\(([A-Za-z][A-Za-z0-9_]*)\)" - _findvar2_rx = r"\${([A-Za-z][A-Za-z0-9_]*)}" - -- - def _safe_realpath(path): - try: - return realpath(path) @@ Lib/sysconfig.py: def _expand_vars(scheme, vars): @@ Lib/sysconfig.py: def parse_config_h(fp, vars=None): if _PYTHON_BUILD: - if os.name == "nt": + if os.name == "nt" and not _POSIX_BUILD: - inc_dir = os.path.join(_sys_home or _PROJECT_BASE, "PC") + inc_dir = os.path.join(_PROJECT_BASE, "PC") else: - inc_dir = _sys_home or _PROJECT_BASE + inc_dir = _PROJECT_BASE @@ Lib/sysconfig.py: def get_config_vars(*args): except AttributeError: _CONFIG_VARS['py_version_nodot_plat'] = '' @@ Lib/sysconfig.py: def get_config_vars(*args): - if os.name == 'nt': + if os.name == 'nt' and not _POSIX_BUILD: _init_non_posix(_CONFIG_VARS) + _CONFIG_VARS['VPATH'] = sys._vpath - if os.name == 'posix': + if _POSIX_BUILD: _init_posix(_CONFIG_VARS) - # For backward compatibility, see issue19555 - SO = _CONFIG_VARS.get('EXT_SUFFIX') + if _HAS_USER_BASE: + # Setting 'userbase' is done below the call to the @@ Lib/sysconfig.py: def get_config_vars(*args): # Always convert srcdir to an absolute path 25: 3258388e0a ! 21: b4b16fd7db MINGW support stdcall without underscore @@ Metadata Author: Алексей ## Commit message ## - MINGW support stdcall without underscore + Add support for stdcall without underscore + + This is the case used in MINGW Co-authored-by: Алексей 26: 7410fa82e6 ! 22: eeab65d65b use replace instead rename to avoid failure on windo @@ Metadata Author: Алексей ## Commit message ## - use replace instead rename to avoid failure on windo + Use replace instead rename to avoid failure on windows Co-authored-by: Алексей Co-authored-by: Christoph Reiter 27: ae571ae936 ! 23: a96dc849dd MINGW customize site @@ Metadata Author: Алексей ## Commit message ## - MINGW customize site + Customize site for MINGW Co-authored-by: Алексей Co-authored-by: Christoph Reiter @@ Lib/site.py: def joinuser(*args): return f'{userbase}\\Python{ver_nodot}\\site-packages' @@ Lib/site.py: def getsitepackages(prefixes=None): - if sys.platlibdir != "lib": - libdirs.append("lib") + continue + seen.add(prefix) - if os.sep == '/': + if _POSIX_BUILD: - for libdir in libdirs: - path = os.path.join(prefix, libdir, - "python%d.%d" % sys.version_info[:2], + libdirs = [sys.platlibdir] + if sys.platlibdir != "lib": + libdirs.append("lib") 28: 8fba0b678b = 24: b40a521028 add python config sh 29: 85b5f50300 < -: ---------- cross darwin feature 30: 92a4e79e2b < -: ---------- mingw system libffi -: ---------- > 25: d91bb76014 setup.py: add export_symbols to fix compile of ctypes 31: cdd15d1b39 ! 26: 992684e055 msys mingw prefer unix sep if MSYSTEM @@ Metadata Author: Ray Donnelly ## Commit message ## - msys mingw prefer unix sep if MSYSTEM + mingw: prefer unix sep if MSYSTEM environment variable Co-authored-by: Алексей Co-authored-by: Christoph Reiter Co-authored-by: cat + Co-authored-by: Naveen M K ## Include/pylifecycle.h ## @@ Include/pylifecycle.h: PyAPI_FUNC(int) Py_IsInitialized(void); @@ Lib/ntpath.py + return b':' + else: + return ':' ++ ++def _get_unc_prefix(path): ++ if isinstance(path, bytes): ++ return b'\\\\?\\UNC\\' ++ else: ++ return '\\\\?\\UNC\\' # Normalize the case of a pathname and map slashes to backslashes. # Other normalizations (such as optimizing '../' away) are not done @@ Lib/ntpath.py: def normcase(s): # Return whether a path is absolute. +@@ Lib/ntpath.py: def normcase(s): + def isabs(s): + """Test whether a path is absolute""" + s = os.fspath(s) +- if isinstance(s, bytes): +- sep = b'\\' +- altsep = b'/' +- colon_sep = b':\\' +- else: +- sep = '\\' +- altsep = '/' +- colon_sep = ':\\' ++ sep = _get_sep(s) ++ altsep = _get_altsep(s) ++ colon_sep = _get_colon(s) + sep + s = s[:3].replace(altsep, sep) + # Absolute: UNC, device, and paths with a drive and root. + # LEGACY BUG: isabs("/x") should be false since the path has no drive. @@ Lib/ntpath.py: def isabs(s): # Join two (or more) paths. def join(path, *paths): @@ Lib/ntpath.py: def splitdrive(p): - sep = b'\\' - altsep = b'/' - colon = b':' +- unc_prefix = b'\\\\?\\UNC\\' - else: - sep = '\\' - altsep = '/' - colon = ':' +- unc_prefix = '\\\\?\\UNC\\' + sep = _get_sep(p) + altsep = _get_altsep(p) + colon = _get_colon(p) ++ unc_prefix = _get_unc_prefix(p) normp = p.replace(altsep, sep) - if (normp[0:2] == sep*2) and (normp[2:3] != sep): - # is a UNC path: + if normp[0:2] == sep * 2: + # UNC drives, e.g. \\server\share or \\?\UNC\server\share @@ Lib/ntpath.py: def split(p): def splitext(p): p = os.fspath(p) @@ Lib/ntpath.py: def split(p): @@ Lib/ntpath.py: def expandvars(path): - def normpath(path): - """Normalize path, eliminating double slashes, etc.""" - path = os.fspath(path) -+ sep = _get_sep(path) -+ altsep = _get_altsep(path) - if isinstance(path, bytes): -- sep = b'\\' -- altsep = b'/' - curdir = b'.' - pardir = b'..' - special_prefixes = (b'\\\\.\\', b'\\\\?\\') - else: -- sep = '\\' -- altsep = '/' - curdir = '.' - pardir = '..' - special_prefixes = ('\\\\.\\', '\\\\?\\') + def normpath(path): + """Normalize path, eliminating double slashes, etc.""" + path = os.fspath(path) ++ sep = _get_sep(path) ++ altsep = _get_altsep(path) + if isinstance(path, bytes): +- sep = b'\\' +- altsep = b'/' + curdir = b'.' + pardir = b'..' + else: +- sep = '\\' +- altsep = '/' + curdir = '.' + pardir = '..' + path = path.replace(altsep, sep) @@ Lib/ntpath.py: def realpath(path, *, strict=False): # strip the prefix anyway. if ex.winerror == initial_winerror: @@ Modules/posixmodule.c: os__getfinalpathname_impl(PyObject *module, path_t *path) Py_SETREF(result, PyUnicode_EncodeFSDefault(result)); ## Python/initconfig.c ## -@@ Python/initconfig.c: static const char usage_6[] = - "PYTHONPYCACHEPREFIX: root directory for bytecode cache (pyc) files.\n" - "PYTHONWARNDEFAULTENCODING: enable opt-in EncodingWarning for 'encoding=None'.\n"; +@@ Python/initconfig.c: static const char usage_envvars[] = + "PYTHONVERBOSE : trace import statements (-v)\n" + "PYTHONWARNINGS=arg : warning control (-W arg)\n"; -#if defined(MS_WINDOWS) +#if defined(_MSC_VER) # define PYTHONHOMEHELP "\\python{major}{minor}" #else # define PYTHONHOMEHELP "/lib/pythonX.X" -@@ Python/initconfig.c: config_init_program_name(PyConfig *config) - } - - /* Last fall back: hardcoded name */ --#ifdef MS_WINDOWS -+#ifdef _MSC_VER - const wchar_t *default_program_name = L"python"; - #else - const wchar_t *default_program_name = L"python3"; ## Python/pathconfig.c ## @@ @@ Python/pathconfig.c + } +} - _PyPathConfig _Py_path_config = _PyPathConfig_INIT; + /* External interface */ @@ Python/pathconfig.c: _Py_SetProgramFullPath(const wchar_t *program_full_path) - if (_Py_path_config.program_full_path == NULL) { + if (has_value && _Py_path_config.program_full_path == NULL) { path_out_of_memory(__func__); } + Py_NormalizeSepsW(_Py_path_config.program_name); 32: 977d86213b < -: ---------- mingw use posix getpath 33: bdebab7343 < -: ---------- mingw add ModuleFileName dir to PATH 34: 03b41c3512 < -: ---------- mingw add BUILDIN_WIN32_MODULEs time msvcrt 35: 79cae867a6 = 27: d0cbde9726 msys cygwin semi native build sysconfig 36: 04f84c6027 ! 28: 3aefa65750 sysconfig: mingw sysconfig like posix @@ Lib/sysconfig.py + 'scripts': '{base}/bin', 'data': '{base}', }, - } + # Downstream distributors can overwrite the default install scheme. @@ Lib/sysconfig.py: def joinuser(*args): _INSTALL_SCHEMES |= { # NOTE: When modifying "purelib" scheme, update site._get_path() too. 37: 071549b4d5 < -: ---------- build _winapi earlier so we can use it in distutils via subprocess 38: 5a7c31e5ee = 29: 20d6a728e3 cross dont add multiarch paths if cross compiling 39: d0884319d9 = 30: 037c566c56 mingw use backslashes in compileall py 40: fde18972fe ! 31: 7feee269dc msys convert_path fix and root hack @@ Commit message msys convert_path fix and root hack ## Makefile.pre.in ## -@@ Makefile.pre.in: libainstall: @DEF_MAKE_RULE@ python-config +@@ Makefile.pre.in: libainstall: all python-config else true; \ fi @@ Makefile.pre.in: libainstall: @DEF_MAKE_RULE@ python-config + # Install the dynamically loadable modules # This goes into $(exec_prefix) - sharedinstall: sharedmods -@@ Makefile.pre.in: sharedinstall: sharedmods + sharedinstall: all +@@ Makefile.pre.in: sharedinstall: all --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ --install-platlib=$(DESTSHARED) \ 41: 6d8ac901a6 < -: ---------- allow static tcltk 42: 15598251a1 = 32: a3a0654f01 mingw pdcurses_ISPAD 43: b0f81385f1 < -: ---------- builddir fixes 44: 4f1a15298e = 33: 6eb63997e6 msys monkeypatch os system via sh exe 45: eb7e8d3e66 ! 34: 03306b49e4 msys replace slashes used in io redirection @@ setup.py: def detect_readline_curses(self): if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) # Determine if readline is already linked against curses or tinfo. -@@ setup.py: def detect_tkinter_darwin(self): - cflags = sysconfig.get_config_vars('CFLAGS')[0] - archs = re.findall(r'-arch\s+(\w+)', cflags) - -- tmpfile = os.path.join(self.build_temp, 'tk.arch') -+ tmpfile = os.path.join(self.build_temp, 'tk.arch').replace('\\','/') - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - - run_command( -- "file {}/Tk.framework/Tk | grep 'for architecture' > {}".format(F, tmpfile) -+ "file {}/Tk.framework/Tk | grep 'for architecture' > {}".format(F, tmpfile).replace('\\','/') - ) - with open(tmpfile) as fp: - detected_archs = [] 46: a92ed0c56d = 35: 8a931e9e47 remove_path_max.default 47: 8e9971255a = 36: 0d8f66272a dont link with gettext 48: 0792fdffff = 37: 65d149db2a ctypes python dll 49: b53a8514ba ! 38: 137580f1fa gdbm module includes @@ Commit message ## Modules/_gdbmmodule.c ## @@ - #include - #include "gdbm.h" + #include + #include -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) 50: 7c0c90c922 ! 39: 2a27cd028e use gnu_printf in format @@ Include/pyport.h: extern char * _getpty(int *, int, mode_t, int); * detected by configure and defined in pyconfig.h. The code in pyconfig.h ## Include/sysmodule.h ## -@@ Include/sysmodule.h: PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int); - PyAPI_FUNC(void) PySys_SetPath(const wchar_t *); +@@ Include/sysmodule.h: Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int); + Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetPath(const wchar_t *); PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); 51: f175eabde0 ! 40: 4142517628 mingw fix ssl dont use enum_certificates @@ Commit message Co-authored-by: Christoph Reiter ## Lib/ssl.py ## -@@ Lib/ssl.py: class _TLSMessageType(_IntEnum): +@@ Lib/ssl.py: class _TLSMessageType: CHANGE_CIPHER_SPEC = 0x0101 52: 5bf6b91d9c = 41: ac17b612ad fix using dllhandle and winver mingw 53: 8af635fcd8 = 42: 30f170d171 Add AMD64 to sys config so msvccompiler get_build_version works 54: 10cc9332f5 ! 43: ea62ff7f23 MINGW link with additional library @@ configure.ac: for dir in $SRCDIRS; do +esac + # Availability of -O2: - AC_MSG_CHECKING(for -O2) + AC_CACHE_CHECK([for -O2], [ac_cv_compile_o2], [ saved_cflags="$CFLAGS" 55: df59a6a6c2 ! 44: 92e51880c7 install msilib @@ Commit message ## Makefile.pre.in ## @@ Makefile.pre.in: LIBSUBDIRS= asyncio \ - sqlite3 \ tkinter \ + tomllib \ turtledemo \ + msilib \ unittest \ 56: 05ba617ec9 < -: ---------- fix signal module build 57: fcbb8def66 < -: ---------- build: build winconsoleio and _testconsole -: ---------- > 45: 43613c61c6 fix signal module build -: ---------- > 46: ebf071a5a4 build: build winconsoleio and _testconsole 58: d771d55fbe = 47: 05a0cacc61 expose sem_unlink 59: d4a09679ef ! 48: a69a3847f7 cygpty isatty @@ Makefile.pre.in: PYTHON_OBJS= \ Python/modsupport.o \ Python/mysnprintf.o \ @@ Makefile.pre.in: PYTHON_HEADERS= \ + $(srcdir)/Include/frameobject.h \ $(srcdir)/Include/import.h \ - $(srcdir)/Include/interpreteridobject.h \ $(srcdir)/Include/intrcheck.h \ + $(srcdir)/Include/iscygpty.h \ $(srcdir)/Include/iterobject.h \ $(srcdir)/Include/listobject.h \ - $(srcdir)/Include/longintrepr.h \ + $(srcdir)/Include/longobject.h \ ## Modules/_io/fileio.c ## @@ @@ Modules/posixmodule.c #endif +#include "iscygpty.h" - #include /* needed for ctermid() */ - + #include // ctermid() + #include // system() @@ Modules/posixmodule.c: os_isatty_impl(PyObject *module, int fd) int return_value; Py_BEGIN_ALLOW_THREADS @@ Modules/posixmodule.c: os_isatty_impl(PyObject *module, int fd) ## Objects/fileobject.c ## @@ - #define PY_SSIZE_T_CLEAN #include "Python.h" + #include "pycore_call.h" // _PyObject_CallNoArgs() +#include "iscygpty.h" - #include "pycore_runtime.h" // _PyRuntime + #include "pycore_runtime.h" // _PyRuntime #if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER) @@ Objects/fileobject.c: stdprinter_isatty(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored)) @@ Python/bltinmodule.c +#include "iscygpty.h" #include #include "pycore_ast.h" // _PyAST_Validate() - #include "pycore_compile.h" // _PyAST_Compile() + #include "pycore_call.h" // _PyObject_CallNoArgs() @@ Python/bltinmodule.c: builtin_input_impl(PyObject *module, PyObject *prompt) Py_DECREF(tmp); if (fd < 0 && PyErr_Occurred()) @@ Python/bltinmodule.c: builtin_input_impl(PyObject *module, PyObject *prompt) + tty = fd == fileno(stdin) && (isatty(fd) || is_cygpty(fd)); } if (tty) { - tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_fileno); + tmp = PyObject_CallMethodNoArgs(fout, &_Py_ID(fileno)); @@ Python/bltinmodule.c: builtin_input_impl(PyObject *module, PyObject *prompt) Py_DECREF(tmp); if (fd < 0 && PyErr_Occurred()) @@ Python/frozenmain.c #ifdef MS_WINDOWS extern void PyWinFreeze_ExeInit(void); @@ Python/frozenmain.c: Py_FrozenMain(int argc, char **argv) - else sts = 0; + } -- if (inspect && isatty((int)fileno(stdin))) +- if (inspect && isatty((int)fileno(stdin))) { + if (inspect && (isatty((int)fileno(stdin)) || is_cygpty((int)fileno(stdin)))) sts = PyRun_AnyFile(stdin, "") != 0; + } - #ifdef MS_WINDOWS ## Python/iscygpty.c (new) ## @@ @@ Python/iscygpty.c (new) ## Python/pylifecycle.c ## @@ - #include "pycore_sysmodule.h" // _PySys_ClearAuditHooks() - #include "pycore_traceback.h" // _Py_DumpTracebackThreads() + + extern void _PyIO_Fini(void); +#include "iscygpty.h" #include // setlocale() + #include // getenv() - #if defined(__APPLE__) @@ Python/pylifecycle.c: Py_Exit(int sts) int Py_FdIsInteractive(FILE *fp, const char *filename) 60: f933521881 ! 49: a734f13ff3 disable broken gdbm module @@ Commit message Co-authored-by: Алексей ## setup.py ## -@@ setup.py: class db_found(Exception): pass +@@ setup.py: def detect_dbm_gdbm(self): if dbm_args: dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":") else: -- dbm_order = "ndbm:gdbm:bdb".split(":") +- dbm_order = "gdbm:ndbm:bdb".split(":") + dbm_order = [] dbmext = None for cand in dbm_order: 61: 7460c75cb8 ! 50: 080fc0e465 build: link win resource files and build pythonw @@ Makefile.pre.in: LIBOBJS= @LIBOBJS@ BUILDPYTHON= python$(BUILDEXE) +BUILDPYTHONW= pythonw$(BUILDEXE) - PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@ - UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/update_file.py -@@ Makefile.pre.in: DTRACE_DEPS = \ + HOSTRUNNER= @HOSTRUNNER@ + +@@ Makefile.pre.in: LIBEXPAT_HEADERS= \ # Default target all: @DEF_MAKE_ALL_RULE@ --build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \ -+build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) oldsharedmods sharedmods gdbhooks \ - Programs/_testembed python-config +-build_all: check-clean-src $(BUILDPYTHON) platform oldsharedmods sharedmods \ ++build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) platform oldsharedmods sharedmods \ + gdbhooks Programs/_testembed python-config + build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config - # Check that the source is clean when building out of source. -@@ Makefile.pre.in: coverage-report: regen-token regen-importlib +@@ Makefile.pre.in: coverage-report: regen-token regen-frozen clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir) @@ Makefile.pre.in: coverage-report: regen-token regen-importlib + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -mwindows -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) pythonw_exe.o + # Build the interpreter --$(BUILDPYTHON): Programs/python.o $(LIBRARY_DEPS) -- $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) -+$(BUILDPYTHON): Programs/python.o $(LIBRARY_DEPS) python_exe.o -+ $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) python_exe.o +-$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) +- $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) ++$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) python_exe.o ++ $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) - platform: $(BUILDPYTHON) pybuilddir.txt + platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform @@ Makefile.pre.in: $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \ @@ Makefile.pre.in: altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@ fi ## configure.ac ## -@@ configure.ac: fi - - AC_MSG_RESULT($LDLIBRARY) +@@ configure.ac: AC_SUBST(LINK_PYTHON_OBJS) + AC_SUBST(AR) + AC_CHECK_TOOLS(AR, ar aal, ar) ++# windres program +AC_SUBST(WINDRES) +AC_CHECK_TOOL(WINDRES, windres) + - AC_SUBST(AR) - AC_CHECK_TOOLS(AR, ar aal, ar) - + # tweak ARFLAGS only if the user didn't set it on the command line + AC_SUBST(ARFLAGS) + if test -z "$ARFLAGS" @@ configure.ac: AC_MSG_RESULT(done) case $host in *-*-mingw*) @@ configure.ac: AC_MSG_RESULT(done) +AC_SUBST(RCFLAGS) # Availability of -O2: - AC_MSG_CHECKING(for -O2) + AC_CACHE_CHECK([for -O2], [ac_cv_compile_o2], [ 62: 00e1f15b04 ! 51: 626f21d9f8 disable readline @@ setup.py: def detect_readline_curses(self): + if MS_WINDOWS: + do_readline = False if do_readline: - if MACOS and os_release < 9: - # In every directory on the search path search for a dynamic + readline_libs = [readline_lib] + if readline_termcap_library: 63: ffe1f25bce = 52: ffa8d22b99 fix isselectable 64: 93e97923a6 < -: ---------- use _wcsnicmp instead wcsncasecmp 65: e614c16cea = 53: 7b5077237e _xxsubinterpretersmodule 66: d80d623487 < -: ---------- sqlite3 module defines 67: fbc96b88d9 < -: ---------- configure.ac: fix inet_pton check -: ---------- > 54: 35820c6fa9 configure.ac: fix inet_pton check 68: ed3d4bf145 = 55: 3911cdb239 set venv activate path unix 70: 84f5ea186a = 56: 59d2dd8a18 pass gen profile ldflags 71: 9b18c99955 = 57: f2f33f742e pkg config windows must link ext with python lib 72: 7057bb9834 = 58: fb2c377400 importlib bootstrap path sep 73: aef08bc77a = 59: 987b7bba45 pathlib path sep 74: d1b111995e = 60: 604d57841c warnings fixes -: ---------- > 61: ad7dc5e9a9 fix build testinternalcapi 76: 6ba8193eea = 62: a4fb99bdf5 extend MS_WINDOWS flag 77: 3a227bdc63 = 63: fe6cbd8c71 clang arm64 78: 8be8de0cec = 64: 8282fe53ee configure.ac: set MINGW stack reserve 79: fee05fafa0 = 65: d7aca52edc Don't use os.pathsep to find EOF not all distributions in win32 have them as \ instead check using sys.platform 80: 4575f2e838 ! 66: 633ba3ba72 Fix extension suffix for c-extensions on mingw @@ Makefile.pre.in: Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile -o $@ $(srcdir)/Python/dynload_win.c Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydtrace.h -@@ Makefile.pre.in: libainstall: @DEF_MAKE_RULE@ python-config +@@ Makefile.pre.in: libainstall: all python-config @if test "$(STATIC_LIBPYTHON)" = 1; then \ if test -d $(LIBRARY); then :; else \ if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ 81: 43ac8eaddb ! 67: f3d1230159 Change the `get_platform()` method in sysconfig @@ ## Metadata ## -Author: Christoph Reiter +Author: Naveen M K ## Commit message ## Change the `get_platform()` method in sysconfig 82: 840b8c0e98 = 68: 7664541c92 distutils: compiler customize mingw cygwin compilers 83: 3e5a6302e1 = 69: 5d2782a329 distutils: compiler enable new dtags 84: 29141b0759 = 70: 91c76e2e53 distutils: MINGW build extensions with GCC 85: 47bde10bc5 = 71: 0ec2aebef1 distutils: use Mingw32CCompiler as default compiler for m 86: d7835d1b00 = 72: c2052689c8 distutils: find import library 87: cdda401919 = 73: 5196e14bc2 distutils: avoid circular dependency from time module dur 88: 54beecc3bb = 74: c8d516dd73 distutils: generalization of posix build in distutils sys 89: f23ec20579 = 75: dee7401c23 distutils: mingw sysconfig like posix 90: 1e7ce827c0 = 76: e28bc7414e distutils: get_versions() fixes 91: d6b3313446 = 77: 91efed755d distutils: install layout as posix 92: c2669a543d = 78: 7e74bc348c distutils: msys convert_path fix and root hack 93: b74663a551 = 79: 6c9975c44e distutils: mingw build optimized ext 94: 020773256d = 80: 2c3fccbd3d distutils: cygwinccompiler dont strip modules if pydebug 95: 9b75c544d0 = 81: a3dd644711 distutils: get compilers from env vars 96: 5cfa547fa7 = 82: 8bbefc5f8d distutils: add windmc to cygwinccompiler 97: bfe9a098fd = 83: 48edc73032 distutils: fix msvc9 import 98: e56d3e1e01 = 84: 01d5c576db distutils: mingw add LIBPL to library dirs 99: 8151b92434 ! 85: 37b419a776 distutils: Change the `get_platform()` method in distutils to match sysconfig @@ ## Metadata ## -Author: Christoph Reiter +Author: Naveen M K ## Commit message ## distutils: Change the `get_platform()` method in distutils to match sysconfig 100: 78554fc1f4 = 86: 89f606eb59 build: Fix ncursesw include lookup 101: 0798715ad9 = 87: 856eb34ebb tests: fix test_bytes 102: 392ea4c2c3 ! 88: 90a3f05a39 time: fix strftime not raising for invalid year values @@ Commit message This fixes a test case in test_time ## Modules/timemodule.c ## -@@ Modules/timemodule.c: time_strftime(PyObject *self, PyObject *args) +@@ Modules/timemodule.c: time_strftime(PyObject *module, PyObject *args) return NULL; } 103: 953e31bcc2 = 89: aec5e8c51e ctypes: find_library('c') should return None with ucrt 104: 537206b0fd ! 90: 19eb37a2d7 build: Disable checks for dlopen/dlfcn @@ Commit message checks for it. ## configure.ac ## -@@ configure.ac: dnl AC_MSG_RESULT($cpp_type) +@@ configure.ac: AC_DEFINE(STDC_HEADERS, 1, [Define to 1 if you have the ANSI C header files.]) # checks for header files - AC_HEADER_STDC --AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \ -+AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h errno.h \ - fcntl.h grp.h \ - ieeefp.h io.h langinfo.h libintl.h process.h \ - shadow.h signal.h stropts.h termios.h \ -@@ configure.ac: libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ - linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \ - sys/endian.h sys/sysmacros.h linux/auxvec.h sys/auxv.h linux/memfd.h linux/wait.h sys/memfd.h \ - sys/mman.h sys/eventfd.h) + AC_CHECK_HEADERS([ \ +- alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \ ++ alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h endian.h errno.h fcntl.h grp.h \ + ieeefp.h io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/memfd.h \ + linux/random.h linux/soundcard.h \ + linux/tipc.h linux/wait.h netdb.h netinet/in.h netpacket/packet.h poll.h process.h pty.h \ +@@ configure.ac: AC_CHECK_HEADERS([ \ + sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h sys/xattr.h sysexits.h syslog.h \ + termios.h util.h utime.h utmp.h \ + ]) + +case $host in + *-*-mingw*) ;; + *) AC_CHECK_HEADERS([dlfcn.h]);; +esac ++ + AC_HEADER_DIRENT AC_HEADER_MAJOR @@ configure.ac: AC_MSG_RESULT($SHLIBS) + AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX - # checks for uuid.h location -@@ configure.ac: then - [define to 1 if your sem_getvalue is broken.]) - fi + +@@ configure.ac: AS_VAR_IF([ac_cv_broken_sem_getvalue], [yes], [ + ) + ]) -AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND, RTLD_MEMBER], [], [], [[#include ]]) +case $host in 105: c4f7f2df7c ! 91: 405991fba9 Fix install location of the import library @@ Commit message Fix install location of the import library ## Makefile.pre.in ## -@@ Makefile.pre.in: libainstall: @DEF_MAKE_RULE@ python-config +@@ Makefile.pre.in: libainstall: all python-config if test -d $(LIBRARY); then :; else \ if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ if test "$(SHLIB_SUFFIX)" = .dll -o "$(SHLIB_SUFFIX)" = .pyd; then \ 106: 00e8abc982 ! 92: 718650f3af Set MSYS2_ARG_CONV_EXCL for the shared Python module install @@ Makefile.pre.in @@ Makefile.pre.in: endif # Install the dynamically loadable modules # This goes into $(exec_prefix) - sharedinstall: sharedmods + sharedinstall: all + MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \ $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \ --prefix=$(prefix) \ 107: b9fc13084d ! 93: 062a2ee7e1 build: Integrate venvlauncher build/installation into the Makefile @@ Makefile.pre.in: LIBOBJS= @LIBOBJS@ +BUILDVENVLAUNCHER= venvlauncher$(BUILDEXE) +BUILDVENVWLAUNCHER= venvwlauncher$(BUILDEXE) - PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@ - UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/update_file.py -@@ Makefile.pre.in: DTRACE_DEPS = \ + HOSTRUNNER= @HOSTRUNNER@ + +@@ Makefile.pre.in: LIBEXPAT_HEADERS= \ # Default target all: @DEF_MAKE_ALL_RULE@ --build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) oldsharedmods sharedmods gdbhooks \ -+build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) $(BUILDVENVLAUNCHER) $(BUILDVENVWLAUNCHER) oldsharedmods sharedmods gdbhooks \ - Programs/_testembed python-config +-build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) platform oldsharedmods sharedmods \ ++build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) $(BUILDVENVLAUNCHER) $(BUILDVENVWLAUNCHER) platform oldsharedmods sharedmods \ + gdbhooks Programs/_testembed python-config + build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config - # Check that the source is clean when building out of source. @@ Makefile.pre.in: $(BUILDPYTHONW): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) pythonw - $(BUILDPYTHON): Programs/python.o $(LIBRARY_DEPS) python_exe.o - $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) python_exe.o + $(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) python_exe.o + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) +# FIXME: build these from PC/launcher.c instead +$(BUILDVENVLAUNCHER): $(BUILDPYTHON) @@ Makefile.pre.in: $(BUILDPYTHONW): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY +$(BUILDVENVWLAUNCHER): $(BUILDPYTHONW) + cp $(BUILDPYTHONW) $(BUILDVENVWLAUNCHER) + - platform: $(BUILDPYTHON) pybuilddir.txt + platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform @@ Makefile.pre.in: $(DESTSHARED): -: ---------- > 94: 2075377da8 configure.ac: set _WIN32_WINNT version 109: ece28e1dbd ! 95: 22e70a8b4f configure.ac: don't check for clock_ functions @@ Commit message They shouldn't be exposed on Windows and lead to winpthread being linked in ## configure.ac ## -@@ configure.ac: char *r = crypt_r("", "", &d); - []) - ) +@@ configure.ac: WITH_SAVE_ENV([ + ]) + ]) +case $host in + *-*-mingw*) ;; @@ configure.ac: AC_CHECK_FUNCS(clock_settime, [], [ + ;; +esac - AC_MSG_CHECKING(for major, minor, and makedev) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + AC_CHECK_FUNCS(clock_nanosleep, [], [ + AC_CHECK_LIB(rt, clock_nanosleep, [ 110: 0300bbf9e8 = 96: 89d2cfe158 expanduser: normpath paths coming from env vars 112: a9e29de0e0 ! 97: 82688c857d CI: test the build and add some mingw specific tests @@ Metadata ## Commit message ## CI: test the build and add some mingw specific tests + - Use actions/setup-python for setting up correct version in cross build + - CI: add cross llvm-mingw jobs + - CI: fix sed pattern for python-config.py shebang + The shebang (`#!`) does not include `${pkgdir}` so this sed did nothing + - CI: remove --without-c-locale-coercion + No longer needed since the default now works on Windows + - Make sure we always use the stdlib distutils + - CI: update actions and images + ubuntu-18.04 is gone now + - CI: updates for mstorsjo/llvm-mingw moving to 20.04 + - CI: 3.10 -> 3.11 + ## .github/workflows/mingw.yml (new) ## @@ +name: Build @@ .github/workflows/mingw.yml (new) + strategy: + fail-fast: false + matrix: -+ msystem: ['MINGW64','MINGW32','UCRT64','CLANG64'] ++ msystem: ['MINGW64','MINGW32','UCRT64','CLANG64','CLANG32'] + include: + - msystem: MINGW64 + prefix: mingw-w64-x86_64 @@ .github/workflows/mingw.yml (new) + prefix: mingw-w64-ucrt-x86_64 + - msystem: CLANG64 + prefix: mingw-w64-clang-x86_64 -+ #- msystem: CLANG32 -+ # prefix: mingw-w64-clang-i686 ++ - msystem: CLANG32 ++ prefix: mingw-w64-clang-i686 + steps: + - name: Setup git + run: | + git config --global core.autocrlf false + git config --global core.eol lf -+ - uses: actions/checkout@v2 ++ - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.msystem }} @@ .github/workflows/mingw.yml (new) + run: | + set -ex + -+ if [ ${{ matrix.msystem }} == "CLANG64" ] -+ then ++ if [[ "${{ matrix.msystem }}" == "CLANG64" ]] || [[ "${{ matrix.msystem }}" == "CLANG32" ]]; then + export CC=clang + export CXX=clang++ + fi @@ .github/workflows/mingw.yml (new) + --with-system-ffi \ + --with-system-libmpdec \ + --without-ensurepip \ -+ --without-c-locale-coercion \ + --enable-loadable-sqlite-extensions \ + --with-tzpath=${MINGW_PREFIX}/share/zoneinfo \ + --enable-optimizations @@ .github/workflows/mingw.yml (new) + - name: Run Smoke Test (build) + shell: msys2 {0} + run: | ++ export SETUPTOOLS_USE_DISTUTILS=stdlib + SMOKETESTS="$(pwd)/mingw_smoketests.py" + cd _build + ./python.exe "$SMOKETESTS" @@ .github/workflows/mingw.yml (new) + - name: Run tests + shell: msys2 {0} + run: | ++ export SETUPTOOLS_USE_DISTUTILS=stdlib + IGNOREFILE="$(pwd)/mingw_ignorefile.txt" + cd _build + MSYSTEM= ./python.exe -m test -j8 --ignorefile "$IGNOREFILE" -W @@ .github/workflows/mingw.yml (new) + continue-on-error: true + shell: msys2 {0} + run: | ++ export SETUPTOOLS_USE_DISTUTILS=stdlib + IGNOREFILE="$(pwd)/mingw_ignorefile.txt" + cd _build + MSYSTEM= ./python.exe -m test -j8 --matchfile "$IGNOREFILE" -W @@ .github/workflows/mingw.yml (new) + for fscripts in 2to3 2to3-${_pybasever} idle3 idle${_pybasever} pydoc3 pydoc${_pybasever}; do + sed -i "s|$(cygpath -w ${MINGW_PREFIX} | sed 's|\\|\\\\|g')/bin/python${_pybasever}.exe|/usr/bin/env python${_pybasever}.exe|g" "${pkgdir}${MINGW_PREFIX}"/bin/${fscripts} + done -+ sed -i "s|#!${pkgdir}${MINGW_PREFIX}/bin/python${_pybasever}.exe|#!/usr/bin/env python${_pybasever}.exe|" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${_pybasever}/python-config.py ++ sed -i "s|#!${MINGW_PREFIX}/bin/python${_pybasever}.exe|#!/usr/bin/env python${_pybasever}.exe|" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${_pybasever}/python-config.py + + # Create version-less aliases + cp "${pkgdir}${MINGW_PREFIX}"/bin/python3.exe "${pkgdir}${MINGW_PREFIX}"/bin/python.exe @@ .github/workflows/mingw.yml (new) + - name: Run Smoke Test (installed) + shell: msys2 {0} + run: | ++ export SETUPTOOLS_USE_DISTUTILS=stdlib + export PYTHONTZPATH="${MINGW_PREFIX}/share/zoneinfo" + SMOKETESTS="$(pwd)/mingw_smoketests.py" + cd _build @@ .github/workflows/mingw.yml (new) + tar -zcf python.tar.gz python_pkgdir/ + + - name: Upload -+ uses: actions/upload-artifact@v2 ++ uses: actions/upload-artifact@v3 + if: always() + with: + name: build-${{ matrix.msystem }} + path: _build/python.tar.gz + -+ cross: ++ cross-gcc-x86_64: + runs-on: ubuntu-latest + container: + image: archlinux:base-devel + steps: -+ - uses: actions/checkout@v2 ++ - uses: actions/checkout@v3 + - name: Install deps + run: | + pacman --noconfirm -Suuy -+ pacman --needed --noconfirm -S mingw-w64-gcc autoconf-archive autoconf automake python zip ++ pacman --needed --noconfirm -S mingw-w64-gcc autoconf-archive autoconf automake zip ++ ++ - uses: actions/setup-python@v4 ++ with: ++ python-version: '3.11' ++ ++ - name: Check Python Version ++ run: | ++ which python ++ python --version + + - name: Build + run: | @@ .github/workflows/mingw.yml (new) + --with-system-ffi \ + --with-system-libmpdec \ + --without-ensurepip \ ++ --enable-loadable-sqlite-extensions \ ++ --with-build-python=python3.11 ++ ++ make -j8 ++ ++ make install DESTDIR="$(pwd)/install" ++ ++ - name: 'Zip files' ++ run: | ++ zip -r install.zip _build/install ++ ++ - name: Upload ++ uses: actions/upload-artifact@v3 ++ with: ++ name: build-cross-gcc-x86_64 ++ path: install.zip ++ ++ cross-gcc-x86_64-test: ++ needs: [cross-gcc-x86_64] ++ runs-on: windows-latest ++ steps: ++ - uses: actions/download-artifact@v3 ++ with: ++ name: build-cross-gcc-x86_64 ++ ++ - name: 'Run tests' ++ run: | ++ 7z x install.zip ++ ./_build/install/usr/local/bin/python3.exe -c "import sysconfig, pprint; pprint.pprint(sysconfig.get_config_vars())" ++ ++ ++ cross-llvm-mingw: ++ runs-on: ubuntu-latest ++ container: ++ image: mstorsjo/llvm-mingw:latest ++ strategy: ++ fail-fast: false ++ matrix: ++ arch: ['x86_64', 'i686', 'aarch64', 'armv7'] ++ steps: ++ - uses: actions/checkout@v3 ++ ++ - name: Install deps ++ run: | ++ export DEBIAN_FRONTEND=noninteractive ++ apt-get update -qq ++ apt-get install -qqy software-properties-common ++ add-apt-repository --yes ppa:deadsnakes/ppa ++ apt-get update -qq ++ apt-get install -qqy autoconf-archive python3.11-dev python3.11 ++ ++ - name: Build ++ run: | ++ autoreconf -vfi ++ ++ mkdir _build && cd _build ++ ++ export CC=${{ matrix.arch }}-w64-mingw32-clang ++ export CXX=${CC}++ ++ ../configure \ ++ --host=${{ matrix.arch }}-w64-mingw32 \ ++ --build=x86_64-pc-linux-gnu \ ++ --enable-shared \ ++ --with-system-expat \ ++ --with-system-ffi \ ++ --with-system-libmpdec \ ++ --without-ensurepip \ + --without-c-locale-coercion \ -+ --enable-loadable-sqlite-extensions ++ --enable-loadable-sqlite-extensions \ ++ --with-build-python=python3.11 + + make -j8 + @@ .github/workflows/mingw.yml (new) + zip -r install.zip _build/install + + - name: Upload -+ uses: actions/upload-artifact@v2 ++ uses: actions/upload-artifact@v3 + with: -+ name: build-cross ++ name: build-cross-llvm-mingw-${{ matrix.arch }} + path: install.zip + -+ cross-test: -+ needs: [cross] ++ cross-llvm-mingw-test: ++ needs: [cross-llvm-mingw] + runs-on: windows-latest ++ strategy: ++ fail-fast: false ++ matrix: ++ arch: ['x86_64', 'i686'] + steps: -+ - uses: actions/download-artifact@v2 ++ - uses: actions/download-artifact@v3 + with: -+ name: build-cross ++ name: build-cross-llvm-mingw-${{ matrix.arch }} + + - name: 'Run tests' + run: | + 7z x install.zip + ./_build/install/usr/local/bin/python3.exe -c "import sysconfig, pprint; pprint.pprint(sysconfig.get_config_vars())" ++ ++ ## mingw_ignorefile.txt (new) ## @@ @@ mingw_smoketests.py (new) + import ctypes + import curses + ++ def test_c_modules_import(self): ++ import _decimal ++ + def test_socket_inet_ntop(self): + import socket + self.assertTrue(hasattr(socket, "inet_ntop")) 114: 46ab1564c6 = 98: be93765647 Prefer sysconfig.python_build 115: 4d2ccf68c9 = 99: c93a2cea60 Define PY3_DLLNAME to fix build 116: 17987e303f = 100: 1f016b6a9a distutils: remove checks for ancient gcc/binutils 117: 32b01059e7 = 101: 67ad65ee95 distutils: split CC env var before passing to subprocess 118: 5215472edb ! 102: e8d06b3253 _testconsole.c: Fix casing & path sep @@ Commit message ## PC/_testconsole.c ## @@ - #ifdef MS_WINDOWS + #include "pycore_fileutils.h" // _Py_get_osfhandle() -#include "..\modules\_io\_iomodule.h" +#include "../Modules/_io/_iomodule.h" 119: c4d2047791 = 103: 8b57aa8de3 Return consistent architecture markers for python on mingw/armv7 120: 4b2a83c3cb = 104: f0f29469c4 distutils: add back gcc_version 121: cb8338aa55 = 105: 806f94087d fix mingw cross compiling in setup.py 123: 62d64910c5 = 106: 7164fd80cd handle ncursesw pkg-config when cross-compiling 125: 8b99744966 = 107: e179c0a256 mingw_smoketests: fix _UCRT condition 127: 69e877ffd3 = 108: 0aa751563a Modify `sys.winver` to match upstream 128: 8ab1ceda96 ! 109: 8ea9bb77c0 Change user site-packages path to include the environment info @@ Lib/sysconfig.py: def get_config_vars(*args): if os.name == 'nt' and not _POSIX_BUILD: _init_non_posix(_CONFIG_VARS) @@ Lib/sysconfig.py: def get_config_var(name): - warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning, 2) + """ return get_config_vars().get(name) - 129: ad81bebd95 = 110: fb0ccc3e75 configure: Include a header in the check for _beginthread 130: 013c9435e3 ! 111: fe4f061f55 configure.ac: Default to --without-c-locale-coercion on Windows @@ Commit message Fixes #36 ## configure.ac ## -@@ configure.ac: AC_MSG_RESULT($with_pymalloc) +@@ configure.ac: AC_MSG_RESULT($with_freelists) AC_MSG_CHECKING(for --with-c-locale-coercion) AC_ARG_WITH(c-locale-coercion, AS_HELP_STRING([--with-c-locale-coercion], 132: 4633979310 ! 112: 05436848f3 Fix failing tests @@ Commit message - Copy `get_platform()` from from distutils.utils to test_importlib/test_windows.py. - In `test_tcl`, ignore `test_tcl.TclTest.testLoadWithUNC` test failure. - Disable `test.test_asynchat.TestAsynchat.test_line_terminator2`, seems flaky. + - skip some more flaky tests + - some basic fixes for test_getpath + - test_sysconfig.py: fix tests related to mingw + + ## Lib/test/test_getpath.py ## +@@ Lib/test/test_getpath.py: def test_symlink_buildpath_macos(self): + ENV_PYTHONHOME="", + ENV_PYTHONEXECUTABLE="", + ENV___PYVENV_LAUNCHER__="", ++ ENV_MSYSTEM="", + argv0="", + py_setpath="", + real_executable="", +@@ Lib/test/test_getpath.py: def __init__(self, *a, argv0=None, config=None, **kw): + self.update(DEFAULT_NAMESPACE) + self["config"] = DEFAULT_CONFIG.copy() + self["os_name"] = "nt" ++ self["is_mingw"] = 0 + self["PLATLIBDIR"] = "DLLs" + self["PYWINVER"] = "9.8-XY" + self["VPATH"] = r"..\.." +@@ Lib/test/test_getpath.py: def __init__(self, *a, argv0=None, config=None, **kw): + self.update(DEFAULT_NAMESPACE) + self["config"] = DEFAULT_CONFIG.copy() + self["os_name"] = "posix" ++ self["is_mingw"] = 0 + self["PLATLIBDIR"] = "lib" + self["WITH_NEXT_FRAMEWORK"] = 0 + super().__init__(*a, **kw) ## Lib/test/test_importlib/test_windows.py ## @@ Lib/test/test_importlib/test_windows.py: def get_platform(): @@ Lib/test/test_importlib/test_windows.py: def get_platform(): os.environ['VSCMD_ARG_TGT_ARCH'] in TARGET_TO_PLAT): return TARGET_TO_PLAT[os.environ['VSCMD_ARG_TGT_ARCH']] + ## Lib/test/test_sysconfig.py ## +@@ + from sysconfig import (get_paths, get_platform, get_config_vars, + get_path, get_path_names, _INSTALL_SCHEMES, + get_default_scheme, get_scheme_names, get_config_var, +- _expand_vars, _get_preferred_schemes, _main) ++ _expand_vars, _get_preferred_schemes, _main, _POSIX_BUILD) + import _osx_support + + +@@ Lib/test/test_sysconfig.py: def test_nt_venv_scheme(self): + self.assertEqual(libpath, sysconfig.get_path('purelib', scheme='nt_venv')) + + def test_venv_scheme(self): +- if sys.platform == 'win32': ++ if not _POSIX_BUILD and sys.platform == 'win32': + self.assertEqual( + sysconfig.get_path('scripts', scheme='venv'), + sysconfig.get_path('scripts', scheme='nt_venv') +@@ Lib/test/test_sysconfig.py: def test_user_similar(self): + if HAS_USER_BASE: + user_path = get_path(name, 'posix_user') + expected = os.path.normpath(global_path.replace(base, user, 1)) ++ if os.name == 'nt' and _POSIX_BUILD: ++ expected = expected.replace( ++ f'python{sysconfig.get_python_version()}', ++ f'python{sysconfig.get_python_version()}-{get_platform()}') + # bpo-44860: platlib of posix_user doesn't use sys.platlibdir, + # whereas posix_prefix does. + if name == 'platlib': + ## mingw_ignorefile.txt ## @@ mingw_ignorefile.txt: test.test_strptime.TimeRETests.test_compile test.test_tools.test_i18n.Test_pygettext.test_POT_Creation_Date @@ mingw_ignorefile.txt: test.test_strptime.TimeRETests.test_compile \ No newline at end of file +test.test_asyncio.test_subprocess.SubprocessProactorTests.test_stdin_broken_pipe +test.test_asynchat.TestAsynchat.test_line_terminator2 -+ ++test.test_asyncgen.AsyncGenAsyncioTest.test_async_gen_asyncio_gc_aclose_09 ++test.test_concurrent_futures.ThreadPoolShutdownTest.test_interpreter_shutdown ++test.test_asynchat.TestNotConnected.test_disallow_negative_terminator ++test.test_logging.SysLogHandlerTest.* ++test.test_logging.IPv6SysLogHandlerTest.* 133: fd216c0718 = 113: c1dd082334 distutils: add build root to libdirs when building uninstalled 137: 22976e8877 ! 114: b80de39575 Don't change os.sep with an empty MSYSTEM env var, not just a missing one @@ Commit message not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. + Also, guard the msystem env check to execute only on MINGW + + Co-authored-by: Naveen M K + ## Lib/importlib/_bootstrap_external.py ## @@ else: @@ Lib/pathlib.py: class _WindowsFlavour(_Flavour): pathmod = ntpath ## Python/pathconfig.c ## +@@ + + #include "Python.h" + #include "marshal.h" // PyMarshal_ReadObjectFromString +-#include "osdefs.h" // DELIM ++#include "osdefs.h" // DELIM, SEP + #include "pycore_initconfig.h" + #include "pycore_fileutils.h" + #include "pycore_pathconfig.h" +@@ Python/pathconfig.c: Py_StartsWithW(const wchar_t * str, const wchar_t * prefix) + char + Py_GetSepA(const char *name) + { +- char* msystem = (char*)2; /* So that non Windows use / as sep */ + static char sep = '\0'; + #ifdef _WIN32 + /* https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx @@ Python/pathconfig.c: Py_GetSepA(const char *name) + if (sep != '\0') + return sep; #if defined(__MINGW32__) - msystem = Py_GETENV("MSYSTEM"); - #endif +- msystem = Py_GETENV("MSYSTEM"); +-#endif - if (msystem != NULL) ++ char* msystem = getenv("MSYSTEM"); + if (msystem != NULL && strcmp(msystem, "") != 0) sep = '/'; else sep = '\\'; +- return sep; ++#endif ++ return SEP; + } + + static char +@@ Python/pathconfig.c: Py_NormalizeSepsA(char *name) + wchar_t + Py_GetSepW(const wchar_t *name) + { +- char* msystem = (char*)2; /* So that non Windows use / as sep */ + static wchar_t sep = L'\0'; + #ifdef _WIN32 + /* https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx @@ Python/pathconfig.c: Py_GetSepW(const wchar_t *name) + if (sep != L'\0') + return sep; #if defined(__MINGW32__) - msystem = Py_GETENV("MSYSTEM"); - #endif +- msystem = Py_GETENV("MSYSTEM"); +-#endif - if (msystem != NULL) ++ char* msystem = getenv("MSYSTEM"); + if (msystem != NULL && strcmp(msystem, "") != 0) sep = L'/'; else sep = L'\\'; +- return sep; ++#endif ++ return SEP; + } + + static wchar_t ## mingw_smoketests.py ## @@ -: ---------- > 115: 9920569e92 def VPATH when compiling `Python/sysmodule.c` -: ---------- > 116: 29265c0c1a Make `_Py_CheckPython3` extern -: ---------- > 117: c12b3bf67d link with bcrypt -: ---------- > 118: 804dd901b4 correctly find native python -: ---------- > 119: ba77612999 Add extra flags for `_bootstrap_python` -: ---------- > 120: 6a0e436d0d posixmodule: undefine `HAVE_OPENDIR` -: ---------- > 121: a55b32f739 getpath.py: add support for mingw -: ---------- > 122: 330bd1ba1a Don't build _posixsubprocess on Windows. -: ---------- > 123: 7c60e778e7 `_ssl`: link with `ws2_32` -: ---------- > 124: 8a0162931f Fix building `_socket` module -: ---------- > 125: 860c886f92 Always normalize path in abspath -: ---------- > 126: f77cd7a588 Include `winsock.h` when checking for netdb function -: ---------- > 127: 031f4b2b55 include `_multiprocessing/semaphore.c` on win32 -: ---------- > 128: 14ff11e80c configure: build `mmap` module on win32 69: c009f2d39d ! 129: 8c7394c06e venv creation fixes @@ ## Metadata ## -Author: Christoph Reiter +Author: Naveen M K ## Commit message ## venv creation fixes - Co-authored-by: Naveen M K - ## Lib/venv/__init__.py ## @@ import sys import sysconfig import types +- +from sysconfig import _POSIX_BUILD - CORE_VENV_DEPS = ('pip', 'setuptools') -@@ Lib/venv/__init__.py: def create_if_needed(d): - context.executable = executable - context.python_dir = dirname - context.python_exe = exename -- if sys.platform == 'win32': -+ if sys.platform == 'win32' and not _POSIX_BUILD: - binname = 'Scripts' - incpath = 'Include' - libpath = os.path.join(env_dir, 'Lib', 'site-packages') + logger = logging.getLogger(__name__) @@ Lib/venv/__init__.py: def setup_python(self, context): if not os.path.islink(path): os.chmod(path, 0o755) @@ Lib/venv/__init__.py: def setup_python(self, context): if os.path.lexists(src): copier(src, os.path.join(binpath, suffix)) -- if sysconfig.is_python_build(True): + if _POSIX_BUILD: + # copy from python/pythonw so the venvlauncher magic in symlink_or_copy triggers + copier(os.path.join(dirname, 'python.exe'), os.path.join(binpath, 'python3.exe')) + copier(os.path.join(dirname, 'python.exe'), os.path.join(binpath, 'python%d.%d.exe' % sys.version_info[:2])) + copier(os.path.join(dirname, 'pythonw.exe'), os.path.join(binpath, 'python3w.exe')) + -+ if sysconfig.is_python_build(True) and not _POSIX_BUILD: + if sysconfig.is_python_build(): # copy init.tcl for root, dirs, files in os.walk(context.python_dir): - if 'init.tcl' in files: @@ Lib/venv/__init__.py: def _call_new_python(self, context, *py_args, **kwargs): env['VIRTUAL_ENV'] = context.env_dir env.pop('PYTHONHOME', None) 75: 5af9ca70f2 < -: ---------- fix build testinternalcapi 108: 3526e528a9 < -: ---------- configure.ac: set _WIN32_WINNT version 111: 23f4fde52f < -: ---------- Add support for Windows 7 Python 3.10 113: 879b6c753d < -: ---------- smoketests: test that _decimal exists 122: ae4a5bc934 < -: ---------- Use actions/setup-python for setting up correct version in cross build 124: 39b6735886 < -: ---------- CI: add cross llvm-mingw jobs 126: dd209ffeea < -: ---------- CI: fix sed pattern for python-config.py shebang 131: 0a7a496d03 < -: ---------- CI: remove --without-c-locale-coercion 134: 914804a2c8 < -: ---------- Avoid some macros only available in >Win7 135: 4a01d33868 < -: ---------- Make sure we always use the stdlib distutils 136: 35f8ebf958 < -: ---------- CI: skip some more flaky tests 138: 9d95e4e3d8 < -: ---------- Commit regenerated importlib 139: f1755b7944 < -: ---------- CI: update actions and images 140: 8689dde278 < -: ---------- configure: require autoreconf to be run first 141: 3f5fc0093e < -: ---------- CI: updates for mstorsjo/llvm-mingw moving to 20.04 142: d3fd6a9012 < -: ---------- tests: fix invalid escape sequence 143: 8ea5be64f2 < -: ---------- CI: set winjitdebug -: ---------- > 130: 8b031a676b move the `shutdown` function where `winsock.h` is included -: ---------- > 131: 1f56311c10 configure.ac: set BUILDEXEEXT and EXEEXT -: ---------- > 132: dab10831dd configure.ac: fix building some test modules -: ---------- > 133: f78da82800 Don't convert `sysconfig.get_config_var('VPATH')` to an absolute path -: ---------- > 134: fffe79ce23 Always convert `/` to `\\` before passing though pathcch functions -: ---------- > 135: b252ec63db Build venvlauncher.exe from PC/launcher.c -: ---------- > 136: aefea16d4f getpath.py: fix `dirname` ```
naveen521kk commented 1 year ago

Locally the smoke tests successfully passed:

mintty_SQP36493hE

jeremyd2019 commented 1 year ago

It looks like you need some newer updates from 3.10 branches, at least f1755b79446155ce23a8f2f9f810b08cbeea9d2a and 3f5fc0093ec9d26a78df331129f56cc849313673 to allow the cross-llvm-mingw jobs to run.

naveen521kk commented 1 year ago

It looks like you need some newer updates from 3.10 branches, at least https://github.com/msys2-contrib/cpython-mingw/commit/f1755b79446155ce23a8f2f9f810b08cbeea9d2a and https://github.com/msys2-contrib/cpython-mingw/commit/3f5fc0093ec9d26a78df331129f56cc849313673 to allow the cross-llvm-mingw jobs to run.

Thanks, will cherry-pick and squash it. Also, I don't they will succeed since it requires a "build python" for cross-compiling now https://docs.python.org/3/using/configure.html#cross-compiling-options.

edit: will squash later, probably all the CI config into a single commit

jeremyd2019 commented 1 year ago

Also, I don't they will succeed since it requires a "build python" for cross-compiling now https://docs.python.org/3/using/configure.html#cross-compiling-options.

I think there is already provision for providing a compatible python version for the build system (the deadsnakes ppa thing), it'd probably just need to add the configure option.

jeremyd2019 commented 1 year ago

hopefully we won't need to set winjitdebug anymore, @lazka's testing showed 3.11 didn't have that mystery issue

jeremyd2019 commented 1 year ago

https://gist.github.com/naveen521kk/19d01c3841a98bd7890aaaa94f6657b2

Once it is ready for review, would a range-diff against the latest 3.10 branch be helpful here (like on msys2-runtime updates), or would there be too much 'noise' from Setup-related moves?

naveen521kk commented 1 year ago

Once it is ready for review, would a range-diff against the latest 3.10 branch be helpful here (like on msys2-runtime updates), or would there be too much 'noise' from Setup-related moves?

I've updated the description with range-diff. The setup-related move could have added some 'noise', but it should be readable ig. I'll also update it when I make any changes here.

jeremyd2019 commented 1 year ago
   @@ mingw_smoketests.py (new)
    +                                    helloworld(PyObject *self, PyObject *args)
    +                                    {
    +                                        printf("Hello World\\n");
   -+                                        Py_RETURN_NONE;
   ++                                        return Py_None;
    +                                    }
    +                                    static PyMethodDef
    +                                    myMethods[] = {

I think this was a fix that got reverted? (specifically https://github.com/msys2-contrib/cpython-mingw/pull/130)

naveen521kk commented 1 year ago

I think this was a fix that got reverted? (specifically https://github.com/msys2-contrib/cpython-mingw/pull/130)

It wasn't reverted, I started working on this before that commit and missed cherry-picking it. Thanks, will cherry-pick now!

naveen521kk commented 1 year ago

I think most of the work here is done, I've also updated the description with the range-diff.

lazka commented 1 year ago

venvs are broken for the installed version at least (which is a bit of a blocker):

$ python3.11 -m venv _foooo2
Error: Command '['C:/msys64/home/user/_foooo2/bin/python3.11.exe', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
$ C:/msys64/home/user/_foooo2/bin/python3.11.exe
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'C:\msys64\home\user\_foooo2\bin\python3.11.exe'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = 'D:/M/msys64/ucrt64/lib/python3.11'
  sys._base_executable = 'C:/msys64/home/user/_foooo2/bin/python3.11.exe'
  sys.base_prefix = 'D:/M/msys64/ucrt64'
  sys.base_exec_prefix = 'D:/M/msys64/ucrt64'
  sys.platlibdir = 'lib'
  sys.executable = 'C:/msys64/home/user/_foooo2/bin/python3.11.exe'
  sys.prefix = 'D:/M/msys64/ucrt64'
  sys.exec_prefix = 'D:/M/msys64/ucrt64'
  sys.path = [
    'D:/M/msys64/ucrt64/lib/python311.zip',
    'D:/M/msys64/ucrt64/lib/python3.11',
    'D:/M/msys64/ucrt64/lib/python3.11/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00004124 (most recent call first):
  <no Python frame>
lazka commented 1 year ago

hopefully we won't need to set winjitdebug anymore, @lazka's testing showed 3.11 didn't have that mystery issue

@jeremyd2019 I can confirm that the meson crashes are gone with this update: https://github.com/lazka/python-crash-test/actions/runs/5368625876

naveen521kk commented 1 year ago

venvs are broken for the installed version at least (which is a bit of a blocker):

I think bringing back https://github.com/msys2-contrib/cpython-mingw/issues/90 would be a simple way to fix this issue. I'll have a look.

naveen521kk commented 1 year ago

venvs are broken for the installed version at least (which is a bit of a blocker):

This should be fixed now, I've made https://github.com/msys2/MINGW-packages/pull/17644

lazka commented 1 year ago

fyi, I tried to rebase on top of 3.11.4: there are no conflicts, but https://github.com/python/cpython/commit/09ce8c3b48f940eb8865330f029b8069854c3106 is needed to make the tests pass. maybe it helps.

naveen521kk commented 1 year ago

I'll merge this and then work on 3.11.4 on a new PR.