# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Maintainer: Ray Donnelly <mingw.android@gmail.com>
# Contributor: Saul Ibarra Corretge <saghul@gmail.com>
# Contributor: Frode Solheim <frode@fs-uae.net>

# TODO :: subprocess.Popen .. specifically list2cmdline in subprocess.py
#         needs a fix so it can handle running MSYS2 executables better.
#         Arguments should not be quoted in the Windows fashion as-per:
#         http://www.daviddeley.com/autohotkey/parameters/parameters.htm
#         but instead how Cygwin expects them to be quoted. Checking for
#         {cygwin,msys-2.0}.dll in the executable is the only way that I
#         can think to do this at present.
#         Any double quoted string will cause problems, e.g.
#         -DGNOMELOCALEDIR=\"/mingw64/share/locale\"

_primary_python="no"
_pybasever=3.9
_realname=python

if [[ "${_primary_python}" == "yes" ]]; then
  pkgbase="mingw-w64-${_realname}"
  pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
  provides=("${MINGW_PACKAGE_PREFIX}-python3=${pkgver}")
  conflicts=("${MINGW_PACKAGE_PREFIX}-python3"
            "${MINGW_PACKAGE_PREFIX}-python2<2.7.16-7")
  replaces=("${MINGW_PACKAGE_PREFIX}-python3")
else
  pkgbase="mingw-w64-${_realname}${_pybasever}"
  pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}${_pybasever}")
