Subject: [alpine-aports] [PATCH] new aport: testing/micropython

From: Marian Buschsieweke <[email-masked]>
Date: Wed, 2 Aug 2017 09:24:03 +0200

A lean and efficient Python implementation for MCUs and constrained systems
http://www.micropython.org/
---
 testing/micropython/0000-unix-mpconfigport.patch | 22 ++++++++++++
 testing/micropython/APKBUILD                     | 44 ++++++++++++++++++++++++
 2 files changed, 66 insertions(+)
 create mode 100644 testing/micropython/0000-unix-mpconfigport.patch
 create mode 100644 testing/micropython/APKBUILD

diff --git a/testing/micropython/0000-unix-mpconfigport.patch b/testing/micropython/0000-unix-mpconfigport.patch
new file mode 100644
index 0000000000..9025694ff2
--- /dev/null
+++ b/testing/micropython/0000-unix-mpconfigport.patch
@@ -0,0 +1,22 @@
+--- old/micropython-1.9.1/unix/mpconfigport.mk
++++ new/micropython-1.9.1/unix/mpconfigport.mk
+@@ -9,7 +9,7 @@
+ MICROPY_USE_READLINE = 1
+ 
+ # btree module using Berkeley DB 1.xx
+-MICROPY_PY_BTREE = 1
++MICROPY_PY_BTREE = 0
+ 
+ # _thread module using pthreads
+ MICROPY_PY_THREAD = 1
+@@ -24,8 +24,8 @@
+ MICROPY_PY_FFI = 1
+ 
+ # ussl module requires axtls
+-MICROPY_PY_USSL = 1
+-MICROPY_SSL_AXTLS = 1
++MICROPY_PY_USSL = 0
++MICROPY_SSL_AXTLS = 0
+ MICROPY_SSL_MBEDTLS = 0
+ 
+ # jni module requires JVM/JNI
diff --git a/testing/micropython/APKBUILD b/testing/micropython/APKBUILD
new file mode 100644
index 0000000000..fb7b141623
--- /dev/null
+++ b/testing/micropython/APKBUILD
@@ -0,0 +1,44 @@
+# Contributor: Marian <[email-masked]>
+# Maintainer: Marian <[email-masked]>
+pkgname=micropython
+pkgver=1.9.1
+pkgrel=0
+pkgdesc="A lean and efficient Python implementation for MCUs and constrained systems"
+url="http://www.micropython.org/"
+arch="all"
+license="MIT"
+depends=""
+makedepends="libffi-dev python3"
+subpackages=""
+source="${pkgname}-${pkgver}.tar.gz::https://github.com/${pkgname}/${pkgname}/archive/v${pkgver}.tar.gz
+        0000-unix-mpconfigport.patch"
+builddir="${srcdir}/${pkgname}-${pkgver}/unix"
+
+prepare() {
+	cd "${srcdir}"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+	cd "$builddir"
+	unset CFLAGS
+	make
+}
+
+check() {
+	cd "$builddir"
+	make test
+}
+
+package() {
+	cd "$builddir"
+	mkdir -p "${pkgdir}/usr/bin"
+	install -m755 micropython "${pkgdir}/usr/bin/micropython"
+}
+
+sha512sums="bc0eeb1e6d821034b7157613f2d421df304f2959e9fd62d2886641eba8d74575787861c9ff46fc3bcb9c14c6ad1f698043231801207f946af9b5d302bb253c63  micropython-1.9.1.tar.gz
+926515a76dc856192de79a7c35c390bd533a38a2c163812ce5a3739280ca33881791f3d199922edb2e577ec9ac16265dc4891ad96f6c6eb4e7cf9d5ae8044a32  0000-unix-mpconfigport.patch"
-- 
2.13.2

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Thu, 3 Aug 2017 13:52:04 +0200

On Wed,  2 Aug 2017 09:24:03 +0200

> +		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;

You don't need the prepare() function. Recent abuild will do that
automatically for you.

> +	unset CFLAGS

Why is unsetting CFLAGS needed?

> +	install -m755 micropython "${pkgdir}/usr/bin/micropython"

build fails due to missing pyhon:

Generating build/frozen.c
env: can't execute 'python': No such file or directory

When I add python2 to makedepends it fails during tests:

...
skip  unix/extra_coverage.py
FAIL  unix/ffi_callback.py
pass  unix/ffi_float.py
pass  unix/ffi_float2.py
597 tests performed (18223 individual testcases)
596 tests passed
40 tests skipped: builtin_help class_delattr_setattr cmd_parsetree btree1 framebuf1 framebuf16 framebuf4 uhashlib_sha1 urandom_extra ussl_basic vfs_basic vfs_fa
t_fileio1 vfs_fat_fileio2 vfs_fat_more vfs_fat_oldproto vfs_fat_ramdisk buffered_writer native_closure native_const_intbig native_misc schedule viper_addr viper
_args viper_binop_arith viper_binop_comp viper_binop_comp_imm viper_binop_multi_comp viper_cond viper_error viper_import viper_misc viper_misc_intbig viper_ptr1
6_load viper_ptr16_store viper_ptr32_load viper_ptr32_store viper_ptr8_load viper_ptr8_store viper_subscr extra_coverage
1 tests failed: ffi_callback
make: *** [Makefile:192: test] Error 1

---

---

From: Natanael Copa <[email-masked]>
Date: Thu, 3 Aug 2017 14:52:04 +0200

On Thu, 3 Aug 2017 13:52:04 +0200

> > http://www.micropython.org/

Hi,

I pushed this and added a few cleanups and workaround the ffi_callback.

I also added python2 to makedepends, but it would be nice to patch
whatever needed so we dont need the python2 package. I did start with a
python3.patch but didn't complete it.

Would be nice if you could have a look at that.

Thanks!

-nc

---