Cross-Platform build scripts for audio plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

378 lines
11KB

  1. diff -Naur Python-3.8.0-orig/Include/pylifecycle.h Python-3.8.0/Include/pylifecycle.h
  2. --- Python-3.8.0-orig/Include/pylifecycle.h 2019-10-14 16:34:47.000000000 +0300
  3. +++ Python-3.8.0/Include/pylifecycle.h 2019-10-22 10:02:36.752112100 +0300
  4. @@ -21,6 +21,12 @@
  5. PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
  6. PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
  7. +PyAPI_FUNC(wchar_t) Py_GetSepW(const wchar_t *);
  8. +PyAPI_FUNC(char) Py_GetSepA(const char *);
  9. +
  10. +PyAPI_FUNC(void) Py_NormalizeSepsW(wchar_t *);
  11. +PyAPI_FUNC(void) Py_NormalizeSepsA(char *);
  12. +
  13. /* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
  14. * exit functions.
  15. diff -Naur Python-3.8.0-orig/Lib/ntpath.py Python-3.8.0/Lib/ntpath.py
  16. --- Python-3.8.0-orig/Lib/ntpath.py 2019-10-14 16:34:47.000000000 +0300
  17. +++ Python-3.8.0/Lib/ntpath.py 2019-10-22 10:02:37.157712800 +0300
  18. @@ -11,9 +11,7 @@
  19. curdir = '.'
  20. pardir = '..'
  21. extsep = '.'
  22. -sep = '\\'
  23. pathsep = ';'
  24. -altsep = '/'
  25. defpath = '.;C:\\bin'
  26. devnull = 'nul'
  27. @@ -23,6 +21,15 @@
  28. import genericpath
  29. from genericpath import *
  30. +if sys.platform == "win32" and "MSYSTEM" in os.environ:
  31. + sep = '/'
  32. + altsep = '\\'
  33. +else:
  34. + sep = '\\'
  35. + altsep = '/'
  36. +bsep = str.encode(sep)
  37. +baltsep = str.encode(altsep)
  38. +
  39. __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
  40. "basename","dirname","commonprefix","getsize","getmtime",
  41. "getatime","getctime", "islink","exists","lexists","isdir","isfile",
  42. @@ -33,9 +40,27 @@
  43. def _get_bothseps(path):
  44. if isinstance(path, bytes):
  45. - return b'\\/'
  46. + return bsep+baltsep
  47. + else:
  48. + return sep+altsep
  49. +
  50. +def _get_sep(path):
  51. + if isinstance(path, bytes):
  52. + return bsep
  53. + else:
  54. + return sep
  55. +
  56. +def _get_altsep(path):
  57. + if isinstance(path, bytes):
  58. + return baltsep
  59. + else:
  60. + return altsep
  61. +
  62. +def _get_colon(path):
  63. + if isinstance(path, bytes):
  64. + return b':'
  65. else:
  66. - return '\\/'
  67. + return ':'
  68. # Normalize the case of a pathname and map slashes to backslashes.
  69. # Other normalizations (such as optimizing '../' away) are not done
  70. @@ -47,9 +72,9 @@
  71. Makes all characters lowercase and all slashes into backslashes."""
  72. s = os.fspath(s)
  73. if isinstance(s, bytes):
  74. - return s.replace(b'/', b'\\').lower()
  75. + return s.replace(baltsep, bsep).lower()
  76. else:
  77. - return s.replace('/', '\\').lower()
  78. + return s.replace(altsep, sep).lower()
  79. # Return whether a path is absolute.
  80. @@ -68,14 +93,9 @@
  81. # Join two (or more) paths.
  82. def join(path, *paths):
  83. path = os.fspath(path)
  84. - if isinstance(path, bytes):
  85. - sep = b'\\'
  86. - seps = b'\\/'
  87. - colon = b':'
  88. - else:
  89. - sep = '\\'
  90. - seps = '\\/'
  91. - colon = ':'
  92. + sep = _get_sep(path)
  93. + seps = _get_bothseps(path)
  94. + colon = _get_colon(path)
  95. try:
  96. if not paths:
  97. path[:0] + sep #23780: Ensure compatible data type even if p is null.
  98. @@ -134,14 +154,9 @@
  99. """
  100. p = os.fspath(p)
  101. if len(p) >= 2:
  102. - if isinstance(p, bytes):
  103. - sep = b'\\'
  104. - altsep = b'/'
  105. - colon = b':'
  106. - else:
  107. - sep = '\\'
  108. - altsep = '/'
  109. - colon = ':'
  110. + sep = _get_sep(p)
  111. + altsep = _get_altsep(p)
  112. + colon = _get_colon(p)
  113. normp = p.replace(altsep, sep)
  114. if (normp[0:2] == sep*2) and (normp[2:3] != sep):
  115. # is a UNC path:
  116. @@ -195,9 +210,9 @@
  117. def splitext(p):
  118. p = os.fspath(p)
  119. if isinstance(p, bytes):
  120. - return genericpath._splitext(p, b'\\', b'/', b'.')
  121. + return genericpath._splitext(p, bsep, baltsep, b'.')
  122. else:
  123. - return genericpath._splitext(p, '\\', '/', '.')
  124. + return genericpath._splitext(p, sep, altsep, '.')
  125. splitext.__doc__ = genericpath._splitext.__doc__
  126. @@ -442,15 +457,13 @@
  127. def normpath(path):
  128. """Normalize path, eliminating double slashes, etc."""
  129. path = os.fspath(path)
  130. + sep = _get_sep(path)
  131. + altsep = _get_altsep(path)
  132. if isinstance(path, bytes):
  133. - sep = b'\\'
  134. - altsep = b'/'
  135. curdir = b'.'
  136. pardir = b'..'
  137. special_prefixes = (b'\\\\.\\', b'\\\\?\\')
  138. else:
  139. - sep = '\\'
  140. - altsep = '/'
  141. curdir = '.'
  142. pardir = '..'
  143. special_prefixes = ('\\\\.\\', '\\\\?\\')
  144. @@ -620,6 +620,7 @@
  145. # strip the prefix anyway.
  146. if ex.winerror == initial_winerror:
  147. path = spath
  148. + path = normpath(path)
  149. return path
  150. @@ -645,12 +658,11 @@
  151. def relpath(path, start=None):
  152. """Return a relative version of a path"""
  153. path = os.fspath(path)
  154. + sep = _get_sep(path)
  155. if isinstance(path, bytes):
  156. - sep = b'\\'
  157. curdir = b'.'
  158. pardir = b'..'
  159. else:
  160. - sep = '\\'
  161. curdir = '.'
  162. pardir = '..'
  163. @@ -705,13 +717,11 @@
  164. raise ValueError('commonpath() arg is an empty sequence')
  165. paths = tuple(map(os.fspath, paths))
  166. + sep = _get_sep(paths[0])
  167. + altsep = _get_altsep(paths[0])
  168. if isinstance(paths[0], bytes):
  169. - sep = b'\\'
  170. - altsep = b'/'
  171. curdir = b'.'
  172. else:
  173. - sep = '\\'
  174. - altsep = '/'
  175. curdir = '.'
  176. try:
  177. diff -Naur Python-3.8.0-orig/Modules/posixmodule.c Python-3.8.0/Modules/posixmodule.c
  178. --- Python-3.8.0-orig/Modules/posixmodule.c 2019-10-22 10:00:56.988936800 +0300
  179. +++ Python-3.8.0/Modules/posixmodule.c 2019-10-22 10:02:37.547713500 +0300
  180. @@ -3438,6 +3438,7 @@
  181. return PyErr_SetFromWindowsErr(0);
  182. }
  183. + Py_NormalizeSepsW(wbuf2);
  184. PyObject *resobj = PyUnicode_FromWideChar(wbuf2, len);
  185. if (wbuf2 != wbuf) {
  186. PyMem_RawFree(wbuf2);
  187. @@ -3886,6 +3887,7 @@
  188. result = GetFullPathNameW(path->wide, result, woutbufp, &wtemp);
  189. }
  190. if (result) {
  191. + Py_NormalizeSepsW(woutbufp);
  192. v = PyUnicode_FromWideChar(woutbufp, wcslen(woutbufp));
  193. if (path->narrow)
  194. Py_SETREF(v, PyUnicode_EncodeFSDefault(v));
  195. @@ -3962,6 +3964,7 @@
  196. target_path = tmp;
  197. }
  198. + Py_NormalizeSepsW(target_path);
  199. result = PyUnicode_FromWideChar(target_path, result_length);
  200. if (result && path->narrow) {
  201. Py_SETREF(result, PyUnicode_EncodeFSDefault(result));
  202. diff -Naur Python-3.8.0-orig/Python/initconfig.c Python-3.8.0/Python/initconfig.c
  203. --- Python-3.8.0-orig/Python/initconfig.c 2019-10-14 16:34:47.000000000 +0300
  204. +++ Python-3.8.0/Python/initconfig.c 2019-10-22 10:02:37.968914200 +0300
  205. @@ -98,7 +98,7 @@
  206. "PYTHONDEVMODE: enable the development mode.\n"
  207. "PYTHONPYCACHEPREFIX: root directory for bytecode cache (pyc) files.\n";
  208. -#if defined(MS_WINDOWS)
  209. +#if defined(_MSC_VER)
  210. # define PYTHONHOMEHELP "<prefix>\\python{major}{minor}"
  211. #else
  212. # define PYTHONHOMEHELP "<prefix>/lib/pythonX.X"
  213. @@ -1129,7 +1129,7 @@
  214. }
  215. /* Last fall back: hardcoded name */
  216. -#ifdef MS_WINDOWS
  217. +#ifdef _MSC_VER
  218. const wchar_t *default_program_name = L"python";
  219. #else
  220. const wchar_t *default_program_name = L"python3";
  221. diff -Naur Python-3.8.0-orig/Python/pathconfig.c Python-3.8.0/Python/pathconfig.c
  222. --- Python-3.8.0-orig/Python/pathconfig.c 2019-10-14 16:34:47.000000000 +0300
  223. +++ Python-3.8.0/Python/pathconfig.c 2019-10-22 10:02:38.358914900 +0300
  224. @@ -13,6 +13,114 @@
  225. extern "C" {
  226. #endif
  227. +#ifdef __MINGW32__
  228. +#define wcstok wcstok_s
  229. +#include <windows.h>
  230. +#endif
  231. +
  232. +char
  233. +Py_GetSepA(const char *name)
  234. +{
  235. + char* msystem = (char*)2; /* So that non Windows use / as sep */
  236. + static char sep = '\0';
  237. +#ifdef _WIN32
  238. + /* https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx
  239. + * The "\\?\" prefix .. indicate that the path should be passed to the system with minimal
  240. + * modification, which means that you cannot use forward slashes to represent path separators
  241. + */
  242. + if (name != NULL && memcmp(name, "\\\\?\\", sizeof("\\\\?\\") - sizeof(char)) == 0)
  243. + {
  244. + return '\\';
  245. + }
  246. +#endif
  247. + if (sep != '\0')
  248. + return sep;
  249. +#if defined(__MINGW32__)
  250. + msystem = Py_GETENV("MSYSTEM");
  251. +#endif
  252. + if (msystem != NULL)
  253. + sep = '/';
  254. + else
  255. + sep = '\\';
  256. + return sep;
  257. +}
  258. +
  259. +static char
  260. +Py_GetAltSepA(const char *name)
  261. +{
  262. + char sep = Py_GetSepA(name);
  263. + if (sep == '/')
  264. + return '\\';
  265. + return '/';
  266. +}
  267. +
  268. +void
  269. +Py_NormalizeSepsA(char *name)
  270. +{
  271. + char sep = Py_GetSepA(name);
  272. + char altsep = Py_GetAltSepA(name);
  273. + char* seps;
  274. + if (strlen(name) > 1 && name[1] == ':') {
  275. + name[0] = toupper(name[0]);
  276. + }
  277. + seps = strchr(name, altsep);
  278. + while(seps) {
  279. + *seps = sep;
  280. + seps = strchr(seps, altsep);
  281. + }
  282. +}
  283. +
  284. +wchar_t
  285. +Py_GetSepW(const wchar_t *name)
  286. +{
  287. + char* msystem = (char*)2; /* So that non Windows use / as sep */
  288. + static wchar_t sep = L'\0';
  289. +#ifdef _WIN32
  290. + /* https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx
  291. + * The "\\?\" prefix .. indicate that the path should be passed to the system with minimal
  292. + * modification, which means that you cannot use forward slashes to represent path separators
  293. + */
  294. + if (name != NULL && memcmp(name, L"\\\\?\\", sizeof(L"\\\\?\\") - sizeof(wchar_t)) == 0)
  295. + {
  296. + return L'\\';
  297. + }
  298. +#endif
  299. + if (sep != L'\0')
  300. + return sep;
  301. +#if defined(__MINGW32__)
  302. + msystem = Py_GETENV("MSYSTEM");
  303. +#endif
  304. + if (msystem != NULL)
  305. + sep = L'/';
  306. + else
  307. + sep = L'\\';
  308. + return sep;
  309. +}
  310. +
  311. +static wchar_t
  312. +Py_GetAltSepW(const wchar_t *name)
  313. +{
  314. + char sep = Py_GetSepW(name);
  315. + if (sep == L'/')
  316. + return L'\\';
  317. + return L'/';
  318. +}
  319. +
  320. +void
  321. +Py_NormalizeSepsW(wchar_t *name)
  322. +{
  323. + wchar_t sep = Py_GetSepW(name);
  324. + wchar_t altsep = Py_GetAltSepW(name);
  325. + wchar_t* seps;
  326. + if (wcslen(name) > 1 && name[1] == L':') {
  327. + name[0] = towupper(name[0]);
  328. + }
  329. + seps = wcschr(name, altsep);
  330. + while(seps) {
  331. + *seps = sep;
  332. + seps = wcschr(seps, altsep);
  333. + }
  334. +}
  335. _PyPathConfig _Py_path_config = _PyPathConfig_INIT;
  336. #ifdef MS_WINDOWS
  337. @@ -560,6 +668,7 @@
  338. if (_Py_path_config.program_name == NULL) {
  339. Py_FatalError("Py_SetProgramName() failed: out of memory");
  340. }
  341. + Py_NormalizeSepsW(_Py_path_config.program_name);
  342. }
  343. void
  344. diff -Naur Python-3.8.0-orig/Python/traceback.c Python-3.8.0/Python/traceback.c
  345. --- Python-3.8.0-orig/Python/traceback.c 2019-10-14 16:34:47.000000000 +0300
  346. +++ Python-3.8.0/Python/traceback.c 2019-10-22 10:02:39.170116300 +0300
  347. @@ -315,7 +315,7 @@
  348. filepath = PyBytes_AS_STRING(filebytes);
  349. /* Search tail of filename in sys.path before giving up */
  350. - tail = strrchr(filepath, SEP);
  351. + tail = strrchr(filepath, Py_GetSepA(filepath));
  352. if (tail == NULL)
  353. tail = filepath;
  354. else