fi
pkgver=${_pybasever}.6
pkgrel=3
pkgdesc="A high-level scripting language (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
license=('PSF')
url="https://www.python.org/"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-expat"
         "${MINGW_PACKAGE_PREFIX}-bzip2"
         "${MINGW_PACKAGE_PREFIX}-libffi"
         "${MINGW_PACKAGE_PREFIX}-mpdecimal"
         "${MINGW_PACKAGE_PREFIX}-ncurses"
         "${MINGW_PACKAGE_PREFIX}-openssl"
         "${MINGW_PACKAGE_PREFIX}-sqlite3"
         "${MINGW_PACKAGE_PREFIX}-tcl"
         "${MINGW_PACKAGE_PREFIX}-tk"
         "${MINGW_PACKAGE_PREFIX}-zlib"
         "${MINGW_PACKAGE_PREFIX}-xz")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-gcc"
  "${MINGW_PACKAGE_PREFIX}-pkg-config"
  "autoconf-archive"
)
options=('makeflags') # 'debug' '!strip')
source=("https://www.python.org/ftp/python/${pkgver%rc?}/Python-${pkgver}.tar.xz"
        "smoketests.py"
        0001-make-_sysconfigdata.py-relocatable.patch
        0002-restore-setup-config.patch
        0003-MINGW-BASE-use-NT-thread-model.patch
        0004-MINGW-translate-gcc-internal-defines-to-python-platf.patch
        0005-MINGW-configure-MACHDEP-and-platform-for-build.patch
        0006-MINGW-preset-configure-defaults.patch
        0007-MINGW-configure-largefile-support-for-windows-builds.patch
        0008-MINGW-add-srcdir-PC-to-CPPFLAGS.patch
        0009-MINGW-init-system-calls.patch
        0010-MINGW-build-in-windows-modules-winreg.patch
        0011-MINGW-determine-if-pwdmodule-should-be-used.patch
        0012-MINGW-compiler-customize-mingw-cygwin-compilers.patch
        0013-MINGW-compiler-enable-new-dtags.patch
        0014-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch
        0015-MINGW-configure-for-shared-build.patch
        0016-MINGW-dynamic-loading-support.patch
        0017-MINGW-ignore-main-program-for-frozen-scripts.patch
        0018-MINGW-setup-_multiprocessing-module.patch
        0019-MINGW-setup-select-module.patch
        0020-MINGW-setup-_ctypes-module-with-system-libffi.patch
        0021-MINGW-defect-winsock2-and-setup-_socket-module.patch
        0022-MINGW-exclude-unix-only-modules.patch
        0023-MINGW-setup-msvcrt-and-_winapi-modules.patch
        0024-MINGW-build-extensions-with-GCC.patch
        0025-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch
        0026-MINGW-find-import-library.patch
        0027-MINGW-setup-_ssl-module.patch
        0028-MINGW-generalization-of-posix-build-in-sysconfig.py.patch
        0029-MINGW-support-stdcall-without-underscore.patch
        0030-use-replace-instead-rename-to-avoid-failure-on-windo.patch
        0031-MINGW-avoid-circular-dependency-from-time-module-dur.patch
        0032-MINGW-generalization-of-posix-build-in-distutils-sys.patch
        0033-MINGW-customize-site.patch
        0034-add-python-config-sh.patch
        0035-cross-darwin-feature.patch
        0036-py3k-mingw-ntthreads-vs-pthreads.patch
        0037-mingw-system-libffi.patch
        0038-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch
        0039-mingw-use-posix-getpath.patch
        0040-mingw-add-ModuleFileName-dir-to-PATH.patch
        0041-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch
        0042-msys-cygwin-semi-native-build-sysconfig.patch
        0043-mingw-sysconfig-like-posix.patch
        0044-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompile.patch
        0045-cross-dont-add-multiarch-paths-if-cross-compiling.patch
        0046-mingw-use-backslashes-in-compileall-py.patch
        0047-msys-convert_path-fix-and-root-hack.patch
        0048-allow-static-tcltk.patch
        0049-mingw-pdcurses_ISPAD.patch
        0050-grammar-fixes.patch
        0051-builddir-fixes.patch
        0052-msys-monkeypatch-os-system-via-sh-exe.patch
        0053-msys-replace-slashes-used-in-io-redirection.patch
        0054-mingw-install-layout-as-posix.patch
        0055-remove_path_max.default.patch
        0056-dont-link-with-gettext.patch
        0057-ctypes-python-dll.patch
        0058-gdbm-module-includes.patch
        0059-use-gnu_printf-in-format.patch
        0060-mingw-fix-ssl-dont-use-enum_certificates.patch
        0061-mingw-build-optimized-ext.patch
        0062-cygwinccompiler-dont-strip-modules-if-pydebug.patch
        0063-fix-using-dllhandle-and-winver-mingw.patch
        0064-mingw-add-LIBPL-to-library-dirs.patch
        0065-Add-AMD64-to-sys-config-so-msvccompiler-get_build_ve.patch
        0066-MINGW-link-with-additional-library.patch
        0067-install-msilib.patch
        0068-dont-include-system-ncurses-path.patch
        0069-fix-signal-module-build.patch
        0070-build-winconsoleio.patch
        0071-expose-sem_unlink.patch
        0072-cygpty-isatty.patch
        0073-disable-broken-gdbm-module.patch
        0074-link-win-resource-files-and-build-pythonw.patch
        0075-3.7-mpdec-mingw.patch
        0076-disable-readline.patch
        0077-fix-isselectable.patch
        0078-use-_wcsnicmp-instead-wcsncasecmp.patch
        0079-_xxsubinterpretersmodule.patch
        0080-sqlite3-module-defines.patch
        0081-configure-have-inet-pton.patch
        0082-fix-msvc9-import.patch
        0083-set-venv-activate-path-unix.patch
        0084-venv-creation-fixes.patch
        0085-pass-gen-profile-ldflags.patch
        0086-distutils-add-windmc-to-cygwinccompiler.patch
        0087-pkg-config-windows-must-link-ext-with-python-lib.patch
        0088-importlib-bootstrap-path-sep.patch
        0089-pathlib-path-sep.patch
        0090-warnings-fixes.patch
        0091-fix-build-testinternalcapi.patch
        0092-extend-MS_WINDOWS-flag.patch
        0093-clang-arm64.patch
        0094-MINGW-stack-reserve.patch
        0095-Add-support-for-Windows-7-Python-3.9.patch
        0097-Don-t-use-os.pathsep-to-find-EOF.patch
        0098-Fix-extension-suffix-for-c-extensions-on-mingw.patch
        0099-Change-the-get_platform-method-in-sysconfig-and-dist.patch
        0103-squash-Fixup-.rc-handling.patch
        0104-squash-Set-MS_DLL_ID.patch
        0107-squash-fix-srcdir-builddir.patch)

# Helper macros to help make tasks easier #
apply_patch_with_msg() {
  for _patch in "$@"
  do
    msg2 "Applying ${_patch}"
    patch -Nbp1 -i "${srcdir}/${_patch}"
  done
}

