MSYS2-packages/python2/0260-fix-sys-prefix-when-win-drive-in-argv0.patch
Ray Donnelly 7f9cc5b2b3 python2: Fix sys.prefix in a Cygwin friendly way
The same issue is can be reproduced on Cygwin so re-implement
the msys2-specific fix using cygwin_conv_path() instead.
2015-07-07 22:40:55 +01:00

49 lines
1.5 KiB
Diff

diff -urN Python-2.7.10.orig/Modules/getpath.c Python-2.7.10/Modules/getpath.c
--- Python-2.7.10.orig/Modules/getpath.c 2015-07-07 12:58:16.162926800 +0100
+++ Python-2.7.10/Modules/getpath.c 2015-07-07 13:09:22.496926800 +0100
@@ -10,6 +10,10 @@
#include <mach-o/dyld.h>
#endif
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+#endif
+
/* Search in some common locations for the associated Python libraries.
*
* Two directories must be found, the platform independent directory
@@ -229,8 +233,21 @@
static void
copy_absolute(char *path, char *p)
{
+#if defined(__CYGWIN__)
+ int win_drive = (p[0] != '\0' && p[1] == ':') ? 1 : 0;
+ if (p[0] == SEP || win_drive)
+#else
if (p[0] == SEP)
+#endif
strcpy(path, p);
+#if defined(__CYGWIN__)
+ /* Turn absolute paths with Windows drive letters into their
+ Cygwin equivalent since sys.path can't have drive seps (:)
+ in since those delimit path list entries */
+ if (win_drive) {
+ cygwin_conv_path(CCP_WIN_A_TO_POSIX, p, path, MAXPATHLEN + 1);
+ }
+#endif
else {
if (!getcwd(path, MAXPATHLEN)) {
/* unable to get the current directory */
@@ -482,7 +499,11 @@
}
else
progpath[0] = '\0';
+#if defined(__MSYS__)
+ if (progpath[0] != SEP && progpath[0] != '\0' && progpath[1] != ':')
+#else
if (progpath[0] != SEP && progpath[0] != '\0')
+#endif
absolutize(progpath);
strncpy(argv0_path, progpath, MAXPATHLEN);
argv0_path[MAXPATHLEN] = '\0';