diff options
author | Andrew Sun | 2017-11-18 00:39:08 +0000 |
---|---|---|
committer | Andrew Sun | 2017-11-18 00:39:08 +0000 |
commit | 8262bb07fa44ddcf8ac619a2d0881aafe3e6df26 (patch) | |
tree | 4f056dbeb806c3f4892afd60c6d569256931baca | |
download | aur-8262bb07fa44ddcf8ac619a2d0881aafe3e6df26.tar.gz |
add mingw-w64-python-setuptools
-rw-r--r-- | .SRCINFO | 27 | ||||
-rw-r--r-- | 0001-mingw-python-fix.patch | 13 | ||||
-rw-r--r-- | 0002-Allow-usr-bin-env-in-script.patch | 104 | ||||
-rw-r--r-- | 0003-MinGW-w64-Look-in-same-dir-as-script-for-exe.patch | 21 | ||||
-rw-r--r-- | 0004-dont-execute-msvc.patch | 12 | ||||
-rw-r--r-- | PKGBUILD | 104 |
6 files changed, 281 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..46fe479136cf --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,27 @@ +pkgbase = mingw-w64-python-setuptools + pkgdesc = Easily download, build, install, upgrade, and uninstall Python packages (mingw-w64) + pkgver = 36.7.2 + pkgrel = 1 + url = https://pypi.python.org/pypi/setuptools + arch = any + license = MIT + makedepends = mingw-w64-python-pip + makedepends = mingw-w64-python2-pip + depends = wine + source = https://github.com/pypa/setuptools/archive/v36.7.2.tar.gz + source = 0001-mingw-python-fix.patch + source = 0002-Allow-usr-bin-env-in-script.patch + source = 0003-MinGW-w64-Look-in-same-dir-as-script-for-exe.patch + source = 0004-dont-execute-msvc.patch + md5sums = 5c76d4500cecfc2ba2465a42daad5099 + md5sums = 9a47748aa98d1263b4b056f0c46b11b1 + md5sums = c89605bb93f8e6ab683ec8e3ca2ff9df + md5sums = 12685e2e10a64e7b0615098d4b0a1c41 + md5sums = 41da2b739443e65a72f9bb4ae454eb57 + +pkgname = mingw-w64-python-setuptools + depends = mingw-w64-python>=3.3 + +pkgname = mingw-w64-python2-setuptools + depends = mingw-w64-python2>=2.7 + diff --git a/0001-mingw-python-fix.patch b/0001-mingw-python-fix.patch new file mode 100644 index 000000000000..7cac378b8c88 --- /dev/null +++ b/0001-mingw-python-fix.patch @@ -0,0 +1,13 @@ +--- 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( +- install_dir='$base/Lib/site-packages', +- script_dir='$base/Scripts', ++ install_dir='$base/lib/python$py_version_short/site-packages', ++ script_dir='$base/bin', + ) + + def _expand(self, *attrs): diff --git a/0002-Allow-usr-bin-env-in-script.patch b/0002-Allow-usr-bin-env-in-script.patch new file mode 100644 index 000000000000..6e1b5ca00d39 --- /dev/null +++ b/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/0003-MinGW-w64-Look-in-same-dir-as-script-for-exe.patch b/0003-MinGW-w64-Look-in-same-dir-as-script-for-exe.patch new file mode 100644 index 000000000000..a751d403892e --- /dev/null +++ b/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/0004-dont-execute-msvc.patch b/0004-dont-execute-msvc.patch new file mode 100644 index 000000000000..7ad06828c1ba --- /dev/null +++ b/0004-dont-execute-msvc.patch @@ -0,0 +1,12 @@ +--- setuptools-27.3.0/setuptools/monkey.py.orig 2016-09-23 11:38:23.517707200 +0300 ++++ setuptools-27.3.0/setuptools/monkey.py 2016-09-23 11:39:40.362333800 +0300 +@@ -90,7 +90,8 @@ + setuptools.extension.Extension + ) + +- patch_for_msvc_specialized_compiler() ++ if not 'GCC' in sys.version: ++ patch_for_msvc_specialized_compiler() + + + def _patch_distribution_metadata_write_pkg_file(): diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..3341300b9ee8 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,104 @@ +# Maintainer: Andrew Sun <adsun701@gmail.com> + +_pypiname=setuptools +pkgbase=mingw-w64-python-setuptools +pkgname=('mingw-w64-python-setuptools' 'mingw-w64-python2-setuptools') +pkgver=36.7.2 +pkgrel=1 +pkgdesc="Easily download, build, install, upgrade, and uninstall Python packages (mingw-w64)" +arch=(any) +url="https://pypi.python.org/pypi/setuptools" +license=('MIT') +makedepends=('mingw-w64-python-pip' 'mingw-w64-python2-pip') +depends=('wine') +source=("https://github.com/pypa/setuptools/archive/v${pkgver}.tar.gz" + '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') +md5sums=('5c76d4500cecfc2ba2465a42daad5099' + '9a47748aa98d1263b4b056f0c46b11b1' + 'c89605bb93f8e6ab683ec8e3ca2ff9df' + '12685e2e10a64e7b0615098d4b0a1c41' + '41da2b739443e65a72f9bb4ae454eb57') +_py3_base=3.6 +_py2_base=2.7 + +_architectures="i686-w64-mingw32 x86_64-w64-mingw32" + +prepare() { + 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 + patch -p1 -i ${srcdir}/0004-dont-execute-msvc.patch + + cd "${srcdir}" + + i686-w64-mingw32-gcc -DGUI=0 -O -s -o setuptools-${pkgver}/setuptools/cli-32.exe setuptools-${pkgver}/launcher.c + i686-w64-mingw32-gcc -DGUI=1 -mwindows -O -s -o setuptools-${pkgver}/setuptools/gui-32.exe setuptools-${pkgver}/launcher.c + x86_64-w64-mingw32-gcc -DGUI=0 -O -s -o setuptools-${pkgver}/setuptools/cli-64.exe setuptools-${pkgver}/launcher.c + x86_64-w64-mingw32-gcc -DGUI=1 -mwindows -O -s -o setuptools-${pkgver}/setuptools/gui-64.exe setuptools-${pkgver}/launcher.c + + for _arch in ${_architectures}; do + cp -r "${srcdir}/setuptools-${pkgver}" ${srcdir}/setuptools-python2-${_arch} + cp -r "${srcdir}/setuptools-${pkgver}" ${srcdir}/setuptools-python3-${_arch} + + cd "${srcdir}"/setuptools-python2-${_arch} + sed -i -e "s|^#\!.*/usr/bin/python|#!/usr/bin/python2|" tests/manual_test.py + sed -i -e "s|^#\!.*/usr/bin/env python|#!/usr/bin/env python2|" setuptools/command/easy_install.py + + cd "${srcdir}"/setuptools-python3-${_arch} + sed -i -e "s|^#\!.*/usr/bin/python|#!/usr/bin/python3|" tests/manual_test.py + sed -i -e "s|^#\!.*/usr/bin/env python|#!/usr/bin/env python3|" setuptools/command/easy_install.py + + done +} + +build() { + for _arch in ${_architectures}; do + + # Build python 2 module + cd "${srcdir}"/setuptools-python2-${_arch} + /usr/${_arch}/bin/python2.exe bootstrap.py + /usr/${_arch}/bin/python2.exe setup.py build + + # Build python 3 module + cd "${srcdir}"/setuptools-python3-${_arch} + /usr/${_arch}/bin/python3.exe bootstrap.py + /usr/${_arch}/bin/python3.exe setup.py build + done +} + +package_mingw-w64-python-setuptools() { + depends=("mingw-w64-python>=3.3") + for _arch in ${_architectures}; do + + cd "${srcdir}/setuptools-python3-${_arch}" + /usr/${_arch}/bin/python3.exe setup.py install --prefix="\usr/${_arch}" --root="${pkgdir}" --optimize=1 --skip-build + + # Move files conflicted with python2-setuptools + mv ${pkgdir}/usr/${_arch}/bin/easy_install-script.py ${pkgdir}/usr/${_arch}/bin/easy_install-${_py3_base}-script.py + mv ${pkgdir}/usr/${_arch}/bin/easy_install.exe ${pkgdir}/usr/${_arch}/bin/easy_install-${_py3_base}.exe + + done + + [[ -f ${pkgdir}/usr/i686-w64-mingw32/bin/easy_install.exe.manifest ]] && { + mv ${pkgdir}/usr/i686-w64-mingw32/bin/easy_install.exe.manifest ${pkgdir}/usr/i686-w64-mingw32/bin/easy_install-${_py3_base}.exe.manifest + sed -e "s|easy_install|easy_install-${_py3_base}|g" -i ${pkgdir}/usr/i686-w64-mingw32/bin/easy_install-${_py3_base}.exe.manifest + } + +} + +package_mingw-w64-python2-setuptools() { + depends=("mingw-w64-python2>=2.7") + for _arch in ${_architectures}; do + + cd "${srcdir}/setuptools-python2-${_arch}" + /usr/${_arch}/bin/python2.exe setup.py install --prefix="\usr/${_arch}" --root="${pkgdir}" --optimize=1 --skip-build + + done +} + +# vim:set ts=2 sw=2 et: + |