prepare() {
  cd "${srcdir}/Python-${pkgver}"

 apply_patch_with_msg 0001-make-_sysconfigdata.py-relocatable.patch \
  0002-restore-setup-config.patch \
  0003-MINGW-BASE-use-NT-thread-model.patch \
  0004-MINGW-translate-gcc-internal-defines-to-python-platf.patch \
  0005-MINGW-configure-MACHDEP-and-platform-for-build.patch \
  0006-MINGW-preset-configure-defaults.patch \
  0007-MINGW-configure-largefile-support-for-windows-builds.patch \
  0008-MINGW-add-srcdir-PC-to-CPPFLAGS.patch \
  0009-MINGW-init-system-calls.patch \
  0010-MINGW-build-in-windows-modules-winreg.patch \
  0011-MINGW-determine-if-pwdmodule-should-be-used.patch \
  0012-MINGW-compiler-customize-mingw-cygwin-compilers.patch \
  0013-MINGW-compiler-enable-new-dtags.patch \
  0014-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch \
  0015-MINGW-configure-for-shared-build.patch \
  0016-MINGW-dynamic-loading-support.patch \
  0017-MINGW-ignore-main-program-for-frozen-scripts.patch \
  0018-MINGW-setup-_multiprocessing-module.patch \
  0019-MINGW-setup-select-module.patch \
  0020-MINGW-setup-_ctypes-module-with-system-libffi.patch \
  0021-MINGW-defect-winsock2-and-setup-_socket-module.patch \
  0022-MINGW-exclude-unix-only-modules.patch \
  0023-MINGW-setup-msvcrt-and-_winapi-modules.patch \
  0024-MINGW-build-extensions-with-GCC.patch \
  0025-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch \
  0026-MINGW-find-import-library.patch \
  0027-MINGW-setup-_ssl-module.patch \
  0028-MINGW-generalization-of-posix-build-in-sysconfig.py.patch \
  0029-MINGW-support-stdcall-without-underscore.patch \
  0030-use-replace-instead-rename-to-avoid-failure-on-windo.patch \
  0031-MINGW-avoid-circular-dependency-from-time-module-dur.patch \
  0032-MINGW-generalization-of-posix-build-in-distutils-sys.patch \
  0033-MINGW-customize-site.patch \
  0034-add-python-config-sh.patch \
  0035-cross-darwin-feature.patch \
  0036-py3k-mingw-ntthreads-vs-pthreads.patch \
  0037-mingw-system-libffi.patch \
  0038-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch \
  0039-mingw-use-posix-getpath.patch \
  0040-mingw-add-ModuleFileName-dir-to-PATH.patch \
  0041-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch \
  0042-msys-cygwin-semi-native-build-sysconfig.patch \
  0043-mingw-sysconfig-like-posix.patch \
  0044-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompile.patch \
  0045-cross-dont-add-multiarch-paths-if-cross-compiling.patch \
  0046-mingw-use-backslashes-in-compileall-py.patch \
  0047-msys-convert_path-fix-and-root-hack.patch \
  0048-allow-static-tcltk.patch \
  0049-mingw-pdcurses_ISPAD.patch \
  0050-grammar-fixes.patch \
  0051-builddir-fixes.patch \
  0052-msys-monkeypatch-os-system-via-sh-exe.patch \
  0053-msys-replace-slashes-used-in-io-redirection.patch \
  0054-mingw-install-layout-as-posix.patch \
  0055-remove_path_max.default.patch \
  0056-dont-link-with-gettext.patch \
  0057-ctypes-python-dll.patch \
  0058-gdbm-module-includes.patch \
  0059-use-gnu_printf-in-format.patch \
  0060-mingw-fix-ssl-dont-use-enum_certificates.patch \
  0061-mingw-build-optimized-ext.patch \
  0062-cygwinccompiler-dont-strip-modules-if-pydebug.patch \
  0063-fix-using-dllhandle-and-winver-mingw.patch \
  0064-mingw-add-LIBPL-to-library-dirs.patch \
  0065-Add-AMD64-to-sys-config-so-msvccompiler-get_build_ve.patch \
  0066-MINGW-link-with-additional-library.patch \
  0067-install-msilib.patch \
  0068-dont-include-system-ncurses-path.patch \
  0069-fix-signal-module-build.patch \
  0070-build-winconsoleio.patch \
  0071-expose-sem_unlink.patch \
  0072-cygpty-isatty.patch \
  0073-disable-broken-gdbm-module.patch \
  0074-link-win-resource-files-and-build-pythonw.patch \
  0075-3.7-mpdec-mingw.patch \
  0076-disable-readline.patch \
  0077-fix-isselectable.patch \
  0078-use-_wcsnicmp-instead-wcsncasecmp.patch \
  0079-_xxsubinterpretersmodule.patch \
  0080-sqlite3-module-defines.patch \
  0081-configure-have-inet-pton.patch \
  0082-fix-msvc9-import.patch \
  0083-set-venv-activate-path-unix.patch \
  0084-venv-creation-fixes.patch \
  0085-pass-gen-profile-ldflags.patch \
  0086-distutils-add-windmc-to-cygwinccompiler.patch \
  0087-pkg-config-windows-must-link-ext-with-python-lib.patch \
  0088-importlib-bootstrap-path-sep.patch \
  0089-pathlib-path-sep.patch \
  0090-warnings-fixes.patch \
  0091-fix-build-testinternalcapi.patch \
  0092-extend-MS_WINDOWS-flag.patch \
  0093-clang-arm64.patch \
  0094-MINGW-stack-reserve.patch \
  0095-Add-support-for-Windows-7-Python-3.9.patch \
  0097-Don-t-use-os.pathsep-to-find-EOF.patch \
  0098-Fix-extension-suffix-for-c-extensions-on-mingw.patch \
  0099-Change-the-get_platform-method-in-sysconfig-and-dist.patch \
  0103-squash-Fixup-.rc-handling.patch \
  0104-squash-Set-MS_DLL_ID.patch \
  0107-squash-fix-srcdir-builddir.patch
 
  autoreconf -vfi
}

