diff --git a/mingw-w64-python-setuptools/mingw-python-fix.patch b/mingw-w64-python-setuptools/0001-mingw-python-fix.patch similarity index 55% rename from mingw-w64-python-setuptools/mingw-python-fix.patch rename to mingw-w64-python-setuptools/0001-mingw-python-fix.patch index 1e57509a37..7cac378b8c 100644 --- a/mingw-w64-python-setuptools/mingw-python-fix.patch +++ b/mingw-w64-python-setuptools/0001-mingw-python-fix.patch @@ -1,6 +1,6 @@ ---- setuptools-2.2/setuptools/command/easy_install.py.orig 2014-02-11 21:11:57.898800000 +0400 -+++ setuptools-2.2/setuptools/command/easy_install.py 2014-02-11 21:41:20.905000000 +0400 -@@ -1213,8 +1213,8 @@ +--- setuptools-5.4.1/setuptools/command/easy_install.py.orig 2014-02-11 21:11:57.898800000 +0400 ++++ setuptools-5.4.1/setuptools/command/easy_install.py 2014-02-11 21:41:20.905000000 +0400 +@@ -1256,8 +1256,8 @@ ) DEFAULT_SCHEME = dict( diff --git a/mingw-w64-python-setuptools/0002-Allow-usr-bin-env-in-script.patch b/mingw-w64-python-setuptools/0002-Allow-usr-bin-env-in-script.patch new file mode 100644 index 0000000000..6e1b5ca00d --- /dev/null +++ b/mingw-w64-python-setuptools/0002-Allow-usr-bin-env-in-script.patch @@ -0,0 +1,104 @@ +--- setuptools-5.4.1/launcher.c.orig 2014-06-29 02:40:09.000000000 +0100 ++++ setuptools-5.4.1/launcher.c 2014-10-19 13:37:21.272787900 +0100 +@@ -104,9 +104,19 @@ + } + + +-char *find_exe(char *exename, char *script) { ++int file_exists(char* path) ++{ ++ DWORD attrib = GetFileAttributes(path); ++ ++ if ((attrib == INVALID_FILE_ATTRIBUTES) || (attrib & FILE_ATTRIBUTE_DIRECTORY)) return 0; ++ return 1; ++} ++ ++char *find_exe(char *exename, char *script, int search_in_path) { + char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + char path[_MAX_PATH], c, *result; ++ char *path_env, *path_env_start; ++ int maximum, needs_exe = 0; + + /* convert slashes to backslashes for uniform search below */ + result = exename; +@@ -116,6 +126,34 @@ + if (drive[0] || dir[0]=='\\') { + return loadable_exe(exename); /* absolute path, use directly */ + } ++ ++ if (search_in_path) { ++ if (strstr(exename, ".exe") == NULL) needs_exe = 1; ++ char *path_env = getenv("PATH"); ++ while (path_env != NULL) { ++ path_env_start = path_env; ++ path_env = strchr(path_env, ';'); ++ maximum = _MAX_PATH - 2 - strlen(exename) - (needs_exe * strlen(".exe")); ++ if (path_env == NULL) { ++ strncpy(path, path_env_start, maximum); ++ } ++ else { ++ maximum = path_env - path_env_start < maximum ? path_env - path_env_start : maximum; ++ memcpy(path, path_env_start, maximum); ++ ++path_env; ++ } ++ path[maximum] = '\0'; ++ strcat(path, "\\"); ++ strcat(path, exename); ++ if (needs_exe) strcat(path, ".exe"); ++ /* printf("Checking %s\n", path); */ ++ if (file_exists(path)) { ++ /* printf("Found\n"); */ ++ return loadable_exe(path); ++ } ++ } ++ } ++ + /* Use the script's parent directory, which should be the Python home + (This should only be used for bdist_wininst-installed scripts, because + easy_install-ed scripts use the absolute path to python[w].exe +@@ -206,7 +244,7 @@ + // set-up control handler callback funciotn + SetConsoleCtrlHandler((PHANDLER_ROUTINE) control_handler, TRUE); + if (!CreateProcessA(NULL, commandline, NULL, NULL, TRUE, 0, NULL, NULL, &s_info, &p_info)) { +- fprintf(stderr, "failed to create process.\n"); ++ fprintf(stderr, "failed to create process (%s).\n", commandline); + return 0; + } + child_pid = p_info.dwProcessId; +@@ -256,6 +294,9 @@ + char *ptr, *end; /* working pointers for string manipulation */ + char *cmdline; + int i, parsedargc; /* loop counter */ ++ char *env, *first_space; ++ int skip = 2; ++ int search_in_path = 0; + + /* compute script name from our .exe name*/ + GetModuleFileNameA(NULL, script, sizeof(script)); +@@ -284,12 +325,24 @@ + strcpy(python, "#!python.exe"); + } + +- parsedargs = parse_argv(python+2, &parsedargc); ++ /* Check if "env" appears before the first space and skip ++ ahead to the next space. */ ++ env = strstr(python+skip, "env"); ++ first_space = strchr(python+skip, ' '); ++ if (env != NULL && (first_space == NULL || env < first_space)) { ++ search_in_path = 1; ++ env += 3; ++ while (*env && *env != ' ') ++ ++env; ++ skip = env - python; ++ } ++ ++ parsedargs = parse_argv(python+skip, &parsedargc); + + /* Using spawnv() can fail strangely if you e.g. find the Cygwin + Python, so we'll make sure Windows can find and load it */ + +- ptr = find_exe(parsedargs[0], script); ++ ptr = find_exe(parsedargs[0], script, search_in_path); + if (!ptr) { + return fail("Cannot find Python executable %s\n", parsedargs[0]); + } diff --git a/mingw-w64-python-setuptools/0003-MinGW-w64-Look-in-same-dir-as-script-for-exe.patch b/mingw-w64-python-setuptools/0003-MinGW-w64-Look-in-same-dir-as-script-for-exe.patch new file mode 100644 index 0000000000..a751d40389 --- /dev/null +++ b/mingw-w64-python-setuptools/0003-MinGW-w64-Look-in-same-dir-as-script-for-exe.patch @@ -0,0 +1,21 @@ +--- setuptools-5.4.1/launcher.c.orig 2014-06-29 02:40:09.000000000 +0100 ++++ setuptools-5.4.1/launcher.c 2014-10-19 13:37:21.272787900 +0100 +@@ -154,14 +154,16 @@ + } + } + +- /* Use the script's parent directory, which should be the Python home +- (This should only be used for bdist_wininst-installed scripts, because ++ /* Use the script's directory (parent directory if not mingw-w64), which should be the ++ Python home (This should only be used for bdist_wininst-installed scripts, because + easy_install-ed scripts use the absolute path to python[w].exe + */ + _splitpath(script, drive, dir, fname, ext); + result = dir + strlen(dir) -1; ++#if !defined(__MINGW64_VERSION_MAJOR) + if (*result == '\\') result--; + while (*result != '\\' && result>=dir) *result-- = 0; ++#endif + _makepath(path, drive, dir, exename, NULL); + return loadable_exe(path); + } diff --git a/mingw-w64-python-setuptools/dont-execute-msvc.patch b/mingw-w64-python-setuptools/0004-dont-execute-msvc.patch similarity index 100% rename from mingw-w64-python-setuptools/dont-execute-msvc.patch rename to mingw-w64-python-setuptools/0004-dont-execute-msvc.patch diff --git a/mingw-w64-python-setuptools/PKGBUILD b/mingw-w64-python-setuptools/PKGBUILD index fb74eb14c2..f9ab4413dd 100644 --- a/mingw-w64-python-setuptools/PKGBUILD +++ b/mingw-w64-python-setuptools/PKGBUILD @@ -1,50 +1,68 @@ # Maintainer: Alexey Pavlov +# Contributor: Ray Donnelly _realname=setuptools pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" pkgname=("${MINGW_PACKAGE_PREFIX}-python2-setuptools" "${MINGW_PACKAGE_PREFIX}-python3-setuptools") _py3_base=3.4 -pkgver=7.0 -pkgrel=1 +#pkgver=7.0 +#pkgrel=1 +pkgver=5.4.1 +pkgrel=2 pkgdesc="Easily download, build, install, upgrade, and uninstall Python packages (mingw-w64)" arch=('any') license=('PSF') url="http://pypi.python.org/pypi/setuptools" depends=("${MINGW_PACKAGE_PREFIX}-python2" "${MINGW_PACKAGE_PREFIX}-python3") source=(http://pypi.python.org/packages/source/s/setuptools/${_realname}-${pkgver}.tar.gz - 'mingw-python-fix.patch' - 'dont-execute-msvc.patch') -md5sums=('6245d6752e2ef803c365f560f7f2f940' - 'c141e15510d51e35b1d1578b35510f9a' - '8ac6825bdc329f9adf1f71142122a72b') + '0001-mingw-python-fix.patch' + '0002-Allow-usr-bin-env-in-script.patch' + '0003-MinGW-w64-Look-in-same-dir-as-script-for-exe.patch' + '0004-dont-execute-msvc.patch') +sha1sums=('113e5688a7fab03004f7b793aa2f718f949515d0' + 'a26b8313592899ff6e5c18e5a4d489b7d8a6e021' + '3f475c0510ecaa1ee86412197cb3624ebfba7105' + '101db3f8acbd116c81ee170adea2b1453ccc709a' + '8c7266a73334b166286baf8641ad0c139f15faad') prepare() { - cd "${srcdir}/setuptools-${pkgver}" - patch -p1 -i ${srcdir}/mingw-python-fix.patch - patch -p1 -i ${srcdir}/dont-execute-msvc.patch + cd "${srcdir}/setuptools-${pkgver}" + patch -p1 -i ${srcdir}/0001-mingw-python-fix.patch + patch -p1 -i ${srcdir}/0002-Allow-usr-bin-env-in-script.patch + patch -p1 -i ${srcdir}/0003-MinGW-w64-Look-in-same-dir-as-script-for-exe.patch + if [ "${pkgver}" = "7.0" ]; then + patch -p1 -i ${srcdir}/0004-dont-execute-msvc.patch + fi - cd "${srcdir}" - - cp -r setuptools-${pkgver} setuptools-python2 - cp -r setuptools-${pkgver} setuptools-python3 - - cd "${srcdir}"/setuptools-python2 - sed -i -e "s|^#\!.*/usr/bin/python|#!/usr/bin/python3|" setuptools/tests/test_resources.py - sed -i -e "s|^#\!.*/usr/bin/env python|#!/usr/bin/env python3|" setuptools/command/easy_install.py - - cd "${srcdir}"/setuptools-python3 - sed -i -e "s|^#\!.*/usr/bin/python|#!/usr/bin/python2|" setuptools/tests/test_resources.py - sed -i -e "s|^#\!.*/usr/bin/env python|#!/usr/bin/env python2|" setuptools/command/easy_install.py + cd "${srcdir}" + + # Compile our own MSYS2-layout and /usr/bin/env capable {cli,gui}{-32,-64}.exe to replace the precompiled binaries. + # .. when arm is ready, add it to this. + PATH=/mingw32/bin:$PATH gcc -DGUI=0 -O -s -o setuptools-${pkgver}/setuptools/cli-32.exe setuptools-${pkgver}/launcher.c + PATH=/mingw32/bin:$PATH gcc -DGUI=1 -mwindows -O -s -o setuptools-${pkgver}/setuptools/gui-32.exe setuptools-${pkgver}/launcher.c + PATH=/mingw64/bin:$PATH gcc -DGUI=0 -O -s -o setuptools-${pkgver}/setuptools/cli-64.exe setuptools-${pkgver}/launcher.c + PATH=/mingw64/bin:$PATH gcc -DGUI=1 -mwindows -O -s -o setuptools-${pkgver}/setuptools/gui-64.exe setuptools-${pkgver}/launcher.c + + cp -r setuptools-${pkgver} setuptools-python2 + cp -r setuptools-${pkgver} setuptools-python3 + + cd "${srcdir}"/setuptools-python2 + sed -i -e "s|^#\!.*/usr/bin/python|#!/usr/bin/python2|" setuptools/tests/test_resources.py + sed -i -e "s|^#\!.*/usr/bin/env python|#!/usr/bin/env python2|" setuptools/command/easy_install.py + + cd "${srcdir}"/setuptools-python3 + sed -i -e "s|^#\!.*/usr/bin/python|#!/usr/bin/python3|" setuptools/tests/test_resources.py + sed -i -e "s|^#\!.*/usr/bin/env python|#!/usr/bin/env python3|" setuptools/command/easy_install.py } build() { - # Build python 3 module - cd "${srcdir}"/setuptools-python3 - ${MINGW_PREFIX}/bin/python3 setup.py build - # Build python 2 module cd "${srcdir}"/setuptools-python2 ${MINGW_PREFIX}/bin/python2 setup.py build + + # Build python 3 module + cd "${srcdir}"/setuptools-python3 + ${MINGW_PREFIX}/bin/python3 setup.py build } package_python3-setuptools() { @@ -57,18 +75,17 @@ package_python3-setuptools() { cd "${srcdir}/setuptools-python3" MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \ ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX#\/} --root="${pkgdir}" --optimize=1 --skip-build - - # Remove files conflicted with python2-setuptools - #rm -f ${pkgdir}${MINGW_PREFIX}/bin/easy_install{-script.py,.exe,.exe.manifest} + + # Move files conflicted with python2-setuptools mv ${pkgdir}${MINGW_PREFIX}/bin/easy_install-script.py ${pkgdir}${MINGW_PREFIX}/bin/easy_install-${_py3_base}-script.py mv ${pkgdir}${MINGW_PREFIX}/bin/easy_install.exe ${pkgdir}${MINGW_PREFIX}/bin/easy_install-${_py3_base}.exe [[ -f ${pkgdir}${MINGW_PREFIX}/bin/easy_install.exe.manifest ]] && { mv ${pkgdir}${MINGW_PREFIX}/bin/easy_install.exe.manifest ${pkgdir}${MINGW_PREFIX}/bin/easy_install-${_py3_base}.exe.manifest sed -e "s|easy_install|easy_install-${_py3_base}|g" -i ${pkgdir}${MINGW_PREFIX}/bin/easy_install-${_py3_base}.exe.manifest } - sed -e "s|${_mingw_prefix}|${MINGW_PREFIX}|g" -i ${pkgdir}${MINGW_PREFIX}/bin/easy_install-${_py3_base}-script.py + sed -e "s|${_mingw_prefix}/bin/|/usr/bin/env |g" -i ${pkgdir}${MINGW_PREFIX}/bin/easy_install-${_py3_base}-script.py } - + package_python2-setuptools() { depends=("${MINGW_PACKAGE_PREFIX}-python2>=2.7") @@ -79,26 +96,21 @@ package_python2-setuptools() { cd "${srcdir}/setuptools-python2" MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \ ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX#\/} --root="${pkgdir}" --optimize=1 --skip-build - #rm "${pkgdir}${MINGW_PREFIX}/bin/easy_install" - sed -e "s|${_mingw_prefix}|${MINGW_PREFIX}|g" -i ${pkgdir}${MINGW_PREFIX}/bin/easy_install-script.py + sed -e "s|${_mingw_prefix}/bin/|/usr/bin/env |g" -i ${pkgdir}${MINGW_PREFIX}/bin/easy_install-script.py } package_mingw-w64-i686-python2-setuptools() { - install=${_realname}2-${CARCH}.install package_python2-setuptools } package_mingw-w64-i686-python3-setuptools() { - install=${_realname}3-${CARCH}.install package_python3-setuptools } package_mingw-w64-x86_64-python2-setuptools() { - install=${_realname}2-${CARCH}.install package_python2-setuptools } package_mingw-w64-x86_64-python3-setuptools() { - install=${_realname}3-${CARCH}.install package_python3-setuptools } diff --git a/mingw-w64-python-setuptools/setuptools2-i686.install b/mingw-w64-python-setuptools/setuptools2-i686.install deleted file mode 100644 index 5c50ef88e1..0000000000 --- a/mingw-w64-python-setuptools/setuptools2-i686.install +++ /dev/null @@ -1,14 +0,0 @@ -post_install() { - pushd mingw32 > /dev/null - local _prefix=$(pwd -W) - popd > /dev/null - local _it - for _it in easy_install-script; do - sed -e "s|/mingw32|${_prefix}|g" \ - -i mingw32/bin/${_it}.py - done -} - -post_upgrade() { - post_install -} diff --git a/mingw-w64-python-setuptools/setuptools2-x86_64.install b/mingw-w64-python-setuptools/setuptools2-x86_64.install deleted file mode 100644 index 59bdcd419d..0000000000 --- a/mingw-w64-python-setuptools/setuptools2-x86_64.install +++ /dev/null @@ -1,14 +0,0 @@ -post_install() { - pushd mingw64 > /dev/null - local _prefix=$(pwd -W) - popd > /dev/null - local _it - for _it in easy_install-script; do - sed -e "s|/mingw64|${_prefix}|g" \ - -i mingw64/bin/${_it}.py - done -} - -post_upgrade() { - post_install -} diff --git a/mingw-w64-python-setuptools/setuptools3-i686.install b/mingw-w64-python-setuptools/setuptools3-i686.install deleted file mode 100644 index 4d435b0c33..0000000000 --- a/mingw-w64-python-setuptools/setuptools3-i686.install +++ /dev/null @@ -1,14 +0,0 @@ -post_install() { - pushd mingw32 > /dev/null - local _prefix=$(pwd -W) - popd > /dev/null - local _it - for _it in easy_install-3.4-script; do - sed -e "s|/mingw32|${_prefix}|g" \ - -i mingw32/bin/${_it}.py - done -} - -post_upgrade() { - post_install -} diff --git a/mingw-w64-python-setuptools/setuptools3-x86_64.install b/mingw-w64-python-setuptools/setuptools3-x86_64.install deleted file mode 100644 index 74046c8bb8..0000000000 --- a/mingw-w64-python-setuptools/setuptools3-x86_64.install +++ /dev/null @@ -1,14 +0,0 @@ -post_install() { - pushd mingw64 > /dev/null - local _prefix=$(pwd -W) - popd > /dev/null - local _it - for _it in easy_install-3.4-script; do - sed -e "s|/mingw64|${_prefix}|g" \ - -i mingw64/bin/${_it}.py - done -} - -post_upgrade() { - post_install -}