Skip to content

Commit 5342707

Browse files
committed
Update patches, bump version to 3.6.9
1 parent 6281d63 commit 5342707

File tree

12 files changed

+3825
-2631
lines changed

12 files changed

+3825
-2631
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://travis-ci.org/vbe0201/3DS.py.svg?branch=master)](https://travis-ci.org/vbe0201/3DS.py)
44

5-
3DS.py is a WIP port of the [Python 3.6.8 interpreter][cpython] to the Nintendo 3DS.
5+
3DS.py is a WIP port of the [Python 3.6.9 interpreter][cpython] to the Nintendo 3DS.
66
It allows you to run your Python scripts directly on the 3DS by having the interpreter
77
embedded into a homebrew application that launches a `main.py` script from the same
88
directory.

interpreter/Makefile

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
4444
CFLAGS += $(INCLUDE) -DARM11 -D_3DS -DWITH_THREAD
4545

4646
ifeq ($(strip $(PYVERSION)),)
47-
PYVERSION := 3.6.8
47+
PYVERSION := 3.6.9
4848
endif
4949

5050
ANAME := libpython$(shell echo $(PYVERSION) | cut -b 1-3).a
@@ -70,10 +70,7 @@ distPython: makePython
7070
cp $(ANAME) $(OUTDIR)/lib
7171
cp -r $(PYDIR)/Include/* $(OUTDIR)/include
7272
cp $(PYDIR)/pyconfig.h $(OUTDIR)/include
73-
cd $(PYDIR)/Lib && \
74-
ls *.py -1 | xargs zip ../../$(OUTDIR)/python_lib.zip && \
75-
find asyncio/ collections/ email/ encodings/ html/ http/ importlib/ json/ logging/ sqlite3/ test/ urllib/ xml/ -type f \
76-
| xargs zip ../../$(OUTDIR)/python_lib.zip
73+
zip -r $(OUTDIR)/python_lib.zip $(PYDIR)/Lib/
7774

7875
makePython: patchPython
7976
cd $(PYDIR) && \
@@ -82,10 +79,11 @@ makePython: patchPython
8279
cp $(PYDIR)/$(ANAME) .
8380

8481
patchPython: configurePython
85-
cp $(PATCH_DIR)/condvars_ctr.h $(PYDIR)/Python/condvars_ctr.h
86-
cp $(PATCH_DIR)/thread_ctr.h $(PYDIR)/Python/thread_ctr.h
82+
cp $(PATCH_DIR)/condvars_ctr.h $(PYDIR)/Python/
83+
cp $(PATCH_DIR)/thread_ctr.h $(PYDIR)/Python/
84+
patch $(PYDIR)/Python/fileutils.c $(PATCH_DIR)/fileutils.c.diff
8785
patch $(PYDIR)/pyconfig.h $(PATCH_DIR)/pyconfig.h.diff
88-
patch --ignore-whitespace $(PYDIR)/Makefile $(PATCH_DIR)/Makefile.diff
86+
patch $(PYDIR)/Makefile $(PATCH_DIR)/Makefile.diff
8987
patch $(PYDIR)/Modules/posixmodule.c $(PATCH_DIR)/posixmodule.c.diff
9088
patch $(PYDIR)/Python/ceval_gil.h $(PATCH_DIR)/ceval_gil.h.diff
9189
patch $(PYDIR)/Python/condvar.h $(PATCH_DIR)/condvar.h.diff
@@ -99,15 +97,13 @@ configurePython: preparePython
9997
cd $(PYDIR) && \
10098
./configure CC="$(CC)" CXX="$(CXX)" AS="$(AS)" AR="$(AR)" OBJCOPY="$(OBJCOPY)" STRIP="$(STRIP)" NM="$(NM)" RANLIB="$(RANLIB)" \
10199
CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" ASFLAGS="$(ASFLAGS)" LDFLAGS="$(LDFLAGS)" CONFIG_SITE=config.site \
102-
--without-doc-strings --disable-shared --disable-ipv6 --host=arm-none-eabi --build=`./config.guess` && \
100+
--enable-optimizations --without-doc-strings --disable-shared --disable-ipv6 --host=arm-none-eabi --build=`./config.guess` && \
103101
cd ..
104102

105103
preparePython: $(PYDIR)
106104
$(SED) -i -e 's/\*\-\*\-linux\*)/\*\-\*\-linux\*\|arm\-none\-eabi)/g' $(PYDIR)/configure
107-
echo "ac_cv_file__dev_ptmx=no" >$(PYDIR)/config.site
108-
echo "ac_cv_file__dev_ptc=no" >>$(PYDIR)/config.site
109-
echo "ac_cv_lib_dl_dlopen=no" >>$(PYDIR)/config.site
110-
cp $(PATCH_DIR)/Setup.dist $(PYDIR)/Modules/Setup.dist
105+
cp $(PATCH_DIR)/config.site $(PYDIR)/
106+
cp $(PATCH_DIR)/Setup.dist $(PYDIR)/Modules/
111107

112108
$(PYDIR):
113109
wget $(PYURL) || curl -L $(PYURL)

python_patches/Makefile.diff

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,59 @@
1-
--- interpreter/Python-3.6.8/Makefile 2019-05-30 14:20:39.268163375 +0200
2-
+++ python_patches/Makefile 2019-05-30 14:18:15.074830333 +0200
3-
@@ -22,9 +22,12 @@
4-
# === Variables set by makesetup ===
5-
6-
MODNAMES= posix errno _sre _codecs _weakref _functools _operator _collections itertools atexit _signal _stat time _locale _io zipimport faulthandler _tracemalloc _symtable array cmath math _struct _weakref _random _elementtree _pickle _datetime _bisect _heapq _asyncio unicodedata _md5 _sha1 _sha256 _sha512 zlib
7-
MODOBJS= Modules/posixmodule.o Modules/errnomodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/_weakref.o Modules/_functoolsmodule.o Modules/_operator.o Modules/_collectionsmodule.o Modules/itertoolsmodule.o Modules/atexitmodule.o Modules/signalmodule.o Modules/_stat.o Modules/timemodule.o Modules/_localemodule.o Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o Modules/zipimport.o Modules/faulthandler.o Modules/_tracemalloc.o Modules/hashtable.o Modules/symtablemodule.o Modules/arraymodule.o Modules/cmathmodule.o Modules/_math.o Modules/mathmodule.o Modules/_math.o Modules/_struct.o Modules/_weakref.o Modules/_randommodule.o Modules/_elementtree.o Modules/_pickle.o Modules/_datetimemodule.o Modules/_bisectmodule.o Modules/_heapqmodule.o Modules/_asynciomodule.o Modules/unicodedata.o Modules/md5module.o Modules/sha1module.o Modules/sha256module.o Modules/sha512module.o Modules/zlibmodule.o
8-
MODLIBS= $(LOCALMODLIBS) $(BASEMODLIBS)
9-
+
10-
+MODNAMES+= _thread
11-
+MODOBJS+= Modules/_threadmodule.o
12-
13-
# === Variables set by configure
14-
VERSION= 3.6
15-
srcdir= .
16-
@@ -226,7 +229,7 @@
17-
SYSLIBS= $(LIBM) $(LIBC)
18-
SHLIBS= $(LIBS)
19-
20-
-THREADOBJ=
21-
+THREADOBJ= Python/thread.o
22-
DLINCLDIR= .
23-
DYNLOADFILE= dynload_stub.o
24-
MACHDEP_OBJS=
25-
@@ -1736,7 +1739,7 @@
26-
27-
# Dependencies
28-
29-
-Python/thread.o: $(srcdir)/Python/thread_foobar.h $(srcdir)/Python/thread_nt.h $(srcdir)/Python/thread_pthread.h
30-
+Python/thread.o: $(srcdir)/Python/thread_foobar.h $(srcdir)/Python/thread_nt.h $(srcdir)/Python/thread_pthread.h $(srcdir)/Python/thread_ctr.h
31-
32-
# Declare targets that aren't real files
33-
.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest
34-
@@ -1755,6 +1758,8 @@
35-
36-
# Rules appended by makedepend
37-
38-
+Modules/_threadmodule.o: $(srcdir)/Modules/_threadmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_threadmodule.c -o Modules/_threadmodule.o
39-
+Modules/_thread$(EXT_SUFFIX): Modules/_threadmodule.o; $(BLDSHARED) Modules/_threadmodule.o -o Modules/_thread$(EXT_SUFFIX)
40-
Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/posixmodule.c -o Modules/posixmodule.o
41-
Modules/posix$(EXT_SUFFIX): Modules/posixmodule.o; $(BLDSHARED) Modules/posixmodule.o -o Modules/posix$(EXT_SUFFIX)
42-
Modules/errnomodule.o: $(srcdir)/Modules/errnomodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/errnomodule.c -o Modules/errnomodule.o
1+
*** interpreter/Python-3.6.9/Makefile 2019-07-25 21:47:31.900963535 +0200
2+
--- python_patches/Makefile 2019-07-25 21:36:32.807631976 +0200
3+
***************
4+
*** 25,30 ****
5+
--- 25,33 ----
6+
MODOBJS= Modules/posixmodule.o Modules/errnomodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/_weakref.o Modules/_functoolsmodule.o Modules/_operator.o Modules/_collectionsmodule.o Modules/itertoolsmodule.o Modules/atexitmodule.o Modules/signalmodule.o Modules/_stat.o Modules/timemodule.o Modules/_localemodule.o Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o Modules/zipimport.o Modules/faulthandler.o Modules/_tracemalloc.o Modules/hashtable.o Modules/symtablemodule.o Modules/arraymodule.o Modules/cmathmodule.o Modules/_math.o Modules/mathmodule.o Modules/_math.o Modules/_struct.o Modules/_weakref.o Modules/_randommodule.o Modules/_elementtree.o Modules/_pickle.o Modules/_datetimemodule.o Modules/_bisectmodule.o Modules/_heapqmodule.o Modules/_asynciomodule.o Modules/unicodedata.o Modules/md5module.o Modules/sha1module.o Modules/sha256module.o Modules/sha512module.o Modules/zlibmodule.o
7+
MODLIBS= $(LOCALMODLIBS) $(BASEMODLIBS)
8+
9+
+ MODNAMES+= _thread
10+
+ MODOBJS+= Modules/_threadmodule.o
11+
+
12+
# === Variables set by configure
13+
VERSION= 3.6
14+
srcdir= .
15+
***************
16+
*** 226,232 ****
17+
SYSLIBS= $(LIBM) $(LIBC)
18+
SHLIBS= $(LIBS)
19+
20+
! THREADOBJ=
21+
DLINCLDIR= .
22+
DYNLOADFILE= dynload_stub.o
23+
MACHDEP_OBJS=
24+
--- 229,235 ----
25+
SYSLIBS= $(LIBM) $(LIBC)
26+
SHLIBS= $(LIBS)
27+
28+
! THREADOBJ= Python/thread.o
29+
DLINCLDIR= .
30+
DYNLOADFILE= dynload_stub.o
31+
MACHDEP_OBJS=
32+
***************
33+
*** 1736,1742 ****
34+
35+
# Dependencies
36+
37+
! Python/thread.o: $(srcdir)/Python/thread_foobar.h $(srcdir)/Python/thread_nt.h $(srcdir)/Python/thread_pthread.h
38+
39+
# Declare targets that aren't real files
40+
.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest
41+
--- 1739,1745 ----
42+
43+
# Dependencies
44+
45+
! Python/thread.o: $(srcdir)/Python/thread_foobar.h $(srcdir)/Python/thread_nt.h $(srcdir)/Python/thread_pthread.h $(srcdir)/Python/thread_ctr.h
46+
47+
# Declare targets that aren't real files
48+
.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest
49+
***************
50+
*** 1755,1760 ****
51+
--- 1758,1765 ----
52+
53+
# Rules appended by makedepend
54+
55+
+ Modules/_threadmodule.o: $(srcdir)/Modules/_threadmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_threadmodule.c -o Modules/_threadmodule.o
56+
+ Modules/_thread$(EXT_SUFFIX): Modules/_threadmodule.o; $(BLDSHARED) Modules/_threadmodule.o -o Modules/_thread$(EXT_SUFFIX)
57+
Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/posixmodule.c -o Modules/posixmodule.o
58+
Modules/posix$(EXT_SUFFIX): Modules/posixmodule.o; $(BLDSHARED) Modules/posixmodule.o -o Modules/posix$(EXT_SUFFIX)
59+
Modules/errnomodule.o: $(srcdir)/Modules/errnomodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/errnomodule.c -o Modules/errnomodule.o

python_patches/ceval_gil.h.diff

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
1-
--- interpreter/Python-3.6.8/Python/ceval_gil.h 2018-12-23 22:37:14.000000000 +0100
2-
+++ python_patches/ceval_gil.h 2019-05-25 20:40:44.520666533 +0200
3-
@@ -79,9 +79,16 @@
4-
Py_FatalError("PyMUTEX_UNLOCK(" #mut ") failed"); };
5-
6-
#define COND_T PyCOND_T
7-
+
8-
+#ifdef _3DS
9-
+#define COND_INIT(cond, mut) \
10-
+ if (PyCOND_INIT(&(cond), &(mut))) { \
11-
+ Py_FatalError("PyCOND_INIT(" #cond ") failed"); };
12-
+#else
13-
#define COND_INIT(cond) \
14-
if (PyCOND_INIT(&(cond))) { \
15-
Py_FatalError("PyCOND_INIT(" #cond ") failed"); };
16-
+#endif
17-
#define COND_FINI(cond) \
18-
if (PyCOND_FINI(&(cond))) { \
19-
Py_FatalError("PyCOND_FINI(" #cond ") failed"); };
20-
@@ -138,9 +145,9 @@
21-
#ifdef FORCE_SWITCHING
22-
MUTEX_INIT(switch_mutex);
23-
#endif
24-
- COND_INIT(gil_cond);
25-
+ COND_INIT(gil_cond, gil_mutex);
26-
#ifdef FORCE_SWITCHING
27-
- COND_INIT(switch_cond);
28-
+ COND_INIT(switch_cond, switch_mutex);
29-
#endif
30-
_Py_atomic_store_relaxed(&gil_last_holder, 0);
31-
_Py_ANNOTATE_RWLOCK_CREATE(&gil_locked);
1+
*** interpreter/Python-3.6.9/Python/ceval_gil.h 2019-07-02 22:25:39.000000000 +0200
2+
--- python_patches/ceval_gil.h 2019-07-25 21:35:28.447632153 +0200
3+
***************
4+
*** 79,87 ****
5+
--- 79,94 ----
6+
Py_FatalError("PyMUTEX_UNLOCK(" #mut ") failed"); };
7+
8+
#define COND_T PyCOND_T
9+
+
10+
+ #ifdef _3DS
11+
+ #define COND_INIT(cond, mut) \
12+
+ if (PyCOND_INIT(&(cond), &(mut))) { \
13+
+ Py_FatalError("PyCOND_INIT(" #cond ") failed"); };
14+
+ #else
15+
#define COND_INIT(cond) \
16+
if (PyCOND_INIT(&(cond))) { \
17+
Py_FatalError("PyCOND_INIT(" #cond ") failed"); };
18+
+ #endif
19+
#define COND_FINI(cond) \
20+
if (PyCOND_FINI(&(cond))) { \
21+
Py_FatalError("PyCOND_FINI(" #cond ") failed"); };
22+
***************
23+
*** 138,146 ****
24+
#ifdef FORCE_SWITCHING
25+
MUTEX_INIT(switch_mutex);
26+
#endif
27+
! COND_INIT(gil_cond);
28+
#ifdef FORCE_SWITCHING
29+
! COND_INIT(switch_cond);
30+
#endif
31+
_Py_atomic_store_relaxed(&gil_last_holder, 0);
32+
_Py_ANNOTATE_RWLOCK_CREATE(&gil_locked);
33+
--- 145,153 ----
34+
#ifdef FORCE_SWITCHING
35+
MUTEX_INIT(switch_mutex);
36+
#endif
37+
! COND_INIT(gil_cond, gil_mutex);
38+
#ifdef FORCE_SWITCHING
39+
! COND_INIT(switch_cond, switch_mutex);
40+
#endif
41+
_Py_atomic_store_relaxed(&gil_last_holder, 0);
42+
_Py_ANNOTATE_RWLOCK_CREATE(&gil_locked);

python_patches/condvar.h.diff

Lines changed: 74 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,74 @@
1-
--- interpreter/Python-3.6.8/Python/condvar.h 2018-12-23 22:37:14.000000000 +0100
2-
+++ python_patches/condvar.h 2019-05-25 20:47:58.217332113 +0200
3-
@@ -109,6 +109,69 @@
4-
return 0;
5-
}
6-
7-
+#elif defined(_3DS)
8-
+
9-
+#define Py_HAVE_CONDVAR
10-
+
11-
+#include "condvars_ctr.h"
12-
+
13-
+/* The following functions return 0 on success, nonzero on error. */
14-
+#define PyMUTEX_T LightLock
15-
+
16-
+Py_LOCAL_INLINE(int)
17-
+PyMUTEX_INIT(PyMUTEX_T *mut) {
18-
+ LightLock_Init(mut);
19-
+ return 0;
20-
+}
21-
+
22-
+Py_LOCAL_INLINE(int)
23-
+PyMUTEX_FINI(PyMUTEX_T *mut) {
24-
+ LightLock_Init(mut);
25-
+ return 0;
26-
+}
27-
+
28-
+Py_LOCAL_INLINE(int)
29-
+PyMUTEX_LOCK(PyMUTEX_T *mut) {
30-
+ LightLock_Lock(mut);
31-
+ return 0;
32-
+}
33-
+
34-
+Py_LOCAL_INLINE(int)
35-
+PyMUTEX_UNLOCK(PyMUTEX_T *mut) {
36-
+ LightLock_Unlock(mut);
37-
+ return 0;
38-
+}
39-
+
40-
+#define PyCOND_T CondVar
41-
+
42-
+Py_LOCAL_INLINE(int)
43-
+PyCOND_INIT(PyCOND_T *cond, PyMUTEX_T *mut) {
44-
+ CondVar_Init(cond, mut);
45-
+ return 0;
46-
+}
47-
+
48-
+
49-
+#define PyCOND_FINI(cond) 0
50-
+#define PyCOND_SIGNAL(cond) CondVar_NotifyOne((cond))
51-
+#define PyCOND_BROADCAST(cond) CondVar_NotifyAll((cond))
52-
+#define PyCOND_WAIT(cond, mut) CondVar_Wait((cond), (mut))
53-
+
54-
+/* Return 0 for success, 1 on timeout, -1 on error. */
55-
+Py_LOCAL_INLINE(int)
56-
+PyCOND_TIMEDWAIT(PyCOND_T *cond, PyMUTEX_T *mut, PY_LONG_LONG us)
57-
+{
58-
+ bool r;
59-
+ u64 ns = us * 1000; // microseconds to nanoseconds
60-
+
61-
+ r = CondVar_WaitTimeout((cond), (mut), ns);
62-
+ if (r == 1)
63-
+ return 0;
64-
+ else if (!r) // timeout
65-
+ return 0;
66-
+ else
67-
+ return -1;
68-
+}
69-
+
70-
#elif defined(NT_THREADS)
71-
/*
72-
* Windows (XP, 2003 server and later, as well as (hopefully) CE) support
1+
*** interpreter/Python-3.6.9/Python/condvar.h 2019-07-02 22:25:39.000000000 +0200
2+
--- python_patches/condvar.h 2019-07-25 21:35:50.697632088 +0200
3+
***************
4+
*** 109,114 ****
5+
--- 109,177 ----
6+
return 0;
7+
}
8+
9+
+ #elif defined(_3DS)
10+
+
11+
+ #define Py_HAVE_CONDVAR
12+
+
13+
+ #include "condvars_ctr.h"
14+
+
15+
+ /* The following functions return 0 on success, nonzero on error. */
16+
+ #define PyMUTEX_T LightLock
17+
+
18+
+ Py_LOCAL_INLINE(int)
19+
+ PyMUTEX_INIT(PyMUTEX_T *mut) {
20+
+ LightLock_Init(mut);
21+
+ return 0;
22+
+ }
23+
+
24+
+ Py_LOCAL_INLINE(int)
25+
+ PyMUTEX_FINI(PyMUTEX_T *mut) {
26+
+ LightLock_Init(mut);
27+
+ return 0;
28+
+ }
29+
+
30+
+ Py_LOCAL_INLINE(int)
31+
+ PyMUTEX_LOCK(PyMUTEX_T *mut) {
32+
+ LightLock_Lock(mut);
33+
+ return 0;
34+
+ }
35+
+
36+
+ Py_LOCAL_INLINE(int)
37+
+ PyMUTEX_UNLOCK(PyMUTEX_T *mut) {
38+
+ LightLock_Unlock(mut);
39+
+ return 0;
40+
+ }
41+
+
42+
+ #define PyCOND_T CondVar
43+
+
44+
+ Py_LOCAL_INLINE(int)
45+
+ PyCOND_INIT(PyCOND_T *cond, PyMUTEX_T *mut) {
46+
+ CondVar_Init(cond, mut);
47+
+ return 0;
48+
+ }
49+
+
50+
+
51+
+ #define PyCOND_FINI(cond) 0
52+
+ #define PyCOND_SIGNAL(cond) CondVar_NotifyOne((cond))
53+
+ #define PyCOND_BROADCAST(cond) CondVar_NotifyAll((cond))
54+
+ #define PyCOND_WAIT(cond, mut) CondVar_Wait((cond), (mut))
55+
+
56+
+ /* Return 0 for success, 1 on timeout, -1 on error. */
57+
+ Py_LOCAL_INLINE(int)
58+
+ PyCOND_TIMEDWAIT(PyCOND_T *cond, PyMUTEX_T *mut, PY_LONG_LONG us)
59+
+ {
60+
+ bool r;
61+
+ u64 ns = us * 1000; // microseconds to nanoseconds
62+
+
63+
+ r = CondVar_WaitTimeout((cond), (mut), ns);
64+
+ if (r == 1)
65+
+ return 0;
66+
+ else if (!r) // timeout
67+
+ return 0;
68+
+ else
69+
+ return -1;
70+
+ }
71+
+
72+
#elif defined(NT_THREADS)
73+
/*
74+
* Windows (XP, 2003 server and later, as well as (hopefully) CE) support

python_patches/config.site

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ac_cv_file__dev_ptmx=no
2+
ac_cv_file__dev_ptc=no
3+
ac_cv_lib_dl_dlopen=no

0 commit comments

Comments
 (0)