check() {
  cd "${srcdir}/build-${CARCH}"

  # Some basic tests to ensure nothing major or MSYS2 specific features are
  # broken
  ./python.exe "${srcdir}/smoketests.py"
  MSYSTEM= ./python.exe "${srcdir}/smoketests.py"

  # make test EXTRATESTOPTS="-v"
}

build() {
  local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX})

  CFLAGS+=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601"
  CXXFLAGS+=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601"
  CPPFLAGS+=" -I${PREFIX_WIN}/include/ncurses "

  declare -a _extra_config
  if check_option "debug" "n"; then
    CFLAGS+=" -DNDEBUG "
    CXXFLAGS+=" -DNDEBUG "
    _extra_config+=("--enable-optimizations")
    # FIXME: https://github.com/msys2-contrib/cpython-mingw/issues/10
    # _extra_config+=("--with-lto")
  else
    CFLAGS+=" -O0 -ggdb"
    CXXFLAGS+=" -O0 -ggdb"
    _extra_config+=("--with-pydebug")
  fi

  # Workaround for conftest error on 64-bit builds
  export ac_cv_working_tzset=no

  # Workaround for when dlfcn exists on Windows, which causes
  # some conftests to succeed when they shouldn't (we don't use dlfcn).
  export ac_cv_header_dlfcn_h=no
  export ac_cv_lib_dl_dlopen=no
  export ac_cv_have_decl_RTLD_GLOBAL=no
  export ac_cv_have_decl_RTLD_LAZY=no
  export ac_cv_have_decl_RTLD_LOCAL=no
  export ac_cv_have_decl_RTLD_NOW=no
  export ac_cv_have_decl_RTLD_DEEPBIND=no
  export ac_cv_have_decl_RTLD_MEMBER=no
  export ac_cv_have_decl_RTLD_NODELETE=no
  export ac_cv_have_decl_RTLD_NOLOAD=no

  [[ -d "${srcdir}/build-${CARCH}" ]] && rm -rf "${srcdir}/build-${CARCH}"
  mkdir -p "${srcdir}/build-${CARCH}" && cd "${srcdir}/build-${CARCH}"

  MSYSTEM=MINGW ../Python-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --host=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --enable-shared \
    --with-nt-threads \
    --with-system-expat \
    --with-system-ffi \
    --with-system-libmpdec \
    --without-ensurepip \
    --without-c-locale-coercion \
    --enable-loadable-sqlite-extensions \
    "${_extra_config[@]}" \
    OPT=""

  # We patch importlib which is embedded in C headers, so regenerate them
  make regen-importlib

  make

  # Add missing venvlauncher files (issue #7014)
  # FIXME: build these from PC/launcher.c instead
  cp python.exe venvlauncher.exe
  cp pythonw.exe venvwlauncher.exe
}

