diff --git a/pydk-all.sh b/pydk-all.sh index a089738..50c4fdf 100755 --- a/pydk-all.sh +++ b/pydk-all.sh @@ -10,26 +10,28 @@ else echo "not bash, those previously rising errors are ash/sh/dash/... flavours" fi -PYMINOR_DEFAULT=9 +PYMINOR_DEFAULT=8 +PYMICRO=10 + +PYMINOR_DEFAULT=7 +PYMICRO=10 export PYMAJOR=3 export PYMINOR=${PYMINOR:-$PYMINOR_DEFAULT} +export PYVER=${PYMAJOR}.${PYMINOR}.${PYMICRO} -if echo $PYMINOR |grep -q 7 +#echo $PYMINOR |grep -q 7 +if false then -# python 3.7.x - export PYVER=${PYMAJOR}.${PYMINOR}.7 + # python 3.7.x export OPENSSL_VERSION="1.0.2t" else -# python 3.8.x / 3.9.x - #export PYVER=${PYMAJOR}.${PYMINOR}.5 - export PYVER=${PYMAJOR}.${PYMINOR}.1 + # python 3.8.x / 3.9.x export OPENSSL_VERSION="1.1.1h" fi export LIBFFI_VERSION=3.3 - export HOST_TRIPLET=x86_64-linux-gnu export HOST_TAG=linux-x86_64 @@ -54,7 +56,6 @@ export HOME=${PYTHONPYCACHEPREFIX} #UNITS="unit" UNITS="" - # select a place for android build export ENV=aosp ROOT="${ORIGIN}/${ENV}" @@ -280,6 +281,9 @@ if [ -f CMakeLists.txt ] then echo " * using previous CMakeLists.txt in $(pwd)" else + +# TODO: check wasm/wasi cmake + CMAKE_CACHE_ARGS "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true" + cat > CMakeLists.txt < ${HOST}/${ABI_NAME}.sh < string. + Activates/queries locale processing. + """ ++ if category>LC_ALL: ++ raise Error('_locale emulation invalid category') ++ + if value not in (None, '', 'C'): + raise Error('_locale emulation only supports "C" locale') + return 'C' diff --git a/sources.aosp/Python-3.7.10/Lib_modulefinder.py.diff b/sources.aosp/Python-3.7.10/Lib_modulefinder.py.diff new file mode 100644 index 0000000..c7337c4 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Lib_modulefinder.py.diff @@ -0,0 +1,31 @@ +--- Python-3.7.10/Lib/modulefinder.py 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Lib/modulefinder.py 2021-03-04 15:06:27.764071657 +0100 +@@ -185,8 +185,8 @@ + if q: + self.msgout(4, "find_head_package ->", (q, tail)) + return q, tail +- self.msgout(4, "raise ImportError: No module named", qname) +- raise ImportError("No module named " + qname) ++ self.msgout(4, "raise ImportError: No module named1", qname) ++ raise ImportError("No module named1 " + qname) + + def load_tail(self, q, tail): + self.msgin(4, "load_tail", q, tail) +@@ -199,7 +199,7 @@ + m = self.import_module(head, mname, m) + if not m: + self.msgout(4, "raise ImportError: No module named", mname) +- raise ImportError("No module named " + mname) ++ raise ImportError("No module named2 " + mname) + self.msgout(4, "load_tail ->", m) + return m + +@@ -215,7 +215,7 @@ + subname = "%s.%s" % (m.__name__, sub) + submod = self.import_module(sub, subname, m) + if not submod: +- raise ImportError("No module named " + subname) ++ raise ImportError("No module named3 " + subname) + + def find_all_submodules(self, m): + if not m.__path__: diff --git a/sources.aosp/Python-3.7.10/Lib_platform.py.diff b/sources.aosp/Python-3.7.10/Lib_platform.py.diff new file mode 100644 index 0000000..c676d3b --- /dev/null +++ b/sources.aosp/Python-3.7.10/Lib_platform.py.diff @@ -0,0 +1,12 @@ +--- Python-3.7.10/Lib/platform.py 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Lib/platform.py 2021-03-04 15:06:27.768071521 +0100 +@@ -188,6 +188,9 @@ + The file is read and scanned in chunks of chunksize bytes. + + """ ++ if hasattr(sys, 'getandroidapilevel'): ++ return 'libc', f'{sys.getandroidapilevel()}-bionic' ++ + V = _comparable_version + if hasattr(os.path, 'realpath'): + # Python 2.2 introduced os.path.realpath(); it is used diff --git a/sources.aosp/Python-3.7.10/Lib_runpy.py.diff b/sources.aosp/Python-3.7.10/Lib_runpy.py.diff new file mode 100644 index 0000000..bbead00 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Lib_runpy.py.diff @@ -0,0 +1,11 @@ +--- Python-3.7.10/Lib/runpy.py 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Lib/runpy.py 2021-03-04 15:06:27.772071386 +0100 +@@ -133,7 +133,7 @@ + msg = "Error while finding module specification for {!r} ({}: {})" + raise error(msg.format(mod_name, type(ex).__name__, ex)) from ex + if spec is None: +- raise error("No module named %s" % mod_name) ++ raise error("No module named5 %s" % mod_name) + if spec.submodule_search_locations is not None: + if mod_name == "__main__" or mod_name.endswith(".__main__"): + raise error("Cannot use package as __main__ module") diff --git a/sources.aosp/Python-3.7.10/Lib_test_test_zlib.py.diff b/sources.aosp/Python-3.7.10/Lib_test_test_zlib.py.diff new file mode 100644 index 0000000..4e3e16c --- /dev/null +++ b/sources.aosp/Python-3.7.10/Lib_test_test_zlib.py.diff @@ -0,0 +1,18 @@ +--- Python-3.7.10/Lib/test/test_zlib.py 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Lib/test/test_zlib.py 2021-03-04 15:06:27.776071250 +0100 +@@ -437,7 +437,14 @@ + sync_opt = ['Z_NO_FLUSH', 'Z_SYNC_FLUSH', 'Z_FULL_FLUSH', + 'Z_PARTIAL_FLUSH'] + +- ver = tuple(int(v) for v in zlib.ZLIB_RUNTIME_VERSION.split('.')) ++ v = zlib.ZLIB_RUNTIME_VERSION.split('-', 1)[0].split('.') ++ if len(v) < 4: ++ v.append('0') ++ elif not v[-1].isnumeric(): ++ v[-1] = '0' ++ ++ ver = tuple(map(int, v)) ++ + # Z_BLOCK has a known failure prior to 1.2.5.3 + if ver >= (1, 2, 5, 3): + sync_opt.append('Z_BLOCK') diff --git a/sources.aosp/Python-3.7.10/Makefile.pre.in.diff b/sources.aosp/Python-3.7.10/Makefile.pre.in.diff new file mode 100644 index 0000000..c822fde --- /dev/null +++ b/sources.aosp/Python-3.7.10/Makefile.pre.in.diff @@ -0,0 +1,11 @@ +--- Python-3.7.10/Makefile.pre.in 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Makefile.pre.in 2021-03-04 15:06:27.780071115 +0100 +@@ -226,7 +226,7 @@ + PY3LIBRARY= @PY3LIBRARY@ + DLLLIBRARY= @DLLLIBRARY@ + LDLIBRARYDIR= @LDLIBRARYDIR@ +-INSTSONAME= @INSTSONAME@ ++INSTSONAME= libpython$(LDVERSION).so + + + LIBS= @LIBS@ diff --git a/sources.aosp/Python-3.7.10/Modules__decimal_libmpdec_io.c.diff b/sources.aosp/Python-3.7.10/Modules__decimal_libmpdec_io.c.diff new file mode 100644 index 0000000..4a69e32 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Modules__decimal_libmpdec_io.c.diff @@ -0,0 +1,19 @@ +--- Python-3.7.10/Modules/_decimal/libmpdec/io.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Modules/_decimal/libmpdec/io.c 2021-03-04 15:06:27.784070980 +0100 +@@ -871,9 +871,15 @@ + if (*spec->sep) { + return 0; + } ++ + spec->type = *cp++; + spec->type = (spec->type == 'N') ? 'G' : 'g'; +- lc = localeconv(); ++#if __ANDROID__ && (__ANDROID_API__ < 21) ++ #warning "====================================== broken_localeconv ================================" ++ lc = broken_localeconv(); ++#else ++ lc = localeconv(); //PATCHED ++#endif + spec->dot = lc->decimal_point; + spec->sep = lc->thousands_sep; + spec->grouping = lc->grouping; diff --git a/sources.aosp/Python-3.7.10/Modules__localemodule.c.diff b/sources.aosp/Python-3.7.10/Modules__localemodule.c.diff new file mode 100644 index 0000000..f43d28f --- /dev/null +++ b/sources.aosp/Python-3.7.10/Modules__localemodule.c.diff @@ -0,0 +1,31 @@ +--- Python-3.7.10/Modules/_localemodule.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Modules/_localemodule.c 2021-03-04 15:06:27.788070843 +0100 +@@ -96,6 +96,10 @@ + PyErr_SetString(Error, "invalid locale category"); + return NULL; + } ++#else ++#ifdef __ANDROID__ ++ return PyUnicode_FromFormat("%s", "C"); ++#endif + #endif + + if (locale) { +@@ -213,7 +217,16 @@ + } + + /* if LC_NUMERIC is different in the C library, use saved value */ +- l = localeconv(); ++//PMPP API<21 ++#if __ANDROID__ && (__ANDROID_API__ < 21) ++ /* Don't even try on Android's broken locale.h. */ ++ /* maybe can use c++ stdlib to implement */ ++ l = broken_localeconv(); ++#else ++ /* if LC_NUMERIC is different in the C library, use saved value */ ++ l = localeconv(); //PATCHED ++#endif ++//PMPP API<21 + + /* hopefully, the localeconv result survives the C library calls + involved herein */ diff --git a/sources.aosp/Python-3.7.10/Modules_main.c.diff b/sources.aosp/Python-3.7.10/Modules_main.c.diff new file mode 100644 index 0000000..04781ab --- /dev/null +++ b/sources.aosp/Python-3.7.10/Modules_main.c.diff @@ -0,0 +1,35 @@ +--- Python-3.7.10/Modules/main.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Modules/main.c 2021-03-04 15:06:27.792070707 +0100 +@@ -62,6 +62,14 @@ + #define WCSTOK wcstok + #endif + ++//PMPP API<21 ++#ifdef __ANDROID__ ++ #if __ANDROID_API__ < 21 ++ #define NO_LOCALECONV 1 ++ #endif ++#endif ++//PMPP API<21 ++ + /* For Py_GetArgcArgv(); set by main() */ + static wchar_t **orig_argv = NULL; + static int orig_argc = 0; +@@ -2095,13 +2103,15 @@ + int init_utf8_mode = Py_UTF8Mode; + _PyCoreConfig save_config = _PyCoreConfig_INIT; + int res = -1; +- ++#if NO_LOCALECONV ++ char *oldloc = NULL; ++#else + char *oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL)); + if (oldloc == NULL) { + pymain->err = _Py_INIT_NO_MEMORY(); + goto done; + } +- ++#endif + /* Reconfigure the locale to the default for this process */ + _Py_SetLocaleFromEnv(LC_ALL); + diff --git a/sources.aosp/Python-3.7.10/Modules_mmapmodule.c.diff b/sources.aosp/Python-3.7.10/Modules_mmapmodule.c.diff new file mode 100644 index 0000000..fb339b6 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Modules_mmapmodule.c.diff @@ -0,0 +1,15 @@ +--- Python-3.7.10/Modules/mmapmodule.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Modules/mmapmodule.c 2021-03-04 15:06:27.796070572 +0100 +@@ -79,6 +79,12 @@ + # define MAP_ANONYMOUS MAP_ANON + #endif + ++//PMPP API<21 ++#if __ANDROID_API__ < 21 ++ extern void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset); ++#endif ++//PMPP API<21 ++ + typedef enum + { + ACCESS_DEFAULT, diff --git a/sources.aosp/Python-3.7.10/Modules_posixmodule.c.diff b/sources.aosp/Python-3.7.10/Modules_posixmodule.c.diff new file mode 100644 index 0000000..b94b777 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Modules_posixmodule.c.diff @@ -0,0 +1,104 @@ +--- Python-3.7.10/Modules/posixmodule.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Modules/posixmodule.c 2021-03-04 15:06:27.804070300 +0100 +@@ -51,7 +51,6 @@ + disguised Unix interface). Refer to the library manual and\n\ + corresponding Unix manual entries for more information on calls."); + +- + #ifdef HAVE_SYS_UIO_H + #include + #endif +@@ -242,6 +241,8 @@ + #ifdef HAVE_LSTAT + extern int lstat(const char *, struct stat *); + #endif /* HAVE_LSTAT */ ++#else ++#warning "unistd" + #endif /* !HAVE_UNISTD_H */ + + #endif /* !_MSC_VER */ +@@ -481,6 +482,11 @@ + #endif + } + ++//PMPP API<21 ++#if __ANDROID_API__ < 21 ++ //extern ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count); ++#endif ++//PMPP API<21 + + #ifdef MS_WINDOWS + /* defined in fileutils.c */ +@@ -5935,6 +5941,51 @@ + for both the master and slave ends. + [clinic start generated code]*/ + ++#ifdef __ANDROID__ ++ static PyObject * ++ os_openpty_impl(PyObject *module) ++ { ++ int master_fd = -1, slave_fd = -1; ++ char * slave_name; ++ PyOS_sighandler_t sig_saved; ++ ++ master_fd = open("/dev/ptmx", O_RDWR | O_NONBLOCK | O_NOCTTY); /* open master */ ++ if (master_fd < 0) ++ goto posix_error; ++ ++ sig_saved = PyOS_setsig(SIGCHLD, SIG_DFL); ++ ++ if (unlockpt(master_fd) < 0) { ++ PyOS_setsig(SIGCHLD, sig_saved); ++ goto posix_error; ++ } ++ ++ PyOS_setsig(SIGCHLD, sig_saved); ++ ++ slave_name = ptsname(master_fd); /* get name of slave */ ++ if (slave_name == NULL) ++ goto posix_error; ++ ++ slave_fd = _Py_open(slave_name, O_RDWR | O_NOCTTY); /* open slave */ ++ if (slave_fd == -1) ++ goto error; ++ ++ if (_Py_set_inheritable(master_fd, 0, NULL) < 0) ++ goto posix_error; ++ ++ return Py_BuildValue("(ii)", master_fd, slave_fd); ++ ++ posix_error: ++ posix_error(); ++ error: ++ if (master_fd != -1) ++ close(master_fd); ++ if (slave_fd != -1) ++ close(slave_fd); ++ return NULL; ++ } ++#else ++ + static PyObject * + os_openpty_impl(PyObject *module) + /*[clinic end generated code: output=98841ce5ec9cef3c input=f3d99fd99e762907]*/ +@@ -6023,7 +6074,7 @@ + return NULL; + } + #endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX) */ +- ++#endif + + #ifdef HAVE_FORKPTY + /*[clinic input] +@@ -9109,7 +9160,11 @@ + errno = result; + } + #else ++ #if __ANDROID_API__ < 21 ++ result = ftruncate(path->narrow, length); ++ #else + result = truncate(path->narrow, length); ++ #endif + #endif + _Py_END_SUPPRESS_IPH + Py_END_ALLOW_THREADS diff --git a/sources.aosp/Python-3.7.10/Modules_signalmodule.c.diff b/sources.aosp/Python-3.7.10/Modules_signalmodule.c.diff new file mode 100644 index 0000000..9607d72 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Modules_signalmodule.c.diff @@ -0,0 +1,16 @@ +--- Python-3.7.10/Modules/signalmodule.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Modules/signalmodule.c 2021-03-04 15:06:27.808070166 +0100 +@@ -40,6 +40,13 @@ + #define SIG_ERR ((PyOS_sighandler_t)(-1)) + #endif + ++//PMPP API<21 ++#if __ANDROID_API__ < 21 ++ #define SIGRTMIN 32 ++ #define SIGRTMAX _NSIG ++#endif ++//PMPP API<21 ++ + #ifndef NSIG + # if defined(_NSIG) + # define NSIG _NSIG /* For BSD/SysV */ diff --git a/sources.aosp/Python-3.7.10/Modules_timemodule.c.diff b/sources.aosp/Python-3.7.10/Modules_timemodule.c.diff new file mode 100644 index 0000000..1d9afce --- /dev/null +++ b/sources.aosp/Python-3.7.10/Modules_timemodule.c.diff @@ -0,0 +1,18 @@ +--- Python-3.7.10/Modules/timemodule.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Modules/timemodule.c 2021-03-04 15:06:27.812070028 +0100 +@@ -494,6 +494,7 @@ + } + + #ifndef HAVE_TIMEGM ++#ifndef CRYSTAX + static time_t + timegm(struct tm *p) + { +@@ -505,6 +506,7 @@ + ((p->tm_year-1)/100)*86400 + ((p->tm_year+299)/400)*86400; + } + #endif ++#endif + + PyDoc_STRVAR(gmtime_doc, + "gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n\ diff --git a/sources.aosp/Python-3.7.10/Python_clinic_import.c.h.diff b/sources.aosp/Python-3.7.10/Python_clinic_import.c.h.diff new file mode 100644 index 0000000..09a21a7 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Python_clinic_import.c.h.diff @@ -0,0 +1,12 @@ +--- Python-3.7.10/Python/clinic/import.c.h 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Python/clinic/import.c.h 2021-03-04 15:06:27.816069893 +0100 +@@ -286,6 +286,9 @@ + &spec, &file)) { + goto exit; + } ++#if __ANDROID__ ++ printf("290: _imp_create_dynamic: %s\n",PyUnicode_AsUTF8(PyObject_GetAttrString(spec, "name"))); ++#endif + return_value = _imp_create_dynamic_impl(module, spec, file); + + exit: diff --git a/sources.aosp/Python-3.7.10/Python_dynload_shlib.c.diff b/sources.aosp/Python-3.7.10/Python_dynload_shlib.c.diff new file mode 100644 index 0000000..7a7ad75 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Python_dynload_shlib.c.diff @@ -0,0 +1,19 @@ +--- Python-3.7.10/Python/dynload_shlib.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Python/dynload_shlib.c 2021-03-04 15:06:27.820069757 +0100 +@@ -37,9 +37,13 @@ + #ifdef __CYGWIN__ + ".dll", + #else /* !__CYGWIN__ */ +- "." SOABI ".so", +- ".abi" PYTHON_ABI_STRING ".so", +- ".so", ++ #if __ANDROID__ ++ "." SOABI ".so", ++ #else ++ "." SOABI ".so", ++ ".abi" PYTHON_ABI_STRING ".so", ++ ".so", ++ #endif + #endif /* __CYGWIN__ */ + NULL, + }; diff --git a/sources.aosp/Python-3.7.10/Python_fileutils.c.diff b/sources.aosp/Python-3.7.10/Python_fileutils.c.diff new file mode 100644 index 0000000..0a7b59f --- /dev/null +++ b/sources.aosp/Python-3.7.10/Python_fileutils.c.diff @@ -0,0 +1,25 @@ +--- Python-3.7.10/Python/fileutils.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Python/fileutils.c 2021-03-04 15:06:27.824069622 +0100 +@@ -32,6 +32,16 @@ + int _Py_open_cloexec_works = -1; + #endif + ++//PMPP API<21 ++#ifdef __ANDROID__ ++ #if __ANDROID_API__ < 21 ++ #ifndef CRYSTAX ++ #define NO_LOCALECONV 1 ++ #endif ++ #endif ++#endif ++//PMPP API<21 ++ + PyObject * + _Py_device_encoding(int fd) + { +@@ -1863,3 +1873,5 @@ + PyMem_Free(oldloc); + return res; + } ++ ++ diff --git a/sources.aosp/Python-3.7.10/Python_formatter_unicode.c.diff b/sources.aosp/Python-3.7.10/Python_formatter_unicode.c.diff new file mode 100644 index 0000000..381f50a --- /dev/null +++ b/sources.aosp/Python-3.7.10/Python_formatter_unicode.c.diff @@ -0,0 +1,10 @@ +--- Python-3.7.10/Python/formatter_unicode.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Python/formatter_unicode.c 2021-03-04 15:06:27.828069486 +0100 +@@ -689,6 +689,7 @@ + + static const char no_grouping[1] = {CHAR_MAX}; + ++ + /* Find the decimal point character(s?), thousands_separator(s?), and + grouping description, either for the current locale if type is + LT_CURRENT_LOCALE, a hard-coded locale if LT_DEFAULT_LOCALE or diff --git a/sources.aosp/Python-3.7.10/Python_import.c.diff b/sources.aosp/Python-3.7.10/Python_import.c.diff new file mode 100644 index 0000000..7380961 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Python_import.c.diff @@ -0,0 +1,13 @@ +--- Python-3.7.10/Python/import.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Python/import.c 2021-03-04 15:06:27.832069351 +0100 +@@ -2151,7 +2151,9 @@ + Py_DECREF(name); + return NULL; + } +- ++#if __ANDROID__ ++ printf("2151: name: %s, path:%s\n",PyUnicode_AsUTF8(name),PyUnicode_AsUTF8(path)); ++#endif + mod = _PyImport_FindExtensionObject(name, path); + if (mod != NULL || PyErr_Occurred()) { + Py_DECREF(name); diff --git a/sources.aosp/Python-3.7.10/Python_importdl.c.diff b/sources.aosp/Python-3.7.10/Python_importdl.c.diff new file mode 100644 index 0000000..48c41dc --- /dev/null +++ b/sources.aosp/Python-3.7.10/Python_importdl.c.diff @@ -0,0 +1,12 @@ +--- Python-3.7.10/Python/importdl.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Python/importdl.c 2021-03-04 15:06:27.836069216 +0100 +@@ -126,6 +126,9 @@ + pathbytes = PyUnicode_EncodeFSDefault(path); + if (pathbytes == NULL) + goto error; ++#if __ANDROID__ ++#warning "FIXME: supress lib from "PyInit_lib" ++#endif + exportfunc = _PyImport_FindSharedFuncptr(hook_prefix, name_buf, + PyBytes_AS_STRING(pathbytes), + fp); diff --git a/sources.aosp/Python-3.7.10/Python_pystrtod.c.diff b/sources.aosp/Python-3.7.10/Python_pystrtod.c.diff new file mode 100644 index 0000000..56e79d7 --- /dev/null +++ b/sources.aosp/Python-3.7.10/Python_pystrtod.c.diff @@ -0,0 +1,18 @@ +--- Python-3.7.10/Python/pystrtod.c 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Python/pystrtod.c 2021-03-04 15:06:27.840069079 +0100 +@@ -177,8 +177,14 @@ + + fail_pos = NULL; + +- locale_data = localeconv(); ++#if __ANDROID__ && (__ANDROID_API__ < 21) ++ locale_data = broken_localeconv(); + decimal_point = locale_data->decimal_point; ++#else ++ locale_data = localeconv(); //PATCHED ++ decimal_point = locale_data->decimal_point; ++#endif // __ANDROID_API__ ++ + decimal_point_len = strlen(decimal_point); + + assert(decimal_point_len != 0); diff --git a/sources.aosp/Python-3.7.10/Tools_scripts_update_file.py.diff b/sources.aosp/Python-3.7.10/Tools_scripts_update_file.py.diff new file mode 100644 index 0000000..4c198aa --- /dev/null +++ b/sources.aosp/Python-3.7.10/Tools_scripts_update_file.py.diff @@ -0,0 +1,16 @@ +--- Python-3.7.10/Tools/scripts/update_file.py 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/Tools/scripts/update_file.py 2021-03-04 15:06:27.848068808 +0100 +@@ -11,8 +11,11 @@ + + + def main(old_path, new_path): +- with open(old_path, 'rb') as f: +- old_contents = f.read() ++ if os.path.exists(old_path): ++ with open(old_path, 'rb') as f: ++ old_contents = f.read() ++ else: ++ old_contents ="" + with open(new_path, 'rb') as f: + new_contents = f.read() + if old_contents != new_contents: diff --git a/sources.aosp/Python-3.7.10/setup.py.diff b/sources.aosp/Python-3.7.10/setup.py.diff new file mode 100644 index 0000000..097cc4f --- /dev/null +++ b/sources.aosp/Python-3.7.10/setup.py.diff @@ -0,0 +1,129 @@ +--- Python-3.7.10/setup.py 2021-02-16 02:29:22.000000000 +0100 ++++ Python-3.7.10-aosp/setup.py 2021-03-04 15:06:27.844068943 +0100 +@@ -774,7 +774,7 @@ + # pwd(3) + exts.append( Extension('pwd', ['pwdmodule.c']) ) + # grp(3) +- exts.append( Extension('grp', ['grpmodule.c']) ) ++ # __ANDROID__ exts.append( Extension('grp', ['grpmodule.c']) ) + # spwd, shadow passwords + if (config_h_vars.get('HAVE_GETSPNAM', False) or + config_h_vars.get('HAVE_GETSPENT', False)): +@@ -902,12 +902,12 @@ + missing.append('readline') + + # crypt module. +- +- if self.compiler.find_library_file(lib_dirs, 'crypt'): +- libs = ['crypt'] +- else: +- libs = [] +- exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) ) ++#__ANDROID__ ++# if self.compiler.find_library_file(lib_dirs, 'crypt'): ++# libs = ['crypt'] ++# else: ++# libs = [] ++# exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) ) + + # CSV files + exts.append( Extension('_csv', ['_csv.c']) ) +@@ -1179,7 +1179,7 @@ + '/usr/local/include/sqlite3', + ] + if cross_compiling: +- sqlite_inc_paths = [] ++ sqlite_inc_paths = [f'{os.environ["PREFIX"]}/include/sqlite3'] + MIN_SQLITE_VERSION_NUMBER = (3, 3, 9) + MIN_SQLITE_VERSION = ".".join([str(x) + for x in MIN_SQLITE_VERSION_NUMBER]) +@@ -1450,37 +1450,12 @@ + # You can upgrade zlib to version 1.1.4 yourself by going to + # http://www.gzip.org/zlib/ + zlib_inc = find_file('zlib.h', [], inc_dirs) +- have_zlib = False +- if zlib_inc is not None: +- zlib_h = zlib_inc[0] + '/zlib.h' +- version = '"0.0.0"' +- version_req = '"1.1.3"' +- if host_platform == 'darwin' and is_macosx_sdk_path(zlib_h): +- zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:]) +- with open(zlib_h) as fp: +- while 1: +- line = fp.readline() +- if not line: +- break +- if line.startswith('#define ZLIB_VERSION'): +- version = line.split()[2] +- break +- if version >= version_req: +- if (self.compiler.find_library_file(lib_dirs, 'z')): +- if host_platform == "darwin": +- zlib_extra_link_args = ('-Wl,-search_paths_first',) +- else: +- zlib_extra_link_args = () +- exts.append( Extension('zlib', ['zlibmodule.c'], +- libraries = ['z'], +- extra_link_args = zlib_extra_link_args)) +- have_zlib = True +- else: +- missing.append('zlib') +- else: +- missing.append('zlib') +- else: +- missing.append('zlib') ++ #__ANDROID__ ++ zlib_extra_link_args = () ++ exts.append( Extension('zlib', ['zlibmodule.c'], ++ libraries = ['z'], ++ extra_link_args = zlib_extra_link_args)) ++ have_zlib = True + + # Helper module for various ascii-encoders. Uses zlib for an optimized + # crc32 if we have it. Otherwise binascii uses its own. +@@ -1498,23 +1473,10 @@ + extra_link_args = extra_link_args) ) + + # Gustavo Niemeyer's bz2 module. +- if (self.compiler.find_library_file(lib_dirs, 'bz2')): +- if host_platform == "darwin": +- bz2_extra_link_args = ('-Wl,-search_paths_first',) +- else: +- bz2_extra_link_args = () +- exts.append( Extension('_bz2', ['_bz2module.c'], +- libraries = ['bz2'], +- extra_link_args = bz2_extra_link_args) ) +- else: +- missing.append('_bz2') ++ exts.append( Extension('_bz2', ['_bz2module.c'], libraries = ['bz2'], extra_link_args = [f"-L{os.environ['PREFIX']}/lib",f"-I{os.environ['PREFIX']}/include"]) ) + + # LZMA compression support. +- if self.compiler.find_library_file(lib_dirs, 'lzma'): +- exts.append( Extension('_lzma', ['_lzmamodule.c'], +- libraries = ['lzma']) ) +- else: +- missing.append('_lzma') ++ exts.append( Extension('_lzma', ['_lzmamodule.c'], libraries = ['lzma'], extra_link_args = [f"-L{os.environ['PREFIX']}/lib",f"-I{os.environ['PREFIX']}/include"]) ) + + # Interface to the Expat XML parser + # +@@ -1669,17 +1631,8 @@ + missing.append('_tkinter') + + # Build the _uuid module if possible +- uuid_incs = find_file("uuid.h", inc_dirs, ["/usr/include/uuid"]) +- if uuid_incs is not None: +- if self.compiler.find_library_file(lib_dirs, 'uuid'): +- uuid_libs = ['uuid'] +- else: +- uuid_libs = [] +- self.extensions.append(Extension('_uuid', ['_uuidmodule.c'], +- libraries=uuid_libs, +- include_dirs=uuid_incs)) +- else: +- missing.append('_uuid') ++ #__ANDROID__ ++ missing.append('_uuid') + + ## # Uncomment these lines if you want to play with xxmodule.c + ## ext = Extension('xx', ['xxmodule.c']) diff --git a/sources.aosp/Python-3.8.10/Lib_locale.py.diff b/sources.aosp/Python-3.8.10/Lib_locale.py.diff new file mode 100644 index 0000000..ff7b0f4 --- /dev/null +++ b/sources.aosp/Python-3.8.10/Lib_locale.py.diff @@ -0,0 +1,23 @@ +--- cpython-3.8.5/Lib/locale.py 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Lib/locale.py 2020-08-27 18:54:48.108970638 +0200 +@@ -46,6 +46,10 @@ + + from _locale import * + ++ if hasattr(sys, 'getandroidapilevel'): ++ if sys.getandroidapilevel()<21: ++ raise ImportError("android-api19") ++ + except ImportError: + + # Locale emulation +@@ -88,6 +92,9 @@ + """ setlocale(integer,string=None) -> string. + Activates/queries locale processing. + """ ++ if category>LC_ALL: ++ raise Error('_locale emulation invalid category') ++ + if value not in (None, '', 'C'): + raise Error('_locale emulation only supports "C" locale') + return 'C' diff --git a/sources.aosp/Python-3.8.10/Lib_modulefinder.py.diff b/sources.aosp/Python-3.8.10/Lib_modulefinder.py.diff new file mode 100644 index 0000000..9b6e67b --- /dev/null +++ b/sources.aosp/Python-3.8.10/Lib_modulefinder.py.diff @@ -0,0 +1,31 @@ +--- cpython-3.8.5/Lib/modulefinder.py 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Lib/modulefinder.py 2020-08-27 18:54:48.110970614 +0200 +@@ -239,8 +239,8 @@ + if q: + self.msgout(4, "find_head_package ->", (q, tail)) + return q, tail +- self.msgout(4, "raise ImportError: No module named", qname) +- raise ImportError("No module named " + qname) ++ self.msgout(4, "raise ImportError: No module named1", qname) ++ raise ImportError("No module named1 " + qname) + + def load_tail(self, q, tail): + self.msgin(4, "load_tail", q, tail) +@@ -253,7 +253,7 @@ + m = self.import_module(head, mname, m) + if not m: + self.msgout(4, "raise ImportError: No module named", mname) +- raise ImportError("No module named " + mname) ++ raise ImportError("No module named2 " + mname) + self.msgout(4, "load_tail ->", m) + return m + +@@ -269,7 +269,7 @@ + subname = "%s.%s" % (m.__name__, sub) + submod = self.import_module(sub, subname, m) + if not submod: +- raise ImportError("No module named " + subname) ++ raise ImportError("No module named3 " + subname) + + def find_all_submodules(self, m): + if not m.__path__: diff --git a/sources.aosp/Python-3.8.10/Lib_os.py.diff b/sources.aosp/Python-3.8.10/Lib_os.py.diff new file mode 100644 index 0000000..2e93922 --- /dev/null +++ b/sources.aosp/Python-3.8.10/Lib_os.py.diff @@ -0,0 +1,15 @@ +--- cpython-3.8.5/Lib/os.py 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Lib/os.py 2020-08-27 18:54:48.112970590 +0200 +@@ -1112,3 +1112,12 @@ + cookie, + nt._remove_dll_directory + ) ++ ++try: ++ getpid ++except: ++ import sys ++ print("210: os.getpid() is broken",file=sys.stderr) ++ def getpid(): ++ return int(open('/proc/self/stat').read().split(' ')[0]) ++ diff --git a/sources.aosp/Python-3.8.10/Lib_platform.py.diff b/sources.aosp/Python-3.8.10/Lib_platform.py.diff new file mode 100644 index 0000000..ff4a05b --- /dev/null +++ b/sources.aosp/Python-3.8.10/Lib_platform.py.diff @@ -0,0 +1,14 @@ +--- cpython-3.8.5/Lib/platform.py 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Lib/platform.py 2020-08-27 18:54:48.115970555 +0200 +@@ -171,7 +171,10 @@ + The file is read and scanned in chunks of chunksize bytes. + + """ +- if executable is None: ++ ++ if hasattr(sys, 'getandroidapilevel'): ++ return 'libc', f'{sys.getandroidapilevel()}-bionic' ++ elif executable is None: + try: + ver = os.confstr('CS_GNU_LIBC_VERSION') + # parse 'glibc 2.28' as ('glibc', '2.28') diff --git a/sources.aosp/Python-3.8.10/Lib_runpy.py.diff b/sources.aosp/Python-3.8.10/Lib_runpy.py.diff new file mode 100644 index 0000000..2dfea8c --- /dev/null +++ b/sources.aosp/Python-3.8.10/Lib_runpy.py.diff @@ -0,0 +1,11 @@ +--- cpython-3.8.5/Lib/runpy.py 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Lib/runpy.py 2020-08-27 18:54:48.117970531 +0200 +@@ -135,7 +135,7 @@ + msg = "Error while finding module specification for {!r} ({}: {})" + raise error(msg.format(mod_name, type(ex).__name__, ex)) from ex + if spec is None: +- raise error("No module named %s" % mod_name) ++ raise error("No module named5 %s" % mod_name) + if spec.submodule_search_locations is not None: + if mod_name == "__main__" or mod_name.endswith(".__main__"): + raise error("Cannot use package as __main__ module") diff --git a/sources.aosp/Python-3.8.10/Lib_test_test_zlib.py.diff b/sources.aosp/Python-3.8.10/Lib_test_test_zlib.py.diff new file mode 100644 index 0000000..63b73dc --- /dev/null +++ b/sources.aosp/Python-3.8.10/Lib_test_test_zlib.py.diff @@ -0,0 +1,18 @@ +--- cpython-3.8.5/Lib/test/test_zlib.py 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Lib/test/test_zlib.py 2020-08-27 18:54:48.119970508 +0200 +@@ -438,7 +438,14 @@ + sync_opt = ['Z_NO_FLUSH', 'Z_SYNC_FLUSH', 'Z_FULL_FLUSH', + 'Z_PARTIAL_FLUSH'] + +- ver = tuple(int(v) for v in zlib.ZLIB_RUNTIME_VERSION.split('.')) ++ v = zlib.ZLIB_RUNTIME_VERSION.split('-', 1)[0].split('.') ++ if len(v) < 4: ++ v.append('0') ++ elif not v[-1].isnumeric(): ++ v[-1] = '0' ++ ++ ver = tuple(map(int, v)) ++ + # Z_BLOCK has a known failure prior to 1.2.5.3 + if ver >= (1, 2, 5, 3): + sync_opt.append('Z_BLOCK') diff --git a/sources.aosp/Python-3.8.10/Makefile.pre.in.diff b/sources.aosp/Python-3.8.10/Makefile.pre.in.diff new file mode 100644 index 0000000..51be2cb --- /dev/null +++ b/sources.aosp/Python-3.8.10/Makefile.pre.in.diff @@ -0,0 +1,11 @@ +--- cpython-3.8.5/Makefile.pre.in 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Makefile.pre.in 2020-08-27 18:54:48.122970472 +0200 +@@ -225,7 +225,7 @@ + PY3LIBRARY= @PY3LIBRARY@ + DLLLIBRARY= @DLLLIBRARY@ + LDLIBRARYDIR= @LDLIBRARYDIR@ +-INSTSONAME= @INSTSONAME@ ++INSTSONAME= libpython$(LDVERSION).so + + + LIBS= @LIBS@ diff --git a/sources.aosp/Python-3.8.10/Modules__decimal_libmpdec_io.c.diff b/sources.aosp/Python-3.8.10/Modules__decimal_libmpdec_io.c.diff new file mode 100644 index 0000000..0def590 --- /dev/null +++ b/sources.aosp/Python-3.8.10/Modules__decimal_libmpdec_io.c.diff @@ -0,0 +1,19 @@ +--- cpython-3.8.5/Modules/_decimal/libmpdec/io.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Modules/_decimal/libmpdec/io.c 2020-08-27 18:54:48.124970449 +0200 +@@ -871,9 +871,15 @@ + if (*spec->sep) { + return 0; + } ++ + spec->type = *cp++; + spec->type = (spec->type == 'N') ? 'G' : 'g'; +- lc = localeconv(); ++#if __ANDROID__ && (__ANDROID_API__ < 21) ++ #warning "====================================== broken_localeconv ================================" ++ lc = broken_localeconv(); ++#else ++ lc = localeconv(); //PATCHED ++#endif + spec->dot = lc->decimal_point; + spec->sep = lc->thousands_sep; + spec->grouping = lc->grouping; diff --git a/sources.aosp/Python-3.8.10/Modules__localemodule.c.diff b/sources.aosp/Python-3.8.10/Modules__localemodule.c.diff new file mode 100644 index 0000000..7cfa12c --- /dev/null +++ b/sources.aosp/Python-3.8.10/Modules__localemodule.c.diff @@ -0,0 +1,31 @@ +--- cpython-3.8.5/Modules/_localemodule.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Modules/_localemodule.c 2020-08-27 18:54:48.127970413 +0200 +@@ -97,6 +97,10 @@ + PyErr_SetString(Error, "invalid locale category"); + return NULL; + } ++#else ++#ifdef __ANDROID__ ++ return PyUnicode_FromFormat("%s", "C"); ++#endif + #endif + + if (locale) { +@@ -214,7 +218,16 @@ + } + + /* if LC_NUMERIC is different in the C library, use saved value */ +- lc = localeconv(); ++//PMPP API<21 ++#if __ANDROID__ && (__ANDROID_API__ < 21) ++ /* Don't even try on Android's broken locale.h. */ ++ /* maybe can use c++ stdlib to implement */ ++ lc = broken_localeconv(); ++#else ++ /* if LC_NUMERIC is different in the C library, use saved value */ ++ lc = localeconv(); //PATCHED ++#endif ++//PMPP API<21 + + /* hopefully, the localeconv result survives the C library calls + involved herein */ diff --git a/sources.aosp/Python-3.8.10/Modules_mmapmodule.c.diff b/sources.aosp/Python-3.8.10/Modules_mmapmodule.c.diff new file mode 100644 index 0000000..2c4bd7a --- /dev/null +++ b/sources.aosp/Python-3.8.10/Modules_mmapmodule.c.diff @@ -0,0 +1,15 @@ +--- cpython-3.8.5/Modules/mmapmodule.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Modules/mmapmodule.c 2020-08-27 18:54:48.129970390 +0200 +@@ -79,6 +79,12 @@ + # define MAP_ANONYMOUS MAP_ANON + #endif + ++//PMPP API<21 ++#if __ANDROID_API__ < 21 ++ extern void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset); ++#endif ++//PMPP API<21 ++ + typedef enum + { + ACCESS_DEFAULT, diff --git a/sources.aosp/Python-3.8.10/Modules_posixmodule.c.diff b/sources.aosp/Python-3.8.10/Modules_posixmodule.c.diff new file mode 100644 index 0000000..1fdd4b2 --- /dev/null +++ b/sources.aosp/Python-3.8.10/Modules_posixmodule.c.diff @@ -0,0 +1,95 @@ +--- cpython-3.8.5/Modules/posixmodule.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Modules/posixmodule.c 2020-08-27 18:54:48.134970330 +0200 +@@ -63,7 +63,6 @@ + disguised Unix interface). Refer to the library manual and\n\ + corresponding Unix manual entries for more information on calls."); + +- + #ifdef HAVE_SYS_UIO_H + #include + #endif +@@ -497,6 +496,11 @@ + #endif + } + ++//PMPP API<21 ++#if __ANDROID_API__ < 21 ++ //extern ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count); ++#endif ++//PMPP API<21 + + #ifdef MS_WINDOWS + /* defined in fileutils.c */ +@@ -6664,6 +6668,51 @@ + for both the master and slave ends. + [clinic start generated code]*/ + ++#ifdef __ANDROID__ ++ static PyObject * ++ os_openpty_impl(PyObject *module) ++ { ++ int master_fd = -1, slave_fd = -1; ++ char * slave_name; ++ PyOS_sighandler_t sig_saved; ++ ++ master_fd = open("/dev/ptmx", O_RDWR | O_NONBLOCK | O_NOCTTY); /* open master */ ++ if (master_fd < 0) ++ goto posix_error; ++ ++ sig_saved = PyOS_setsig(SIGCHLD, SIG_DFL); ++ ++ if (unlockpt(master_fd) < 0) { ++ PyOS_setsig(SIGCHLD, sig_saved); ++ goto posix_error; ++ } ++ ++ PyOS_setsig(SIGCHLD, sig_saved); ++ ++ slave_name = ptsname(master_fd); /* get name of slave */ ++ if (slave_name == NULL) ++ goto posix_error; ++ ++ slave_fd = _Py_open(slave_name, O_RDWR | O_NOCTTY); /* open slave */ ++ if (slave_fd == -1) ++ goto error; ++ ++ if (_Py_set_inheritable(master_fd, 0, NULL) < 0) ++ goto posix_error; ++ ++ return Py_BuildValue("(ii)", master_fd, slave_fd); ++ ++ posix_error: ++ posix_error(); ++ error: ++ if (master_fd != -1) ++ close(master_fd); ++ if (slave_fd != -1) ++ close(slave_fd); ++ return NULL; ++ } ++#else ++ + static PyObject * + os_openpty_impl(PyObject *module) + /*[clinic end generated code: output=98841ce5ec9cef3c input=f3d99fd99e762907]*/ +@@ -6752,7 +6801,7 @@ + return NULL; + } + #endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX) */ +- ++#endif + + #ifdef HAVE_FORKPTY + /*[clinic input] +@@ -9972,7 +10021,11 @@ + errno = result; + } + #else ++ #if __ANDROID_API__ < 21 ++ result = ftruncate(path->narrow, length); ++ #else + result = truncate(path->narrow, length); ++ #endif + #endif + _Py_END_SUPPRESS_IPH + Py_END_ALLOW_THREADS diff --git a/sources.aosp/Python-3.8.10/Modules_readline.c.diff b/sources.aosp/Python-3.8.10/Modules_readline.c.diff new file mode 100644 index 0000000..b90987e --- /dev/null +++ b/sources.aosp/Python-3.8.10/Modules_readline.c.diff @@ -0,0 +1,13 @@ +--- cpython-org/Modules/readline.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5/Modules/readline.c 2020-09-12 04:05:18.987939681 +0200 +@@ -1179,7 +1179,9 @@ + int has_input = 0, err = 0; + + while (!has_input) +- { struct timeval timeout = {0, 100000}; /* 0.1 seconds */ ++ { ++ ++ struct timeval timeout = {0, 10000}; /* 0.01 seconds */ + + /* [Bug #1552726] Only limit the pause if an input hook has been + defined. */ diff --git a/sources.aosp/Python-3.8.10/Modules_signalmodule.c.diff b/sources.aosp/Python-3.8.10/Modules_signalmodule.c.diff new file mode 100644 index 0000000..5093999 --- /dev/null +++ b/sources.aosp/Python-3.8.10/Modules_signalmodule.c.diff @@ -0,0 +1,16 @@ +--- cpython-3.8.5/Modules/signalmodule.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Modules/signalmodule.c 2020-08-27 18:54:48.136970307 +0200 +@@ -44,6 +44,13 @@ + #define SIG_ERR ((PyOS_sighandler_t)(-1)) + #endif + ++//PMPP API<21 ++#if __ANDROID_API__ < 21 ++ #define SIGRTMIN 32 ++ #define SIGRTMAX _NSIG ++#endif ++//PMPP API<21 ++ + #ifndef NSIG + # if defined(_NSIG) + # define NSIG _NSIG /* For BSD/SysV */ diff --git a/sources.aosp/Python-3.8.10/Modules_timemodule.c.diff b/sources.aosp/Python-3.8.10/Modules_timemodule.c.diff new file mode 100644 index 0000000..5e5a7ae --- /dev/null +++ b/sources.aosp/Python-3.8.10/Modules_timemodule.c.diff @@ -0,0 +1,18 @@ +--- cpython-3.8.5/Modules/timemodule.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Modules/timemodule.c 2020-08-27 18:54:48.139970271 +0200 +@@ -461,6 +461,7 @@ + } + + #ifndef HAVE_TIMEGM ++#ifndef CRYSTAX + static time_t + timegm(struct tm *p) + { +@@ -472,6 +473,7 @@ + ((p->tm_year-1)/100)*86400 + ((p->tm_year+299)/400)*86400; + } + #endif ++#endif + + PyDoc_STRVAR(gmtime_doc, + "gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n\ diff --git a/sources.aosp/Python-3.8.10/Parser_tokenizer.c.diff b/sources.aosp/Python-3.8.10/Parser_tokenizer.c.diff new file mode 100644 index 0000000..f30a7e9 --- /dev/null +++ b/sources.aosp/Python-3.8.10/Parser_tokenizer.c.diff @@ -0,0 +1,11 @@ +--- cpython-org/Parser/tokenizer.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5/Parser/tokenizer.c 2020-09-12 04:08:54.368934692 +0200 +@@ -846,7 +846,7 @@ + return Py_CHARMASK(*tok->cur++); + } + if (tok->prompt != NULL) { +- char *newtok = PyOS_Readline(stdin, stdout, tok->prompt); ++ char *newtok = PyOS_Readline(tok->fp? tok->fp : stdin, stdout, tok->prompt); + if (newtok != NULL) { + char *translated = translate_newlines(newtok, 0, tok); + PyMem_FREE(newtok); diff --git a/sources.aosp/Python-3.8.10/Python_dynload_shlib.c.diff b/sources.aosp/Python-3.8.10/Python_dynload_shlib.c.diff new file mode 100644 index 0000000..1910763 --- /dev/null +++ b/sources.aosp/Python-3.8.10/Python_dynload_shlib.c.diff @@ -0,0 +1,20 @@ +--- cpython-3.8.5/Python/dynload_shlib.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Python/dynload_shlib.c 2020-08-27 18:54:48.141970248 +0200 +@@ -34,6 +34,9 @@ + */ + + const char *_PyImport_DynLoadFiletab[] = { ++#if __ANDROID__ ++ "." SOABI ".so", ++#else + #ifdef __CYGWIN__ + ".dll", + #else /* !__CYGWIN__ */ +@@ -44,6 +47,7 @@ + ".abi" PYTHON_ABI_STRING ".so", + ".so", + #endif /* __CYGWIN__ */ ++#endif /* __ANDROID__ */ + NULL, + }; + diff --git a/sources.aosp/Python-3.8.10/Python_fileutils.c.diff b/sources.aosp/Python-3.8.10/Python_fileutils.c.diff new file mode 100644 index 0000000..ba6a41c --- /dev/null +++ b/sources.aosp/Python-3.8.10/Python_fileutils.c.diff @@ -0,0 +1,25 @@ +--- cpython-3.8.5/Python/fileutils.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Python/fileutils.c 2020-08-27 18:54:48.143970224 +0200 +@@ -51,6 +51,16 @@ + } + + ++//PMPP API<21 ++#ifdef __ANDROID__ ++ #if __ANDROID_API__ < 21 ++ #ifndef CRYSTAX ++ #define NO_LOCALECONV 1 ++ #endif ++ #endif ++#endif ++//PMPP API<21 ++ + PyObject * + _Py_device_encoding(int fd) + { +@@ -1992,3 +2002,5 @@ + PyMem_Free(oldloc); + return res; + } ++ ++ diff --git a/sources.aosp/Python-3.8.10/Python_formatter_unicode.c.diff b/sources.aosp/Python-3.8.10/Python_formatter_unicode.c.diff new file mode 100644 index 0000000..513d1d5 --- /dev/null +++ b/sources.aosp/Python-3.8.10/Python_formatter_unicode.c.diff @@ -0,0 +1,10 @@ +--- cpython-3.8.5/Python/formatter_unicode.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Python/formatter_unicode.c 2020-08-27 18:54:48.145970201 +0200 +@@ -690,6 +690,7 @@ + + static const char no_grouping[1] = {CHAR_MAX}; + ++ + /* Find the decimal point character(s?), thousands_separator(s?), and + grouping description, either for the current locale if type is + LT_CURRENT_LOCALE, a hard-coded locale if LT_DEFAULT_LOCALE or diff --git a/sources.aosp/Python-3.8.10/Tools_scripts_update_file.py.diff b/sources.aosp/Python-3.8.10/Tools_scripts_update_file.py.diff new file mode 100644 index 0000000..e3025a7 --- /dev/null +++ b/sources.aosp/Python-3.8.10/Tools_scripts_update_file.py.diff @@ -0,0 +1,16 @@ +--- cpython-3.8.5/Tools/scripts/update_file.py 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/Tools/scripts/update_file.py 2020-08-27 18:54:48.154970094 +0200 +@@ -11,8 +11,11 @@ + + + def main(old_path, new_path): +- with open(old_path, 'rb') as f: +- old_contents = f.read() ++ if os.path.exists(old_path): ++ with open(old_path, 'rb') as f: ++ old_contents = f.read() ++ else: ++ old_contents ="" + with open(new_path, 'rb') as f: + new_contents = f.read() + if old_contents != new_contents: diff --git a/sources.aosp/Python-3.8.10/setup.py.diff b/sources.aosp/Python-3.8.10/setup.py.diff new file mode 100644 index 0000000..aeb55bc --- /dev/null +++ b/sources.aosp/Python-3.8.10/setup.py.diff @@ -0,0 +1,131 @@ +--- cpython-3.8.5/setup.py 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5-aosp/setup.py 2020-08-27 18:54:48.152970118 +0200 +@@ -45,7 +45,7 @@ + MACOS = (HOST_PLATFORM == 'darwin') + AIX = (HOST_PLATFORM.startswith('aix')) + VXWORKS = ('vxworks' in HOST_PLATFORM) +- ++ANDROID = hasattr(sys, 'getandroidapilevel') + + SUMMARY = """ + Python is an interpreted, interactive, object-oriented programming +@@ -1032,6 +1032,9 @@ + # the encryption. + return + ++ if ANDROID: ++ return ++ + if self.compiler.find_library_file(self.lib_dirs, 'crypt'): + libs = ['crypt'] + else: +@@ -1358,7 +1361,10 @@ + '/usr/local/include/sqlite3', + ] + if CROSS_COMPILING: +- sqlite_inc_paths = [] ++ if ANDROID: ++ sqlite_inc_paths = [f'{os.environ["APKUSR"]}/include/sqlite3'] ++ else: ++ sqlite_inc_paths = [] + MIN_SQLITE_VERSION_NUMBER = (3, 7, 2) + MIN_SQLITE_VERSION = ".".join([str(x) + for x in MIN_SQLITE_VERSION_NUMBER]) +@@ -1497,37 +1503,44 @@ + # You can upgrade zlib to version 1.1.4 yourself by going to + # http://www.gzip.org/zlib/ + zlib_inc = find_file('zlib.h', [], self.inc_dirs) +- have_zlib = False +- if zlib_inc is not None: +- zlib_h = zlib_inc[0] + '/zlib.h' +- version = '"0.0.0"' +- version_req = '"1.1.3"' +- if MACOS and is_macosx_sdk_path(zlib_h): +- zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:]) +- with open(zlib_h) as fp: +- while 1: +- line = fp.readline() +- if not line: +- break +- if line.startswith('#define ZLIB_VERSION'): +- version = line.split()[2] +- break +- if version >= version_req: +- if (self.compiler.find_library_file(self.lib_dirs, 'z')): +- if MACOS: +- zlib_extra_link_args = ('-Wl,-search_paths_first',) ++ if ANDROID: ++ zlib_extra_link_args = () ++ exts.append( Extension('zlib', ['zlibmodule.c'], ++ libraries = ['z'], ++ extra_link_args = zlib_extra_link_args)) ++ have_zlib = True ++ else: ++ have_zlib = False ++ if zlib_inc is not None: ++ zlib_h = zlib_inc[0] + '/zlib.h' ++ version = '"0.0.0"' ++ version_req = '"1.1.3"' ++ if MACOS and is_macosx_sdk_path(zlib_h): ++ zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:]) ++ with open(zlib_h) as fp: ++ while 1: ++ line = fp.readline() ++ if not line: ++ break ++ if line.startswith('#define ZLIB_VERSION'): ++ version = line.split()[2] ++ break ++ if version >= version_req: ++ if (self.compiler.find_library_file(self.lib_dirs, 'z')): ++ if MACOS: ++ zlib_extra_link_args = ('-Wl,-search_paths_first',) ++ else: ++ zlib_extra_link_args = () ++ self.add(Extension('zlib', ['zlibmodule.c'], ++ libraries=['z'], ++ extra_link_args=zlib_extra_link_args)) ++ have_zlib = True + else: +- zlib_extra_link_args = () +- self.add(Extension('zlib', ['zlibmodule.c'], +- libraries=['z'], +- extra_link_args=zlib_extra_link_args)) +- have_zlib = True ++ self.missing.append('zlib') + else: + self.missing.append('zlib') + else: + self.missing.append('zlib') +- else: +- self.missing.append('zlib') + + # Helper module for various ascii-encoders. Uses zlib for an optimized + # crc32 if we have it. Otherwise binascii uses its own. +@@ -1553,6 +1566,8 @@ + self.add(Extension('_bz2', ['_bz2module.c'], + libraries=['bz2'], + extra_link_args=bz2_extra_link_args)) ++ elif ANDROID: ++ exts.append( Extension('_bz2', ['_bz2module.c'], libraries = ['bz2'], extra_link_args = [f"-L{os.environ['APKUSR']}/lib",f"-I{os.environ['APKUSR']}/include"]) ) + else: + self.missing.append('_bz2') + +@@ -1560,6 +1575,8 @@ + if self.compiler.find_library_file(self.lib_dirs, 'lzma'): + self.add(Extension('_lzma', ['_lzmamodule.c'], + libraries=['lzma'])) ++ elif ANDROID: ++ exts.append( Extension('_lzma', ['_lzmamodule.c'], libraries = ['lzma'], extra_link_args = [f"-L{os.environ['APKUSR']}/lib",f"-I{os.environ['APKUSR']}/include"]) ) + else: + self.missing.append('_lzma') + +@@ -1682,6 +1699,8 @@ + self.add(Extension('_uuid', ['_uuidmodule.c'], + libraries=uuid_libs, + include_dirs=uuid_incs)) ++ elif ANDROID: ++ self.missing.append('_uuid') + else: + self.missing.append('_uuid') + diff --git a/sources.aosp/panda3d.aosp.sh b/sources.aosp/panda3d.aosp.sh index 5fa1549..8a95c85 100644 --- a/sources.aosp/panda3d.aosp.sh +++ b/sources.aosp/panda3d.aosp.sh @@ -54,7 +54,9 @@ ExternalProject_Add( DOWNLOAD_NO_PROGRESS ${CI} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${HOST} -DPYTHON_EXECUTABLE=${HOST}/bin/python${PYMAJOR}.${PYMINOR} ${PANDA3D_CMAKE_ARGS} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${HOST} \ +-DCMAKE_CURRENT_BINARY_DIR=CMAKE_INSTALL_BINDIR=${HOST}/bin -DCMAKE_INSTALL_INCLUDEDIR=${HOST}/include -DCMAKE_INSTALL_LIBDIR=${HOST}/lib \ +-DCMAKE_INSTALL_BINDIR=${HOST}/bin -DPYTHON_EXECUTABLE=${HOST}/bin/python${PYMAJOR}.${PYMINOR} ${PANDA3D_CMAKE_ARGS} ) else() @@ -166,7 +168,9 @@ END -DHAVE_OPENAL=Yes -DHAVE_HARFBUZZ=Yes -DHAVE_FREETYPE=Yes -DHAVE_BULLET=Yes\ -DHAVE_PYTHON=Yes -DHAVE_VORBIS=No\ -DCMAKE_TOOLCHAIN_FILE=${BUILD_PREFIX}-${ABI_NAME}/${unit}.toolchain.cmake\ - -DCMAKE_INSTALL_PREFIX=${APKUSR} ${PANDA3D_CMAKE_ARGS_COMMON}" + -DCMAKE_INSTALL_PREFIX=${APKUSR} \ + -DCMAKE_INSTALL_INCLUDEDIR=${APKUSR}/include -DCMAKE_INSTALL_BINDIR=${APKUSR}/lib -DCMAKE_INSTALL_BINDIR=${APKUSR}/bin \ + ${PANDA3D_CMAKE_ARGS_COMMON}" #HAVE_ASSIMP export VORBISDIR=${APKUSR} diff --git a/sources.aosp/python3.aosp.sh b/sources.aosp/python3.aosp.sh index 3c19e82..4fdafb0 100644 --- a/sources.aosp/python3.aosp.sh +++ b/sources.aosp/python3.aosp.sh @@ -48,6 +48,16 @@ END python_module_setup_local () { + if echo $PYMINOR|grep -q 7 + then + HAVE_MPDEC='#' + else + HAVE_MPDEC="" + fi + + # 3.7 + _decimal/libmpdec/mpalloc.c + # 3.8 - _decimal/libmpdec/mpalloc.c + cat > $1 <> $1 <" % (self._lock, len(self._waiters)) +@@ -343,7 +344,9 @@ + + """ + if not self._is_owned(): +- raise RuntimeError("cannot notify on un-acquired lock") ++ pass ++ #raise RuntimeError("cannot notify on un-acquired lock") ++ + all_waiters = self._waiters + waiters_to_notify = _deque(_islice(all_waiters, n)) + if not waiters_to_notify: diff --git a/sources.wasm/Python-3.7.10/Makefile.pre.in.diff b/sources.wasm/Python-3.7.10/Makefile.pre.in.diff new file mode 100644 index 0000000..dfcaa79 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Makefile.pre.in.diff @@ -0,0 +1,11 @@ +--- Python-3.7.10/Makefile.pre.in 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Makefile.pre.in 2021-05-04 18:24:59.674254567 +0200 +@@ -226,7 +226,7 @@ + PY3LIBRARY= @PY3LIBRARY@ + DLLLIBRARY= @DLLLIBRARY@ + LDLIBRARYDIR= @LDLIBRARYDIR@ +-INSTSONAME= @INSTSONAME@ ++INSTSONAME=libpython$(LDVERSION).so + + + LIBS= @LIBS@ diff --git a/sources.wasm/Python-3.7.10/Modules__ctypes_ctypes.h.diff b/sources.wasm/Python-3.7.10/Modules__ctypes_ctypes.h.diff new file mode 100644 index 0000000..eafe15d --- /dev/null +++ b/sources.wasm/Python-3.7.10/Modules__ctypes_ctypes.h.diff @@ -0,0 +1,18 @@ +--- Python-3.7.10/Modules/_ctypes/ctypes.h 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Modules/_ctypes/ctypes.h 2021-05-04 18:24:59.676254547 +0200 +@@ -53,7 +53,15 @@ + PyObject *b_objects; /* dictionary of references we need to keep, or Py_None */ + union value b_value; + }; ++#if FFI_CLOSURES ++#else + ++ #define ffi_closure void ++ #define ffi_closure_free(writable) "" ++ #define ffi_closure_alloc(size, code) "" ++ #define ffi_prep_closure_loc(...) "" ++ ++#endif + typedef struct { + PyObject_VAR_HEAD + ffi_closure *pcl_write; /* the C callable, writeable */ diff --git a/sources.wasm/Python-3.7.10/Modules__hashopenssl.c.diff b/sources.wasm/Python-3.7.10/Modules__hashopenssl.c.diff new file mode 100644 index 0000000..9837aa9 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Modules__hashopenssl.c.diff @@ -0,0 +1,14 @@ +--- Python-3.7.10/Modules/_hashopenssl.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Modules/_hashopenssl.c 2021-05-04 18:24:59.677254537 +0200 +@@ -33,8 +33,11 @@ + /*[clinic end generated code: output=da39a3ee5e6b4b0d input=c2b4ff081bac4be1]*/ + + #ifndef OPENSSL_THREADS ++#if __EMSCRIPTEN__ ++#else + # error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" + #endif ++#endif + + #define MUNCH_SIZE INT_MAX + diff --git a/sources.wasm/Python-3.7.10/Modules__posixsubprocess.c.diff b/sources.wasm/Python-3.7.10/Modules__posixsubprocess.c.diff new file mode 100644 index 0000000..b5993b0 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Modules__posixsubprocess.c.diff @@ -0,0 +1,30 @@ +--- Python-3.7.10/Modules/_posixsubprocess.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Modules/_posixsubprocess.c 2021-05-04 18:24:59.683254475 +0200 +@@ -552,7 +552,7 @@ + } + } + +- ++#ifdef HAVE_FORK + static PyObject * + subprocess_fork_exec(PyObject* self, PyObject *args) + { +@@ -755,7 +755,7 @@ + Py_XDECREF(gc_module); + return NULL; + } +- ++#endif + + PyDoc_STRVAR(subprocess_fork_exec_doc, + "fork_exec(args, executable_list, close_fds, cwd, env,\n\ +@@ -786,7 +786,9 @@ + + + static PyMethodDef module_methods[] = { ++#ifdef HAVE_FORK + {"fork_exec", subprocess_fork_exec, METH_VARARGS, subprocess_fork_exec_doc}, ++#endif + {NULL, NULL} /* sentinel */ + }; + diff --git a/sources.wasm/Python-3.7.10/Modules__ssl.c.diff b/sources.wasm/Python-3.7.10/Modules__ssl.c.diff new file mode 100644 index 0000000..8bc663e --- /dev/null +++ b/sources.wasm/Python-3.7.10/Modules__ssl.c.diff @@ -0,0 +1,14 @@ +--- Python-3.7.10/Modules/_ssl.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Modules/_ssl.c 2021-05-04 18:24:59.697254331 +0200 +@@ -76,8 +76,11 @@ + #endif + + #ifndef OPENSSL_THREADS ++#if __EMSCRIPTEN__ ++#else + # error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" + #endif ++#endif + + /* SSL error object */ + static PyObject *PySSLErrorObject; diff --git a/sources.wasm/Python-3.7.10/Modules_posixmodule.c.diff b/sources.wasm/Python-3.7.10/Modules_posixmodule.c.diff new file mode 100644 index 0000000..aa35501 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Modules_posixmodule.c.diff @@ -0,0 +1,24 @@ +--- Python-3.7.10/Modules/posixmodule.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Modules/posixmodule.c 2021-05-04 18:24:59.679254516 +0200 +@@ -154,6 +154,12 @@ + # endif + #endif /* MS_WINDOWS */ + ++#if GOSH_MOVE_THEM ++ #pragma message "XXX Gosh I wish these were all moved into pyconfig.h" ++ #ifdef HAVE_FORKPTY ++ #undef HAVE_FORKPTY ++ #endif ++#else + /* Various compilers have only certain posix functions */ + /* XXX Gosh I wish these were all moved into pyconfig.h */ + #if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */ +@@ -193,7 +199,7 @@ + #define HAVE_TTYNAME 1 + #endif /* _MSC_VER */ + #endif /* ! __WATCOMC__ || __QNX__ */ +- ++#endif // my GOSH + + /*[clinic input] + # one of the few times we lie about this name! diff --git a/sources.wasm/Python-3.7.10/Modules_readline.c.diff b/sources.wasm/Python-3.7.10/Modules_readline.c.diff new file mode 100644 index 0000000..de52442 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Modules_readline.c.diff @@ -0,0 +1,14 @@ +--- Python-3.7.10/Modules/readline.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Modules/readline.c 2021-05-04 18:24:59.686254444 +0200 +@@ -1184,6 +1184,11 @@ + + completed_input_string = not_done_reading; + ++ #ifdef __EMSCRIPTEN__ ++ #error no no no i won't go there ++ #endif ++ ++ + while (completed_input_string == not_done_reading) { + int has_input = 0, err = 0; + diff --git a/sources.wasm/Python-3.7.10/Modules_selectmodule.c.diff b/sources.wasm/Python-3.7.10/Modules_selectmodule.c.diff new file mode 100644 index 0000000..9197e1f --- /dev/null +++ b/sources.wasm/Python-3.7.10/Modules_selectmodule.c.diff @@ -0,0 +1,14 @@ +--- Python-3.7.10/Modules/selectmodule.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Modules/selectmodule.c 2021-05-04 18:24:59.689254413 +0200 +@@ -266,7 +266,11 @@ + do { + Py_BEGIN_ALLOW_THREADS + errno = 0; ++#if defined(__EMSCRIPTEN__) ++ n = select(max, &ifdset, &ofdset, NULL, tvp); // &efdset exceptfds not supported (assert) ++#else + n = select(max, &ifdset, &ofdset, &efdset, tvp); ++#endif + Py_END_ALLOW_THREADS + + if (errno != EINTR) diff --git a/sources.wasm/Python-3.7.10/Modules_socketmodule.c.diff b/sources.wasm/Python-3.7.10/Modules_socketmodule.c.diff new file mode 100644 index 0000000..3bffe18 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Modules_socketmodule.c.diff @@ -0,0 +1,13 @@ +--- Python-3.7.10/Modules/socketmodule.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Modules/socketmodule.c 2021-05-04 18:24:59.691254393 +0200 +@@ -1312,6 +1312,10 @@ + } + #endif /* AF_NETLINK */ + ++#if defined(__EMSCRIPTEN__) && defined(AF_VSOCK) ++ #undef AF_VSOCK ++#endif ++ + #if defined(AF_VSOCK) + case AF_VSOCK: + { diff --git a/sources.wasm/Python-3.7.10/Modules_socketmodule.h.diff b/sources.wasm/Python-3.7.10/Modules_socketmodule.h.diff new file mode 100644 index 0000000..119528a --- /dev/null +++ b/sources.wasm/Python-3.7.10/Modules_socketmodule.h.diff @@ -0,0 +1,14 @@ +--- Python-3.7.10/Modules/socketmodule.h 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Modules/socketmodule.h 2021-05-04 18:24:59.694254362 +0200 +@@ -203,6 +203,11 @@ + #ifdef HAVE_SOCKADDR_ALG + struct sockaddr_alg alg; + #endif ++ ++#if defined(__EMSCRIPTEN__) && defined(AF_VSOCK) ++ #undef AF_VSOCK ++#endif ++ + #ifdef AF_VSOCK + struct sockaddr_vm vm; + #endif diff --git a/sources.wasm/Python-3.7.10/Parser_myreadline.c.diff b/sources.wasm/Python-3.7.10/Parser_myreadline.c.diff new file mode 100644 index 0000000..310eab8 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Parser_myreadline.c.diff @@ -0,0 +1,235 @@ +--- Python-3.7.10/Parser/myreadline.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Parser/myreadline.c 2021-05-04 18:24:59.703254269 +0200 +@@ -30,9 +30,6 @@ + static int + my_fgets(char *buf, int len, FILE *fp) + { +-#ifdef MS_WINDOWS +- HANDLE hInterruptEvent; +-#endif + char *p; + int err; + while (1) { +@@ -44,31 +41,6 @@ + if (p != NULL) + return 0; /* No error */ + err = errno; +-#ifdef MS_WINDOWS +- /* Ctrl-C anywhere on the line or Ctrl-Z if the only character +- on a line will set ERROR_OPERATION_ABORTED. Under normal +- circumstances Ctrl-C will also have caused the SIGINT handler +- to fire which will have set the event object returned by +- _PyOS_SigintEvent. This signal fires in another thread and +- is not guaranteed to have occurred before this point in the +- code. +- +- Therefore: check whether the event is set with a small timeout. +- If it is, assume this is a Ctrl-C and reset the event. If it +- isn't set assume that this is a Ctrl-Z on its own and drop +- through to check for EOF. +- */ +- if (GetLastError()==ERROR_OPERATION_ABORTED) { +- hInterruptEvent = _PyOS_SigintEvent(); +- switch (WaitForSingleObjectEx(hInterruptEvent, 10, FALSE)) { +- case WAIT_OBJECT_0: +- ResetEvent(hInterruptEvent); +- return 1; /* Interrupt */ +- case WAIT_FAILED: +- return -2; /* Error */ +- } +- } +-#endif /* MS_WINDOWS */ + if (feof(fp)) { + clearerr(fp); + return -1; /* EOF */ +@@ -93,114 +65,6 @@ + /* NOTREACHED */ + } + +-#ifdef MS_WINDOWS +-/* Readline implementation using ReadConsoleW */ +- +-extern char _get_console_type(HANDLE handle); +- +-char * +-_PyOS_WindowsConsoleReadline(HANDLE hStdIn) +-{ +- static wchar_t wbuf_local[1024 * 16]; +- const DWORD chunk_size = 1024; +- +- DWORD n_read, total_read, wbuflen, u8len; +- wchar_t *wbuf; +- char *buf = NULL; +- int err = 0; +- +- n_read = (DWORD)-1; +- total_read = 0; +- wbuf = wbuf_local; +- wbuflen = sizeof(wbuf_local) / sizeof(wbuf_local[0]) - 1; +- while (1) { +- if (PyOS_InputHook != NULL) { +- (void)(PyOS_InputHook)(); +- } +- if (!ReadConsoleW(hStdIn, &wbuf[total_read], wbuflen - total_read, &n_read, NULL)) { +- err = GetLastError(); +- goto exit; +- } +- if (n_read == (DWORD)-1 && (err = GetLastError()) == ERROR_OPERATION_ABORTED) { +- break; +- } +- if (n_read == 0) { +- int s; +- err = GetLastError(); +- if (err != ERROR_OPERATION_ABORTED) +- goto exit; +- err = 0; +- HANDLE hInterruptEvent = _PyOS_SigintEvent(); +- if (WaitForSingleObjectEx(hInterruptEvent, 100, FALSE) +- == WAIT_OBJECT_0) { +- ResetEvent(hInterruptEvent); +- PyEval_RestoreThread(_PyOS_ReadlineTState); +- s = PyErr_CheckSignals(); +- PyEval_SaveThread(); +- if (s < 0) +- goto exit; +- } +- break; +- } +- +- total_read += n_read; +- if (total_read == 0 || wbuf[total_read - 1] == L'\n') { +- break; +- } +- wbuflen += chunk_size; +- if (wbuf == wbuf_local) { +- wbuf[total_read] = '\0'; +- wbuf = (wchar_t*)PyMem_RawMalloc(wbuflen * sizeof(wchar_t)); +- if (wbuf) +- wcscpy_s(wbuf, wbuflen, wbuf_local); +- else { +- PyErr_NoMemory(); +- goto exit; +- } +- } +- else { +- wchar_t *tmp = PyMem_RawRealloc(wbuf, wbuflen * sizeof(wchar_t)); +- if (tmp == NULL) { +- PyErr_NoMemory(); +- goto exit; +- } +- wbuf = tmp; +- } +- } +- +- if (wbuf[0] == '\x1a') { +- buf = PyMem_RawMalloc(1); +- if (buf) +- buf[0] = '\0'; +- else { +- PyErr_NoMemory(); +- } +- goto exit; +- } +- +- u8len = WideCharToMultiByte(CP_UTF8, 0, wbuf, total_read, NULL, 0, NULL, NULL); +- buf = PyMem_RawMalloc(u8len + 1); +- if (buf == NULL) { +- PyErr_NoMemory(); +- goto exit; +- } +- u8len = WideCharToMultiByte(CP_UTF8, 0, wbuf, total_read, buf, u8len, NULL, NULL); +- buf[u8len] = '\0'; +- +-exit: +- if (wbuf != wbuf_local) +- PyMem_RawFree(wbuf); +- +- if (err) { +- PyEval_RestoreThread(_PyOS_ReadlineTState); +- PyErr_SetFromWindowsErr(err); +- PyEval_SaveThread(); +- } +- +- return buf; +-} +- +-#endif + + + /* Readline implementation using fgets() */ +@@ -211,50 +75,6 @@ + size_t n; + char *p, *pr; + +-#ifdef MS_WINDOWS +- if (!Py_LegacyWindowsStdioFlag && sys_stdin == stdin) { +- HANDLE hStdIn, hStdErr; +- +- _Py_BEGIN_SUPPRESS_IPH +- hStdIn = (HANDLE)_get_osfhandle(fileno(sys_stdin)); +- hStdErr = (HANDLE)_get_osfhandle(fileno(stderr)); +- _Py_END_SUPPRESS_IPH +- +- if (_get_console_type(hStdIn) == 'r') { +- fflush(sys_stdout); +- if (prompt) { +- if (_get_console_type(hStdErr) == 'w') { +- wchar_t *wbuf; +- int wlen; +- wlen = MultiByteToWideChar(CP_UTF8, 0, prompt, -1, +- NULL, 0); +- if (wlen) { +- wbuf = PyMem_RawMalloc(wlen * sizeof(wchar_t)); +- if (wbuf == NULL) { +- PyErr_NoMemory(); +- return NULL; +- } +- wlen = MultiByteToWideChar(CP_UTF8, 0, prompt, -1, +- wbuf, wlen); +- if (wlen) { +- DWORD n; +- fflush(stderr); +- /* wlen includes null terminator, so subtract 1 */ +- WriteConsoleW(hStdErr, wbuf, wlen - 1, &n, NULL); +- } +- PyMem_RawFree(wbuf); +- } +- } else { +- fprintf(stderr, "%s", prompt); +- fflush(stderr); +- } +- } +- clearerr(sys_stdin); +- return _PyOS_WindowsConsoleReadline(hStdIn); +- } +- } +-#endif +- + n = 100; + p = (char *)PyMem_RawMalloc(n); + if (p == NULL) { +@@ -264,7 +84,12 @@ + + fflush(sys_stdout); + if (prompt) ++ #if __EMSCRIPTEN__ ++ fprintf(stderr, "~~>"); ++ #else + fprintf(stderr, "%s", prompt); ++ #endif //__EMSCRIPTEN__ ++ + fflush(stderr); + + switch (my_fgets(p, (int)n, sys_stdin)) { +@@ -275,6 +100,11 @@ + return NULL; + case -1: /* EOF */ + case -2: /* Error */ ++ case -3: ++ #ifdef __EMSCRIPTEN__ ++ #warning ------------- no no no i won't go there -------------- ++ #endif ++ break; + default: /* Shouldn't happen */ + *p = '\0'; + break; diff --git a/sources.wasm/Python-3.7.10/Python_dup2.c.diff b/sources.wasm/Python-3.7.10/Python_dup2.c.diff new file mode 100644 index 0000000..bad86f7 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Python_dup2.c.diff @@ -0,0 +1,42 @@ +--- Python-3.7.10/Python/dup2.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Python/dup2.c 2021-05-04 18:24:59.704254259 +0200 +@@ -16,16 +16,27 @@ + + #define BADEXIT -1 + +-int +-dup2(int fd1, int fd2) +-{ +- if (fd1 != fd2) { +- if (fcntl(fd1, F_GETFL) < 0) +- return BADEXIT; +- if (fcntl(fd2, F_GETFL) >= 0) +- close(fd2); +- if (fcntl(fd1, F_DUPFD, fd2) < 0) +- return BADEXIT; ++#pragma message "extern int dup2(int fd1, int fd2) ?" ++ ++ ++#if HAVE_DUP2 ++ extern int dup2(int fd1, int fd2); ++#else ++ #if defined(__EMSCRIPTEN__) ++ #error "dup2.c will collide with the libc one" ++ #endif ++ int ++ dup2(int fd1, int fd2) ++ { ++ if (fd1 != fd2) { ++ if (fcntl(fd1, F_GETFL) < 0) ++ return BADEXIT; ++ if (fcntl(fd2, F_GETFL) >= 0) ++ close(fd2); ++ if (fcntl(fd1, F_DUPFD, fd2) < 0) ++ return BADEXIT; ++ } ++ return fd2; + } +- return fd2; +-} ++#endif ++ diff --git a/sources.wasm/Python-3.7.10/Python_fileutils.c.diff b/sources.wasm/Python-3.7.10/Python_fileutils.c.diff new file mode 100644 index 0000000..05b278f --- /dev/null +++ b/sources.wasm/Python-3.7.10/Python_fileutils.c.diff @@ -0,0 +1,20 @@ +--- Python-3.7.10/Python/fileutils.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Python/fileutils.c 2021-05-04 18:24:59.706254238 +0200 +@@ -994,6 +994,9 @@ + static int + set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works) + { ++#ifdef __EMSCRIPTEN__ ++ return 0; ++#else + #ifdef MS_WINDOWS + HANDLE handle; + DWORD flags; +@@ -1117,6 +1120,7 @@ + } + return 0; + #endif ++#endif + } + + /* Make the file descriptor non-inheritable. diff --git a/sources.wasm/Python-3.7.10/Python_getplatform.c.diff b/sources.wasm/Python-3.7.10/Python_getplatform.c.diff new file mode 100644 index 0000000..4b9ec4e --- /dev/null +++ b/sources.wasm/Python-3.7.10/Python_getplatform.c.diff @@ -0,0 +1,14 @@ +--- Python-3.7.10/Python/getplatform.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Python/getplatform.c 2021-05-04 18:24:59.707254228 +0200 +@@ -5,6 +5,11 @@ + #define PLATFORM "unknown" + #endif + ++#ifdef __EMSCRIPTEN__ ++ #undef PLATFORM ++ #define PLATFORM "wasm" ++#endif ++ + const char * + Py_GetPlatform(void) + { diff --git a/sources.wasm/Python-3.7.10/Python_import.c.diff b/sources.wasm/Python-3.7.10/Python_import.c.diff new file mode 100644 index 0000000..f57c653 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Python_import.c.diff @@ -0,0 +1,31 @@ +--- Python-3.7.10/Python/import.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Python/import.c 2021-05-04 18:24:59.709254208 +0200 +@@ -1985,6 +1985,20 @@ + list = PyList_New(0); + if (list == NULL) + return NULL; ++ ++#ifdef __EMSCRIPTEN__ ++ PyObject *item = PyUnicode_FromString( ".cpython-38-em.wasm"); ++ if (item == NULL) { ++ Py_DECREF(list); ++ return NULL; ++ } ++ if (PyList_Append(list, item) < 0) { ++ Py_DECREF(list); ++ Py_DECREF(item); ++ return NULL; ++ } ++ Py_DECREF(item); ++#else + #ifdef HAVE_DYNAMIC_LOADING + while ((suffix = _PyImport_DynLoadFiletab[index])) { + PyObject *item = PyUnicode_FromString(suffix); +@@ -2001,6 +2015,7 @@ + index += 1; + } + #endif ++#endif + return list; + } + diff --git a/sources.wasm/Python-3.7.10/Python_pylifecycle.c.diff b/sources.wasm/Python-3.7.10/Python_pylifecycle.c.diff new file mode 100644 index 0000000..5227028 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Python_pylifecycle.c.diff @@ -0,0 +1,29 @@ +--- Python-3.7.10/Python/pylifecycle.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Python/pylifecycle.c 2021-05-05 20:29:35.048542864 +0200 +@@ -70,7 +70,7 @@ + extern void _PyFaulthandler_Fini(void); + extern void _PyHash_Fini(void); + extern int _PyTraceMalloc_Init(int enable); +-extern int _PyTraceMalloc_Fini(void); ++extern void _PyTraceMalloc_Fini(void); + extern void _Py_ReadyTypes(void); + + extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *); +@@ -2362,6 +2362,8 @@ + if (sigaction(sig, NULL, &context) == -1) + return SIG_ERR; + return context.sa_handler; ++#elif defined(__EMSCRIPTEN__) ++ return SIG_ERR; + #else + PyOS_sighandler_t handler; + /* Special signal handling for the secure CRT in Visual Studio 2005 */ +@@ -2408,6 +2410,8 @@ + if (sigaction(sig, &context, &ocontext) == -1) + return SIG_ERR; + return ocontext.sa_handler; ++#elif defined(__EMSCRIPTEN__) ++ return SIG_ERR; + #else + PyOS_sighandler_t oldhandler; + oldhandler = signal(sig, handler); diff --git a/sources.wasm/Python-3.7.10/Python_strdup.c.diff b/sources.wasm/Python-3.7.10/Python_strdup.c.diff new file mode 100644 index 0000000..a9970b1 --- /dev/null +++ b/sources.wasm/Python-3.7.10/Python_strdup.c.diff @@ -0,0 +1,9 @@ +--- Python-3.7.10/Python/strdup.c 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/Python/strdup.c 2021-05-04 18:24:59.713254167 +0200 +@@ -1,4 +1,6 @@ + /* strdup() replacement (from stdwin, if you must know) */ ++#include ++#include + + #include "pgenheaders.h" + diff --git a/sources.wasm/Python-3.7.10/config.sub.diff b/sources.wasm/Python-3.7.10/config.sub.diff new file mode 100644 index 0000000..1495563 --- /dev/null +++ b/sources.wasm/Python-3.7.10/config.sub.diff @@ -0,0 +1,29 @@ +--- Python-3.7.10/config.sub 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/config.sub 2021-05-04 18:24:59.656254752 +0200 +@@ -118,7 +118,8 @@ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ +- storm-chaos* | os2-emx* | rtmk-nova*) ++ storm-chaos* | os2-emx* | rtmk-nova* | \ ++ emscripten) + os=-$maybe_os + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; +@@ -250,6 +251,7 @@ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \ ++ | wasm \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ +@@ -1522,6 +1524,8 @@ + ;; + esac + ;; ++ -emscripten) ++ ;; + -nacl*) + ;; + -ios) diff --git a/sources.wasm/Python-3.7.10/configure.ac.diff b/sources.wasm/Python-3.7.10/configure.ac.diff new file mode 100644 index 0000000..cb86f4a --- /dev/null +++ b/sources.wasm/Python-3.7.10/configure.ac.diff @@ -0,0 +1,82 @@ +--- Python-3.7.10/configure.ac 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/configure.ac 2021-05-04 18:24:59.658254732 +0200 +@@ -376,6 +376,13 @@ + *-*-linux*) + ac_sys_system=Linux + ;; ++ wasm32-unknown-wasi) ++ ac_sys_system=Linux-wasi32 ++ _host_cpu= ++ ;; ++ wasm-*-*) ++ _host_cpu= ++ ;; + *-*-cygwin*) + ac_sys_system=Cygwin + ;; +@@ -423,6 +430,12 @@ + *-*-cygwin*) + _host_cpu= + ;; ++ wasm-*-*) ++ ac_sys_system=Emscripten ++ ;; ++ wasm32-unknown-wasi) ++ ac_sys_system=wasi32 ++ ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" +@@ -1141,6 +1154,16 @@ + PY3LIBRARY=libpython3.so + fi + ;; ++ Emscripten) ++ LDLIBRARY='libpython$(LDVERSION).bc' ++ BLDLIBRARY='-L. -lpython$(LDVERSION)' ++ RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} ++ INSTSONAME="$LDLIBRARY" ++ if test "$with_pydebug" != yes ++ then ++ PY3LIBRARY=libpython3.bc ++ fi ++ ;; + Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) + LDLIBRARY='libpython$(LDVERSION).so' + BLDLIBRARY='-L. -lpython$(LDVERSION)' +@@ -2513,8 +2536,11 @@ + # SHLIB_SUFFIX is the extension of shared libraries `(including the dot!) + # -- usually .so, .sl on HP-UX, .dll on Cygwin + AC_MSG_CHECKING(the extension of shared libraries) ++ + if test -z "$SHLIB_SUFFIX"; then + case $ac_sys_system in ++ Emscripten) ++ SHLIB_SUFFIX=.js;; + hp*|HP*) + case `uname -m` in + ia64) SHLIB_SUFFIX=.so;; +@@ -2525,6 +2551,12 @@ + *) SHLIB_SUFFIX=.so;; + esac + fi ++ ++case $ac_sys_system in ++Emscripten) ++ SHLIB_SUFFIX=.js;; ++esac ++ + AC_MSG_RESULT($SHLIB_SUFFIX) + + # LDSHARED is the ld *command* used to create shared library +@@ -4764,6 +4796,10 @@ + case $ac_sys_system in + Linux*|GNU*|Darwin) + EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};; ++ Emscripten) ++ SOABI="cpython-${VERSION}-emscripten" ++ EXT_SUFFIX=".extsu" ++ ;; + *) + EXT_SUFFIX=${SHLIB_SUFFIX};; + esac diff --git a/sources.wasm/Python-3.7.10/configure.diff b/sources.wasm/Python-3.7.10/configure.diff new file mode 100644 index 0000000..29d787d --- /dev/null +++ b/sources.wasm/Python-3.7.10/configure.diff @@ -0,0 +1,114 @@ +--- Python-3.7.10/configure 2021-02-16 02:29:22.000000000 +0100 ++++ python3-wasm/configure 2021-05-04 18:24:59.663254680 +0200 +@@ -3257,6 +3257,12 @@ + *-*-linux*) + ac_sys_system=Linux + ;; ++ wasm-*-*) ++ ac_sys_system=Emscripten ++ ;; ++ wasm32-unknown-wasi) ++ ac_sys_system=wasi32 ++ ;; + *-*-cygwin*) + ac_sys_system=Cygwin + ;; +@@ -3304,6 +3310,12 @@ + *-*-cygwin*) + _host_cpu= + ;; ++ wasm-*-*) ++ ac_sys_system=Emscripten ++ ;; ++ wasm32-unknown-wasi) ++ ac_sys_system=wasi32 ++ ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" +@@ -9314,8 +9326,9 @@ + # -- usually .so, .sl on HP-UX, .dll on Cygwin + { $as_echo "$as_me:${as_lineno-$LINENO}: checking the extension of shared libraries" >&5 + $as_echo_n "checking the extension of shared libraries... " >&6; } ++ + if test -z "$SHLIB_SUFFIX"; then +- case $ac_sys_system in ++ case $ac_sys_system in + hp*|HP*) + case `uname -m` in + ia64) SHLIB_SUFFIX=.so;; +@@ -9326,6 +9339,12 @@ + *) SHLIB_SUFFIX=.so;; + esac + fi ++ ++case $ac_sys_system in ++Emscripten) ++ SHLIB_SUFFIX=.wasm;; ++esac ++ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHLIB_SUFFIX" >&5 + $as_echo "$SHLIB_SUFFIX" >&6; } + +@@ -10785,7 +10804,7 @@ + + else + +- as_fn_error $? "could not find pthreads on your system" "$LINENO" 5 ++ echo 'as_fn_error $? "could not find pthreads on your system" "$LINENO" 5' + + fi + +@@ -11707,6 +11726,9 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #include ++#ifdef __EMSCRIPTEN__ ++#error unsupported ++#endif + int + main () + { +@@ -11732,6 +11754,9 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #include ++#ifdef __EMSCRIPTEN__ ++#error unsupported ++#endif + int + main () + { +@@ -12381,7 +12406,9 @@ + #ifdef HAVE_GRP_H + #include + #endif +- ++#ifdef __EMSCRIPTEN__ ++ #error setgroups ++#endif + int + main () + { +@@ -13063,7 +13090,9 @@ + #else + #include + #endif +- ++#ifdef __EMSCRIPTEN__ ++ #error makedev ++#endif + int + main () + { +@@ -15283,6 +15312,10 @@ + case $ac_sys_system in + Linux*|GNU*|Darwin) + EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};; ++ Emscripten) ++ SOABI="cpython-${VERSION}-emscripten" ++ EXT_SUFFIX=".wasm" ++ ;; + *) + EXT_SUFFIX=${SHLIB_SUFFIX};; + esac diff --git a/sources.wasm/Python-3.8.10/Include_pyport.h.diff b/sources.wasm/Python-3.8.10/Include_pyport.h.diff new file mode 100644 index 0000000..91ff5f8 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Include_pyport.h.diff @@ -0,0 +1,14 @@ +--- cpython-3.8.5/Include/pyport.h 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Include/pyport.h 2020-08-28 12:53:03.820088471 +0200 +@@ -723,7 +723,11 @@ + * rather than waiting for integer multiplication to trigger bogus + * overflows. + */ ++#ifndef __EMSCRIPTEN__ + #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." ++#else ++#warning "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." ++#endif + #endif + + #ifdef __cplusplus diff --git a/sources.wasm/Python-3.8.10/Lib_hashlib.py.diff b/sources.wasm/Python-3.8.10/Lib_hashlib.py.diff new file mode 100644 index 0000000..b021b21 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Lib_hashlib.py.diff @@ -0,0 +1,21 @@ +--- cpython-3.8.5/Lib/hashlib.py 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Lib/hashlib.py 2020-08-28 12:53:03.821088458 +0200 +@@ -55,10 +55,14 @@ + + # This tuple and __get_builtin_constructor() must be modified if a new + # always available algorithm is added. +-__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', +- 'blake2b', 'blake2s', +- 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', +- 'shake_128', 'shake_256') ++import sys ++if sys.platform=='emscripten': ++ __always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512') ++else: ++ __always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', ++ 'blake2b', 'blake2s', ++ 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', ++ 'shake_128', 'shake_256') + + + algorithms_guaranteed = set(__always_supported) diff --git a/sources.wasm/Python-3.8.10/Lib_subprocess.py.diff b/sources.wasm/Python-3.8.10/Lib_subprocess.py.diff new file mode 100644 index 0000000..a929005 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Lib_subprocess.py.diff @@ -0,0 +1,12 @@ +--- cpython-3.8.5/Lib/subprocess.py 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Lib/subprocess.py 2020-08-28 12:53:03.822088444 +0200 +@@ -66,7 +66,8 @@ + _mswindows = True + except ModuleNotFoundError: + _mswindows = False +- import _posixsubprocess ++ if (sys.platform != "wasm"): ++ import _posixsubprocess + import select + import selectors + else: diff --git a/sources.wasm/Python-3.8.10/Lib_threading.py.diff b/sources.wasm/Python-3.8.10/Lib_threading.py.diff new file mode 100644 index 0000000..a18ee90 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Lib_threading.py.diff @@ -0,0 +1,23 @@ +--- cpython-3.8.5/Lib/threading.py 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Lib/threading.py 2020-08-28 12:53:03.824088418 +0200 +@@ -247,7 +247,8 @@ + return self._lock.__enter__() + + def __exit__(self, *args): +- return self._lock.__exit__(*args) ++ try:return self._lock.__exit__(*args) ++ except:pass + + def __repr__(self): + return "" % (self._lock, len(self._waiters)) +@@ -349,7 +350,9 @@ + + """ + if not self._is_owned(): +- raise RuntimeError("cannot notify on un-acquired lock") ++ pass ++ #raise RuntimeError("cannot notify on un-acquired lock") ++ + all_waiters = self._waiters + waiters_to_notify = _deque(_islice(all_waiters, n)) + if not waiters_to_notify: diff --git a/sources.wasm/Python-3.8.10/Makefile.pre.in.diff b/sources.wasm/Python-3.8.10/Makefile.pre.in.diff new file mode 100644 index 0000000..481388b --- /dev/null +++ b/sources.wasm/Python-3.8.10/Makefile.pre.in.diff @@ -0,0 +1,11 @@ +--- cpython-3.8.5/Makefile.pre.in 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Makefile.pre.in 2020-08-28 12:53:03.828088366 +0200 +@@ -225,7 +225,7 @@ + PY3LIBRARY= @PY3LIBRARY@ + DLLLIBRARY= @DLLLIBRARY@ + LDLIBRARYDIR= @LDLIBRARYDIR@ +-INSTSONAME= @INSTSONAME@ ++INSTSONAME=libpython$(LDVERSION).so + + + LIBS= @LIBS@ diff --git a/sources.wasm/Python-3.8.10/Modules__ctypes_callbacks.c.diff b/sources.wasm/Python-3.8.10/Modules__ctypes_callbacks.c.diff new file mode 100644 index 0000000..d6537ae --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules__ctypes_callbacks.c.diff @@ -0,0 +1,13 @@ +--- Python-3.8.5/Modules/_ctypes/callbacks.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/_ctypes/callbacks.c 2020-09-29 15:03:33.142131929 +0200 +@@ -361,8 +361,8 @@ + + assert(CThunk_CheckExact((PyObject *)p)); + +- p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure), +- &p->pcl_exec); ++ p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure), &p->pcl_exec); ++ + if (p->pcl_write == NULL) { + PyErr_NoMemory(); + goto error; diff --git a/sources.wasm/Python-3.8.10/Modules__ctypes_ctypes.h.diff b/sources.wasm/Python-3.8.10/Modules__ctypes_ctypes.h.diff new file mode 100644 index 0000000..163f97a --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules__ctypes_ctypes.h.diff @@ -0,0 +1,18 @@ +--- Python-3.8.5/Modules/_ctypes/ctypes.h 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/_ctypes/ctypes.h 2020-09-29 15:04:20.708497618 +0200 +@@ -53,7 +53,15 @@ + PyObject *b_objects; /* dictionary of references we need to keep, or Py_None */ + union value b_value; + }; ++#if FFI_CLOSURES ++#else + ++ #define ffi_closure void ++ #define ffi_closure_free(writable) "" ++ #define ffi_closure_alloc(size, code) "" ++ #define ffi_prep_closure_loc(...) "" ++ ++#endif + typedef struct { + PyObject_VAR_HEAD + ffi_closure *pcl_write; /* the C callable, writeable */ diff --git a/sources.wasm/Python-3.8.10/Modules__hashopenssl.c.diff b/sources.wasm/Python-3.8.10/Modules__hashopenssl.c.diff new file mode 100644 index 0000000..b4bf2ff --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules__hashopenssl.c.diff @@ -0,0 +1,14 @@ +--- cpython-3.8.5/Modules/_hashopenssl.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/_hashopenssl.c 2020-08-30 17:22:21.654931539 +0200 +@@ -27,8 +27,11 @@ + #include "openssl/err.h" + + #ifndef OPENSSL_THREADS ++#if __EMSCRIPTEN__ ++#else + # error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" + #endif ++#endif + + #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER) + /* OpenSSL < 1.1.0 */ diff --git a/sources.wasm/Python-3.8.10/Modules__posixsubprocess.c.diff b/sources.wasm/Python-3.8.10/Modules__posixsubprocess.c.diff new file mode 100644 index 0000000..55281b8 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules__posixsubprocess.c.diff @@ -0,0 +1,30 @@ +--- cpython-3.8.5/Modules/_posixsubprocess.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/_posixsubprocess.c 2020-08-28 12:53:03.835088273 +0200 +@@ -552,7 +552,7 @@ + } + } + +- ++#ifdef HAVE_FORK + static PyObject * + subprocess_fork_exec(PyObject* self, PyObject *args) + { +@@ -762,7 +762,7 @@ + Py_XDECREF(gc_module); + return NULL; + } +- ++#endif + + PyDoc_STRVAR(subprocess_fork_exec_doc, + "fork_exec(args, executable_list, close_fds, cwd, env,\n\ +@@ -793,7 +793,9 @@ + + + static PyMethodDef module_methods[] = { ++#ifdef HAVE_FORK + {"fork_exec", subprocess_fork_exec, METH_VARARGS, subprocess_fork_exec_doc}, ++#endif + {NULL, NULL} /* sentinel */ + }; + diff --git a/sources.wasm/Python-3.8.10/Modules__ssl.c.diff b/sources.wasm/Python-3.8.10/Modules__ssl.c.diff new file mode 100644 index 0000000..7178646 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules__ssl.c.diff @@ -0,0 +1,14 @@ +--- cpython-3.8.5/Modules/_ssl.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/_ssl.c 2020-08-30 17:35:08.791546580 +0200 +@@ -76,8 +76,11 @@ + #endif + + #ifndef OPENSSL_THREADS ++#if __EMSCRIPTEN__ ++#else + # error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" + #endif ++#endif + + /* SSL error object */ + static PyObject *PySSLErrorObject; diff --git a/sources.wasm/Python-3.8.10/Modules_clinic_signalmodule.c.h.diff b/sources.wasm/Python-3.8.10/Modules_clinic_signalmodule.c.h.diff new file mode 100644 index 0000000..4e8a3d5 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules_clinic_signalmodule.c.h.diff @@ -0,0 +1,16 @@ +--- cpython-3.8.5/Modules/clinic/signalmodule.c.h 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/clinic/signalmodule.c.h 2020-08-28 12:53:03.830088339 +0200 +@@ -396,9 +396,13 @@ + if (how == -1 && PyErr_Occurred()) { + goto exit; + } ++ #if __EMSCRIPTEN__ ++ #pragma message "HAVE_SIGSET_T // _Py_Sigset_Converter ?" ++ #else + if (!_Py_Sigset_Converter(args[1], &mask)) { + goto exit; + } ++ #endif + return_value = signal_pthread_sigmask_impl(module, how, mask); + + exit: diff --git a/sources.wasm/Python-3.8.10/Modules_posixmodule.c.diff b/sources.wasm/Python-3.8.10/Modules_posixmodule.c.diff new file mode 100644 index 0000000..dfea9d5 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules_posixmodule.c.diff @@ -0,0 +1,52 @@ +--- cpython-3.8.5/Modules/posixmodule.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/posixmodule.c 2020-08-28 12:53:03.832088313 +0200 +@@ -174,6 +174,12 @@ + # endif + #endif /* MS_WINDOWS */ + ++#if GOSH_MOVE_THEM ++ #pragma message "XXX Gosh I wish these were all moved into pyconfig.h" ++ #ifdef HAVE_FORKPTY ++ #undef HAVE_FORKPTY ++ #endif ++#else + /* Various compilers have only certain posix functions */ + /* XXX Gosh I wish these were all moved into pyconfig.h */ + #if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */ +@@ -215,7 +221,7 @@ + #define HAVE_TTYNAME 1 + #endif /* _MSC_VER */ + #endif /* ! __WATCOMC__ || __QNX__ */ +- ++#endif // my GOSH + + /*[clinic input] + # one of the few times we lie about this name! +@@ -5389,9 +5395,13 @@ + + if (setsigmask) { + sigset_t set; ++ #if __EMSCRIPTEN__ ++ #pragma message "HAVE_SIGSET_T // _Py_Sigset_Converter ?" ++ #else + if (!_Py_Sigset_Converter(setsigmask, &set)) { + goto fail; + } ++ #endif + errno = posix_spawnattr_setsigmask(attrp, &set); + if (errno) { + posix_error(); +@@ -5402,9 +5412,13 @@ + + if (setsigdef) { + sigset_t set; ++ #if __EMSCRIPTEN__ ++ #pragma message "HAVE_SIGSET_T // _Py_Sigset_Converter ?" ++ #else + if (!_Py_Sigset_Converter(setsigdef, &set)) { + goto fail; + } ++ #endif + errno = posix_spawnattr_setsigdefault(attrp, &set); + if (errno) { + posix_error(); diff --git a/sources.wasm/Python-3.8.10/Modules_selectmodule.c.diff b/sources.wasm/Python-3.8.10/Modules_selectmodule.c.diff new file mode 100644 index 0000000..2a3ef5f --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules_selectmodule.c.diff @@ -0,0 +1,14 @@ +--- cpython-3.8.5/Modules/selectmodule.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/selectmodule.c 2020-08-28 12:53:03.839088221 +0200 +@@ -322,7 +322,11 @@ + do { + Py_BEGIN_ALLOW_THREADS + errno = 0; ++#if defined(__EMSCRIPTEN__) ++ n = select(max, &ifdset, &ofdset, NULL, tvp); // &efdset exceptfds not supported (assert) ++#else + n = select(max, &ifdset, &ofdset, &efdset, tvp); ++#endif + Py_END_ALLOW_THREADS + + if (errno != EINTR) diff --git a/sources.wasm/Python-3.8.10/Modules_socketmodule.c.diff b/sources.wasm/Python-3.8.10/Modules_socketmodule.c.diff new file mode 100644 index 0000000..93c94c9 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules_socketmodule.c.diff @@ -0,0 +1,13 @@ +--- cpython-3.8.5/Modules/socketmodule.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/socketmodule.c 2020-08-28 12:53:03.841088194 +0200 +@@ -1359,6 +1359,10 @@ + } + #endif /* AF_QIPCRTR */ + ++#if defined(__EMSCRIPTEN__) && defined(AF_VSOCK) ++ #undef AF_VSOCK ++#endif ++ + #if defined(AF_VSOCK) + case AF_VSOCK: + { diff --git a/sources.wasm/Python-3.8.10/Modules_socketmodule.h.diff b/sources.wasm/Python-3.8.10/Modules_socketmodule.h.diff new file mode 100644 index 0000000..344b459 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Modules_socketmodule.h.diff @@ -0,0 +1,14 @@ +--- cpython-3.8.5/Modules/socketmodule.h 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Modules/socketmodule.h 2020-08-28 12:53:03.844088155 +0200 +@@ -215,6 +215,11 @@ + #ifdef AF_QIPCRTR + struct sockaddr_qrtr sq; + #endif ++ ++#if defined(__EMSCRIPTEN__) && defined(AF_VSOCK) ++ #undef AF_VSOCK ++#endif ++ + #ifdef AF_VSOCK + struct sockaddr_vm vm; + #endif diff --git a/sources.wasm/Python-3.8.10/Parser_tokenizer.c.diff b/sources.wasm/Python-3.8.10/Parser_tokenizer.c.diff new file mode 100644 index 0000000..f30a7e9 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Parser_tokenizer.c.diff @@ -0,0 +1,11 @@ +--- cpython-org/Parser/tokenizer.c 2020-07-20 15:01:32.000000000 +0200 ++++ cpython-3.8.5/Parser/tokenizer.c 2020-09-12 04:08:54.368934692 +0200 +@@ -846,7 +846,7 @@ + return Py_CHARMASK(*tok->cur++); + } + if (tok->prompt != NULL) { +- char *newtok = PyOS_Readline(stdin, stdout, tok->prompt); ++ char *newtok = PyOS_Readline(tok->fp? tok->fp : stdin, stdout, tok->prompt); + if (newtok != NULL) { + char *translated = translate_newlines(newtok, 0, tok); + PyMem_FREE(newtok); diff --git a/sources.wasm/Python-3.8.10/Python_dup2.c.diff b/sources.wasm/Python-3.8.10/Python_dup2.c.diff new file mode 100644 index 0000000..5a3878c --- /dev/null +++ b/sources.wasm/Python-3.8.10/Python_dup2.c.diff @@ -0,0 +1,42 @@ +--- cpython-3.8.5/Python/dup2.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Python/dup2.c 2020-08-28 12:53:03.849088090 +0200 +@@ -16,16 +16,27 @@ + + #define BADEXIT -1 + +-int +-dup2(int fd1, int fd2) +-{ +- if (fd1 != fd2) { +- if (fcntl(fd1, F_GETFL) < 0) +- return BADEXIT; +- if (fcntl(fd2, F_GETFL) >= 0) +- close(fd2); +- if (fcntl(fd1, F_DUPFD, fd2) < 0) +- return BADEXIT; ++#pragma message "extern int dup2(int fd1, int fd2) ?" ++ ++ ++#if HAVE_DUP2 ++ extern int dup2(int fd1, int fd2); ++#else ++ #if defined(__EMSCRIPTEN__) ++ #error "dup2.c will collide with the libc one" ++ #endif ++ int ++ dup2(int fd1, int fd2) ++ { ++ if (fd1 != fd2) { ++ if (fcntl(fd1, F_GETFL) < 0) ++ return BADEXIT; ++ if (fcntl(fd2, F_GETFL) >= 0) ++ close(fd2); ++ if (fcntl(fd1, F_DUPFD, fd2) < 0) ++ return BADEXIT; ++ } ++ return fd2; + } +- return fd2; +-} ++#endif ++ diff --git a/sources.wasm/Python-3.8.10/Python_fileutils.c.diff b/sources.wasm/Python-3.8.10/Python_fileutils.c.diff new file mode 100644 index 0000000..f0f7540 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Python_fileutils.c.diff @@ -0,0 +1,20 @@ +--- cpython-3.8.5/Python/fileutils.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Python/fileutils.c 2020-08-28 12:53:03.851088063 +0200 +@@ -1091,6 +1091,9 @@ + static int + set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works) + { ++#ifdef __EMSCRIPTEN__ ++ return 0; ++#else + #ifdef MS_WINDOWS + HANDLE handle; + DWORD flags; +@@ -1214,6 +1217,7 @@ + } + return 0; + #endif ++#endif + } + + /* Make the file descriptor non-inheritable. diff --git a/sources.wasm/Python-3.8.10/Python_getplatform.c.diff b/sources.wasm/Python-3.8.10/Python_getplatform.c.diff new file mode 100644 index 0000000..e0b3199 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Python_getplatform.c.diff @@ -0,0 +1,14 @@ +--- cpython-3.8.5/Python/getplatform.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Python/getplatform.c 2020-08-28 12:53:03.853088037 +0200 +@@ -5,6 +5,11 @@ + #define PLATFORM "unknown" + #endif + ++#ifdef __EMSCRIPTEN__ ++ #undef PLATFORM ++ #define PLATFORM "wasm" ++#endif ++ + const char * + Py_GetPlatform(void) + { diff --git a/sources.wasm/Python-3.8.10/Python_import.c.diff b/sources.wasm/Python-3.8.10/Python_import.c.diff new file mode 100644 index 0000000..1bb80e1 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Python_import.c.diff @@ -0,0 +1,31 @@ +--- cpython-3.8.5/Python/import.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Python/import.c 2020-08-28 12:53:03.855088011 +0200 +@@ -2029,6 +2029,20 @@ + list = PyList_New(0); + if (list == NULL) + return NULL; ++ ++#ifdef __EMSCRIPTEN__ ++ PyObject *item = PyUnicode_FromString( ".cpython-38-em.wasm"); ++ if (item == NULL) { ++ Py_DECREF(list); ++ return NULL; ++ } ++ if (PyList_Append(list, item) < 0) { ++ Py_DECREF(list); ++ Py_DECREF(item); ++ return NULL; ++ } ++ Py_DECREF(item); ++#else + #ifdef HAVE_DYNAMIC_LOADING + const char *suffix; + unsigned int index = 0; +@@ -2048,6 +2062,7 @@ + index += 1; + } + #endif ++#endif + return list; + } + diff --git a/sources.wasm/Python-3.8.10/Python_pylifecycle.c.diff b/sources.wasm/Python-3.8.10/Python_pylifecycle.c.diff new file mode 100644 index 0000000..160e857 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Python_pylifecycle.c.diff @@ -0,0 +1,20 @@ +--- cpython-3.8.5/Python/pylifecycle.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Python/pylifecycle.c 2020-08-28 12:53:03.856087998 +0200 +@@ -2369,6 +2369,8 @@ + if (sigaction(sig, NULL, &context) == -1) + return SIG_ERR; + return context.sa_handler; ++#elif defined(__EMSCRIPTEN__) ++ return SIG_ERR; + #else + PyOS_sighandler_t handler; + /* Special signal handling for the secure CRT in Visual Studio 2005 */ +@@ -2415,6 +2417,8 @@ + if (sigaction(sig, &context, &ocontext) == -1) + return SIG_ERR; + return ocontext.sa_handler; ++#elif defined(__EMSCRIPTEN__) ++ return SIG_ERR; + #else + PyOS_sighandler_t oldhandler; + oldhandler = signal(sig, handler); diff --git a/sources.wasm/Python-3.8.10/Python_strdup.c.diff b/sources.wasm/Python-3.8.10/Python_strdup.c.diff new file mode 100644 index 0000000..c13d2f6 --- /dev/null +++ b/sources.wasm/Python-3.8.10/Python_strdup.c.diff @@ -0,0 +1,9 @@ +--- cpython-3.8.5/Python/strdup.c 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/Python/strdup.c 2020-08-28 12:53:03.858087971 +0200 +@@ -1,4 +1,6 @@ + /* strdup() replacement (from stdwin, if you must know) */ ++#include ++#include + + char * + strdup(const char *str) diff --git a/sources.wasm/Python-3.8.10/config.sub.diff b/sources.wasm/Python-3.8.10/config.sub.diff new file mode 100644 index 0000000..4079cdb --- /dev/null +++ b/sources.wasm/Python-3.8.10/config.sub.diff @@ -0,0 +1,29 @@ +--- cpython-3.8.5/config.sub 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/config.sub 2020-08-28 12:53:03.808088628 +0200 +@@ -118,7 +118,8 @@ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ +- storm-chaos* | os2-emx* | rtmk-nova*) ++ storm-chaos* | os2-emx* | rtmk-nova* | \ ++ emscripten) + os=-$maybe_os + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; +@@ -250,6 +251,7 @@ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \ ++ | wasm \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ +@@ -1522,6 +1524,8 @@ + ;; + esac + ;; ++ -emscripten) ++ ;; + -nacl*) + ;; + -ios) diff --git a/sources.wasm/Python-3.8.10/configure.ac.diff b/sources.wasm/Python-3.8.10/configure.ac.diff new file mode 100644 index 0000000..9af11a7 --- /dev/null +++ b/sources.wasm/Python-3.8.10/configure.ac.diff @@ -0,0 +1,75 @@ +--- cpython-3.8.5/configure.ac 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/configure.ac 2020-08-28 12:53:03.811088589 +0200 +@@ -379,6 +379,9 @@ + *-*-cygwin*) + ac_sys_system=Cygwin + ;; ++ wasm-*-*) ++ _host_cpu= ++ ;; + *-*-vxworks*) + ac_sys_system=VxWorks + ;; +@@ -431,6 +434,9 @@ + *-*-vxworks*) + _host_cpu=$host_cpu + ;; ++ wasm-*-*) ++ ac_sys_system=Emscripten ++ ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" +@@ -1125,6 +1131,16 @@ + PY3LIBRARY=libpython3.so + fi + ;; ++ Emscripten) ++ LDLIBRARY='libpython$(LDVERSION).bc' ++ BLDLIBRARY='-L. -lpython$(LDVERSION)' ++ RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} ++ INSTSONAME="$LDLIBRARY" ++ if test "$with_pydebug" != yes ++ then ++ PY3LIBRARY=libpython3.bc ++ fi ++ ;; + Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) + LDLIBRARY='libpython$(LDVERSION).so' + BLDLIBRARY='-L. -lpython$(LDVERSION)' +@@ -2496,8 +2512,11 @@ + # SHLIB_SUFFIX is the extension of shared libraries `(including the dot!) + # -- usually .so, .sl on HP-UX, .dll on Cygwin + AC_MSG_CHECKING(the extension of shared libraries) ++ + if test -z "$SHLIB_SUFFIX"; then + case $ac_sys_system in ++ Emscripten) ++ SHLIB_SUFFIX=.js;; + hp*|HP*) + case `uname -m` in + ia64) SHLIB_SUFFIX=.so;; +@@ -2508,6 +2527,12 @@ + *) SHLIB_SUFFIX=.so;; + esac + fi ++ ++case $ac_sys_system in ++Emscripten) ++ SHLIB_SUFFIX=.js;; ++esac ++ + AC_MSG_RESULT($SHLIB_SUFFIX) + + # LDSHARED is the ld *command* used to create shared library +@@ -4670,6 +4695,10 @@ + case $ac_sys_system in + Linux*|GNU*|Darwin|VxWorks) + EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};; ++ Emscripten) ++ SOABI="cpython-${VERSION}-emscripten" ++ EXT_SUFFIX=".extsu" ++ ;; + *) + EXT_SUFFIX=${SHLIB_SUFFIX};; + esac diff --git a/sources.wasm/Python-3.8.10/configure.diff b/sources.wasm/Python-3.8.10/configure.diff new file mode 100644 index 0000000..af06bed --- /dev/null +++ b/sources.wasm/Python-3.8.10/configure.diff @@ -0,0 +1,108 @@ +--- cpython-3.8.5/configure 2020-07-20 15:01:32.000000000 +0200 ++++ python3-wasm/configure 2020-08-28 12:53:03.816088523 +0200 +@@ -3275,6 +3275,9 @@ + *-*-cygwin*) + ac_sys_system=Cygwin + ;; ++ wasm-*-*) ++ _host_cpu= ++ ;; + *-*-vxworks*) + ac_sys_system=VxWorks + ;; +@@ -3328,6 +3331,9 @@ + *-*-vxworks*) + _host_cpu=$host_cpu + ;; ++ wasm-*-*) ++ ac_sys_system=Emscripten ++ ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" +@@ -9324,8 +9330,9 @@ + # -- usually .so, .sl on HP-UX, .dll on Cygwin + { $as_echo "$as_me:${as_lineno-$LINENO}: checking the extension of shared libraries" >&5 + $as_echo_n "checking the extension of shared libraries... " >&6; } ++ + if test -z "$SHLIB_SUFFIX"; then +- case $ac_sys_system in ++ case $ac_sys_system in + hp*|HP*) + case `uname -m` in + ia64) SHLIB_SUFFIX=.so;; +@@ -9336,6 +9343,12 @@ + *) SHLIB_SUFFIX=.so;; + esac + fi ++ ++case $ac_sys_system in ++Emscripten) ++ SHLIB_SUFFIX=.wasm;; ++esac ++ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHLIB_SUFFIX" >&5 + $as_echo "$SHLIB_SUFFIX" >&6; } + +@@ -10799,7 +10812,7 @@ + + else + +- as_fn_error $? "could not find pthreads on your system" "$LINENO" 5 ++ echo 'as_fn_error $? "could not find pthreads on your system" "$LINENO" 5' + + fi + +@@ -11723,6 +11736,9 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #include ++#ifdef __EMSCRIPTEN__ ++#error unsupported ++#endif + int + main () + { +@@ -11748,6 +11764,9 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #include ++#ifdef __EMSCRIPTEN__ ++#error unsupported ++#endif + int + main () + { +@@ -12430,7 +12449,9 @@ + #ifdef HAVE_GRP_H + #include + #endif +- ++#ifdef __EMSCRIPTEN__ ++ #error setgroups ++#endif + int + main () + { +@@ -13112,7 +13133,9 @@ + #else + #include + #endif +- ++#ifdef __EMSCRIPTEN__ ++ #error makedev ++#endif + int + main () + { +@@ -15194,6 +15217,10 @@ + case $ac_sys_system in + Linux*|GNU*|Darwin|VxWorks) + EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};; ++ Emscripten) ++ SOABI="cpython-${VERSION}-emscripten" ++ EXT_SUFFIX=".wasm" ++ ;; + *) + EXT_SUFFIX=${SHLIB_SUFFIX};; + esac diff --git a/sources.wasm/python3.wasm.sh b/sources.wasm/python3.wasm.sh index 68392b0..30e05a4 100644 --- a/sources.wasm/python3.wasm.sh +++ b/sources.wasm/python3.wasm.sh @@ -253,7 +253,7 @@ python_configure () { #dropped support for asm.js EM_MODE="" # nope -s ENVIRONMENT=web - EM_FLAGS="-fPIC -O3 -s EXPORT_ALL=1 -s USE_ZLIB=1 -s SOCKET_WEBRTC=0 -s SOCKET_DEBUG=1" + EM_FLAGS="-fPIC -Os -g0" cat >> $1 <&1 >> ${BUILD_SRC}/build.log @@ -349,7 +349,6 @@ else echo ================== ${BUILD_SRC}/build.log =================== tail -n 30 ${BUILD_SRC}/build.log echo "Configuration failed for $PLATFORM_TRIPLET" - env exit 1 fi END @@ -468,8 +467,6 @@ python3_crosscompile () { fi - - } diff --git a/sources.wasm/vorbis.wasm.sh b/sources.wasm/vorbis.wasm.sh index 5e4ea27..61f07cc 100644 --- a/sources.wasm/vorbis.wasm.sh +++ b/sources.wasm/vorbis.wasm.sh @@ -20,11 +20,18 @@ vorbis_crosscompile () { else PrepareBuild ${unit} #-DBUILD_SHARED_LIBS=No -DOGG_INCLUDE_DIR=${EM_CACHE}/wasm/include -DOGG_LIBRARY=${EM_CACHE}/wasm + if echo $EM_CACHE|grep -q cache + then + EM_SYSROOT=${EM_CACHE}/sysroot + else + EM_SYSROOT=$(find $EMSDK/ -type d|grep /sysroot$) + fi + echo " * found emsdk sysroot at $EM_SYSROOT" if $WCMAKE \ -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_C_FLAGS="-fPIC" \ - -DOGG_LIBRARY=${EM_CACHE}/sysroot/lib/wasm32-emscripten/pic/libogg.a \ - -DOGG_INCLUDE_DIR=${EM_CACHE}/sysroot/include \ + -DOGG_LIBRARY=${EM_SYSROOT}/lib/wasm32-emscripten/pic/libogg.a \ + -DOGG_INCLUDE_DIR=${EM_SYSROOT}/include \ ${BUILD_SRC}/${unit}-prefix/src/${unit} >/dev/null then em_make ${unit} diff --git a/sources/python_host.sh b/sources/python_host.sh index d5dd153..8f284fa 100644 --- a/sources/python_host.sh +++ b/sources/python_host.sh @@ -6,11 +6,14 @@ export URL_PYTHON3=${URL_PYTHON3:-"URL https://www.python.org/ftp/python/${PYVER}/Python-${PYVER}.tar.xz"} case "${PYVER}" in - "3.7.9" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=389d3ed26b4d97c741d9e5423da1f43b"};; - "3.8.5" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=35b5a3d0254c1c59be9736373d429db7"};; - "3.9.0" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=6ebfe157f6e88d9eabfbaf3fa92129f6"};; - "3.9.1" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=61981498e75ac8f00adcb908281fadb6"};; - "3.9.2" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=f0dc9000312abeb16de4eccce9a870ab"};; + "3.7.9" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=389d3ed26b4d97c741d9e5423da1f43b"};; + "3.7.10" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=9e34914bc804ab2e7d955b49c5e1e391"};; + "3.8.5" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=35b5a3d0254c1c59be9736373d429db7"};; + "3.8.8" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=23e6b769857233c1ac07b6be7442eff4"};; + "3.8.10" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=d9eee4b20155553830a2025e4dcaa7b3"};; + "3.9.0" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=6ebfe157f6e88d9eabfbaf3fa92129f6"};; + "3.9.1" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=61981498e75ac8f00adcb908281fadb6"};; + "3.9.2" ) export HASH_PYTHON3=${HASH_PYTHON3:-"URL_HASH MD5=f0dc9000312abeb16de4eccce9a870ab"};; esac export PYOPTS="--without-pymalloc --without-pydebug\ @@ -117,6 +120,13 @@ then if $PIP3 scikit-build then if $PIP3 "cmake==${CMAKE_VERSION}" + then + echo maybe ok + else + echo " * NOT BUILDING CMAKE (too buggy), using anything in path" + fi + + if command -v cmake |grep -q cmake then rm new_env fi