package() {
  cd "${srcdir}/build-${CARCH}"

  local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX})
  MSYSTEM=MINGW \
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  make -j1 install DESTDIR="${pkgdir}"
  if check_option "debug" "n"; then
    VERABI=${_pybasever}
  else
    VERABI=${_pybasever}d
  fi

  # gdb pretty printers for debugging Python itself; to use:
  # python
  # sys.path.append('C:/msys64/mingw64/share/gdb/python3')
  # import python_gdb
  # reload(python_gdb)
  # end
  if [[ "${_primary_python}" == "yes" ]]; then
    [[ -d "${pkgdir}${MINGW_PREFIX}"/share/gdb/python3/ ]] || mkdir -p "${pkgdir}${MINGW_PREFIX}"/share/gdb/python3/
    cp -f python.exe-gdb.py "${pkgdir}${MINGW_PREFIX}"/share/gdb/python3/python_gdb.py
  fi

  cp -f "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/libpython${VERABI}.dll.a "${pkgdir}${MINGW_PREFIX}"/lib/libpython${VERABI}.dll.a

  # Need for building boost python module
  cp -f "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/libpython${VERABI}.dll.a "${pkgdir}${MINGW_PREFIX}"/lib/libpython${_pybasever}.dll.a

  # some useful "stuff"
  install -dm755 "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/Tools/{i18n,scripts}
  install -m755 "${srcdir}/Python-${pkgver}"/Tools/i18n/{msgfmt,pygettext}.py "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/Tools/i18n/
  install -m755 "${srcdir}/Python-${pkgver}"/Tools/scripts/{README,*py} "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/Tools/scripts/

  # clean up #!s
  find "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/ -name '*.py' | \
    xargs sed -i "s|#[ ]*![ ]*/usr/bin/env python$|#!/usr/bin/env python|"

  # clean-up reference to build directory
  sed -i "s#${srcdir}/Python-${pkgver}:##" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/Makefile

  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

  if [[ "${_primary_python}" == "yes" ]]; then
    # Default names are aliases for Python now
    cp "${pkgdir}${MINGW_PREFIX}"/bin/python3.exe "${pkgdir}${MINGW_PREFIX}"/bin/python.exe
    cp "${pkgdir}${MINGW_PREFIX}"/bin/python3w.exe "${pkgdir}${MINGW_PREFIX}"/bin/pythonw.exe
    cp "${pkgdir}${MINGW_PREFIX}"/bin/python3-config "${pkgdir}${MINGW_PREFIX}"/bin/python-config
    cp "${pkgdir}${MINGW_PREFIX}"/bin/idle3 "${pkgdir}${MINGW_PREFIX}"/bin/idle
    cp "${pkgdir}${MINGW_PREFIX}"/bin/pydoc3 "${pkgdir}${MINGW_PREFIX}"/bin/pydoc
  else
    rm "${pkgdir}${MINGW_PREFIX}"/bin/python3.exe
    rm "${pkgdir}${MINGW_PREFIX}"/bin/python3w.exe
    rm "${pkgdir}${MINGW_PREFIX}"/bin/python3-config
    rm "${pkgdir}${MINGW_PREFIX}"/bin/idle3
    rm "${pkgdir}${MINGW_PREFIX}"/bin/pydoc3
    rm "${pkgdir}${MINGW_PREFIX}"/bin/2to3
    rm "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/python3-embed.pc
    rm "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/python3.pc
    rm "${pkgdir}${MINGW_PREFIX}"/share/man/man1/python3.1
  fi

  sed -i "s|#!${pkgdir}${MINGW_PREFIX}/bin/python${VERABI}.exe|#!/usr/bin/env python${_pybasever}.exe|" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/python-config.py

  # fix permissons
  find ${pkgdir}${MINGW_PREFIX} -type f \( -name "*.dll" -o -name "*.exe" \) | xargs chmod 0755

  # Fix up two instances of MSYS2 paths in python-config.sh in-case the final consumer of the results are native executables.
  sed -e "s|${MINGW_PREFIX}|${PREFIX_WIN}|" \
    -i "${pkgdir}${MINGW_PREFIX}"/bin/python${VERABI}-config
  if [[ "${_primary_python}" == "yes" ]]; then
    sed -e "s|${MINGW_PREFIX}|${PREFIX_WIN}|" \
      -i "${pkgdir}${MINGW_PREFIX}"/bin/python3-config \
      -i "${pkgdir}${MINGW_PREFIX}"/bin/python-config
  fi

  # replace paths in sysconfig
  sed -i "s|${pkgdir}${MINGW_PREFIX}|${MINGW_PREFIX}|g" \
    "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/lib-dynload/_sysconfigdata*.py \
    "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/smtpd.py

  # install venv launchers
  mkdir -p "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/venv/scripts/nt
  cp venvlauncher.exe "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/venv/scripts/nt/python.exe
  cp venvwlauncher.exe "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/venv/scripts/nt/pythonw.exe
}

sha256sums=('397920af33efc5b97f2e0b57e91923512ef89fc5b3c1d21dbfc8c4828ce0108a'
            '7188e017a1efba4a87cb64a38b63ed2d8a469e2e74c3fd35b6538d5bc6e370e5'
            '621cbe4120c2f83c39eff9c03aba62b4240c657aaacff6c6063968e597a94f88'
            '382f4d6b59da0e3c0ccea985864bd0e1389d97bd6517f068f175a624615f192d'
            '36a13e324c8d4001f60799b60e87255db4f5ae9f2a04c2396b2a154fa8c7eb4c'
            'a3aeeeafbeaf8fd0f0884a29e4066e5ce2af0f8d4945b51e420dfdaa4dbfe4b9'
            '852be8186f71c46b7f7907a8cef3fd1936f3a288ffeeedba843d73cd2e65caaf'
            'db5a158f9545d554dfad95290aae15fc71f03550c3594e1dabdbc0cfbb0ced29'
            'a8a6eb37672dbe4cfcd6df4ccd755217ee5e433b36b67591a407edcbb262c0eb'
            '380a25c2b7cfafb1b9ddff91a94ba8eb7db00fb6a37c5f6bdb1e12ffbdcf2076'
            '354b523f924dd066520f6df3f61fb752a7bdfe63b6422d32cb3b860445040878'
            'ac85eca34438d4e38f195da6614663a10e7f3f659e5c9879670a1e9a46a8a1c1'
            'fa0010a847b7156b07aadc7fe976b675d8913df0fa4efdfe5a148a529ff41ec1'
            '0581eeba3aab8d851a1af2bf7ac29479d36adf19f7db7f0210d6d5e3ca22b9d8'
            'ff8375e55445678ab17a3d1dff62908dd22d15609160acb670e0fe67198736ee'
            'effc7117a72e0f3cadce63135f18ad513516880e3a6b8121037f6dbfddfc1e46'
            '8f515fc87a457462c2d412326907c58dbc4253de95630718c4d56610db24a6de'
            '3f833597807e08a85ca5e1fc26a2872f1127a01bfe2336c85f2c78cc547f40c3'
            'e2e9b0439a0e6c9a054c2f35c8f454ec2a4100e7bca9505ea94cd1011dfe7ee3'
            '4f4d34bf0b1d3a979988d1dab3cc34d43d267c3b1b3ea1debf3358424302752d'
            '02d3058ffe6439033055834f1452edebca5df686d38c2d48bc62f290b11de1a9'
            '5185d0763ac3ff351d86b4403421ba8bbb9dac477ceb2816054caf4eb62873a5'
            '86e39c652691e6dac338d617d262d0413f7468d74d12305cf8a12806f5e07b5e'
            'e28cfe596fa3087172b00fcdc1f313e1050f97b433a6b4f322a291866b80fc95'
            'fce14bcae4019a1d82b66cf18ad80e2c131eafcb585c1e70843b1f2a7b46a059'
            '91499de0d6b5541aae4b544a84af4f85ce25d8bea030dd61cff0f5af2950e26e'
            '67e10d47d4fd13b6ca691e9e04aa73a230a7df95318251e232455f8ab5c1eec4'
            'dae01ea768c270bf7e04f909000156d785881116dd05c48f2d6c5c64992943af'
            'f6214537de4f5ab1bc1c9c287bcd9f4108f6bf444b8930a985759753a96241e6'
            'd332fa50c6b6de4cba8b849c18687a420da1448cfc1bbdaafa8e724976fc0ee0'
            '8363c5a8baf8dbde51c94413cffc1f9b6da3e3881c98995b30f9264cbf587845'
            '5df74f664abbba7302642b7a9791ce891a1a00df2848cb0ac243cf61ca2617dd'
            '339d65c6309431bd871810be26eb28ac84468b0dc287d443a40e5116ea7e45c7'
            '1e5d15016f9866db88bf0efebe2cabef93955a6a9c54efe254e2219a9938bcba'
            '9e3c9dcecb70a1394c2d2ed36ac2161014f95456a7a28fb206ebe14d6e944e28'
            '516327a3e0dddd923c20a23dffbfafbad83d9ae782477eb36650a14526e0237f'
            '008613913e1d861093ffe980999c1999da8c415f6d6e1f2a630ad872e018048b'
            '6a0798d4f3a832bd0a09a22896b59fa4bc69638d99230d81ff3bc45ff16cde82'
            '6346ca038c76011ade842ed2fe629897cc53ee7c2517ede0a300d7c8bab13ab0'
            'cd2614a5d8fef3132e08a0037ba66eeec9acfab386df086de8637e39bbd93cef'
            '5a7d072a9b3c731818288ee0fe51fdabe5dc257b885eeb5fac6f200bbfc8a63a'
            'a155c770a98ee6bb96cfa0a6f9a5ddb4dce993ea818b83532d90cf57b1615c09'
            '4915b4b4ff6c293426671d6bc91c174cc2b2cd7d3d1099a67e9cfe53cd7320b9'
            '0d3061a67c8ed855ec78c01f682c12632e36e473d42c3e7008f999dc13bbc5b0'
            'e0c2d8aaa24425aa9f1cfd576d8f0a67d2e39c7108edadc7f322f618cdf9f97e'
            '18f30eea4c1efb0f2c7f608a7daa7491c021c15476a1df2323a4f48849b6f77d'
            '8ce17fdb9665dcd384744527a1eb155e1d1ff137a0a2a75d275dca0230830645'
            '8b34737a4018920ecd31ee40d3a0db1545478258e58028061935e50024ee6b6c'
            'e4060c8d2158d3b2dcf7f8c79eca7490d23ef4897fa8a24388321f77c340fd88'
            'd47c18f14276c6151176c9c7f0780d334a582adcf4b6c71145f328377960bb94'
            '25002a2be534ef4b4dbcfbc5598832ef4b64aa0ac849c3b44d796b49e10a3906'
            'c6a731c103ef31589296f60b9e220fe70b0113b49696248c4e379bb3b39ddf03'
            'c5ccfdb8f8695f94f23e9ecd0304ec91b5f4f00f9d6f43426ede4e0038479f24'
            '58f5f50ce9e8a6dd4b484f174ad174db397ac5b2b248b56db65acae2122ed805'
            '077ce1a4e5fd69de839c5f1bfb24a3bb5d2d548fb4a51250097692626d7c5d6b'
            '3b1659b05b3353938a84b9a9f23a1add6f0dc38bb1d81e58010651e07c719a95'
            '17d44817baccadcfb23289c15ca23f19fa185aa2a7dd12c88524de8d888f3507'
            '54031e5b3f02cc4b80ce6b1702d7c33c6e9251136e1410012c7faa861abffe84'
            '3741637112ae6fa0bcc15d73e80810b5e5c6986b8e8a4333f8a08c30c5e21ddb'
            '11314e843829ef3fd8058434311dd55eeb7dd512ec8730f28c5b8bc6e101a654'
            'b87f41523bbcb61a8076a46a83b61480a2da79b49c3af3d0310aff02fb3eff7d'
            '12f619eb1bcc3dc3a05d3ac077d0970860a8b97ecbd95f735fc95436bc910c1d'
            '22f256ab9b1f19aa6ad41ef2ef23bcc67b8d9a2fc24315bac39e5eff4a3d5ef0'
            '453be8620a5b47567fd750bdc7226baa2a7bae84d280c082ceea6c822c0152d4'
            '167fc8fe20a0122fa0a5dfd7adcf343ba71379732bd0f6ade5a958f4c4c07c84'
            'f99bc96d13d181c0e3604b0b6f3405450cb23504739812cd05d12bb4796d6a4d'
            '4e1fed573d0b564faad7770fa1a79525864acb02dd3996bbd28813201d80e941'
            'dcbf48794825acdcfc00e08ae358f2dc51dc8dfde8fc3cf7e304c570b8c477d2'
            '3a9876035372157298f0b340c86806a43c193c09a1f732cb116262a8baa6658b'
            '4446250eb39ed7afd9d0c79da92f15586bf8dc8c2ba9dec2edaa5d92136e95e6'
            '385935abdaedf42ae27e21e895707471a3171a73310d0b97218823d13a1cff52'
            '2b890e0612c9aaa0243b3cc86219b47c8f6823af2c57d8f3f100dcc5f664d13e'
            '02b98c859ffc4c0d47667e7fa4579699249eb9052b8a985d051630c33d2304ff'
            '92c3ed2cbcc0c9bd28a0b669ec68e445be7c5245201bda1c06172712c54d1a17'
            '72e51a8f9374766b9afc452a5fbf7646390e89d1ae9f1ec158e22aac6dedf1db'
            '5891a8c56eb49b1a9d2c22ee895821c34086a341b4a7e7e57b9e78196dc346a4'
            'e02409488b5cbd9157b6c80abd78ea2972e49092949e902811dabbf56f3f6d0c'
            'adba48cb1daf77542162e4da61caf498c83b2de5abbc5545f68a8ac290fe7b4a'
            'bf1960038604a3ad0ab11bc47007f8d7a97941c3b7f44d4487e2d79d742ca870'
            '836723f0d3ec3d10b5ddabd09f7dddc76eefa261b6105b544f9dae7f4416146e'
            'b64e7a874532fe0475d4b3c192fb215948c06392a7ad04fd47a28289cc809967'
            'b49ab150e95bd390101225ba6ac3983df2a5a0bbc47d506a88c9caeefbd4ed3f'
            '79f1646fa548a9da9986ded4a51842751cdea7ec579d28e6cc5d86e4a5a89f27'
            '233318923f5fd7dd4605c79bb2adfbcdd2e8cc7e242b1e080e59aed1f6b86a29'
            'ceba0f6e583570db571ee9c3fe64b74ea58a474d114847cadd3ad70386c7c199'
            'fb3bee9ba5e4f9b2e8b7e8ec2fb08e12d85542bae8b86e7a4c69f698f720253b'
            'b01320b3c9037bb1fed03c7b8002e7b6af52fc7bb85cdf84cfc96842c7c9657d'
            'e3c10b3eb07b41e804b6a500c848def6f72cb04d94d00657dab307e68e891536'
            '5e8113ca39795b59a0144b68db88a197c43c3b907c3f7bf2a5e1c1dd3a41b19c'
            '4130af022a9ec1717cac82e3d3d5a7144a9c17611ac4db5150f8adede4ed3276'
            '24e9029d664255a96c0346f7e53316640be6a6480bd77fcd7532a2b88881b485'
            '754d84bc288da89cdec4b1cf5d216195aaa2f3d4046043d8b487bdd2f5a4c837'
            '2d6ce50423f65dded048f64eb0dafe62448ad4786add9295d90fcfa6f316412a'
            'b3ba2ac22cd4263419f3daf93334745bccd1c70c429812c95821ed1e2d649159'
            'a74c4203ccc6f858fa9ee2c203cad1bf5de2bd868650d18c65034897e29e2b5d'
            'fe6bb4725238cbd00b856ed757392bdd2f0e7adb5216ee7738654b7a74594810'
            '6fcc769d47e71afd496eef16a6c77d0e1eff983a20b16a7fadb6f4cc1c8ee6d7'
            '38217179bc520cc35ba03f4f049d06b2bb935d66e5cfb488e5fd08befda3b8e8'
            '034a036cbdcbe33bb17a7951658da438ff7047f4f86fe8e5ebac5d84438ed0bd'
            '703846000b96d426c50b400f5efbc8c2c877ce7c844f64ecdba86275035577b3'
            'ba079f6735555329997f7bd2e06140a1f4c32bf31e51c7a08f43b6fbf242829e'
            '70d2d6d4b0ad50633069f14a13ac7474d97bc6443da51a1f4cdfe50d200c7c97'
            '527284880bc4eaf45f657993cbb14b0c9e2355c696bf9da30ffa20fe0a527f72')
