Skip to contentSkip to conversation

micropython: new package

PATCH New Chris Packham 5 participants 38 messages Sep 14, 2015 – Sep 19, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 micropython: new package

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems.

---

Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Cheers,
Chris

 package/Config.in                          |  2 ++
 package/micropython-lib/Config.in          |  7 +++++++
 package/micropython-lib/micropython-lib.mk | 12 ++++++++++++
 package/micropython/Config.in              |  8 ++++++++
 package/micropython/micropython.mk         | 22 ++++++++++++++++++++++
 5 files changed, 51 insertions(+)
 create mode 100644 package/micropython-lib/Config.in
 create mode 100644 package/micropython-lib/micropython-lib.mk
 create mode 100644 package/micropython/Config.in
 create mode 100644 package/micropython/micropython.mk
package/Config.in +2 -0
index fc35f12..986fe16 100644
@@ -509,6 +509,8 @@ menu "Lua libraries/modules"
 endmenu
 endif
 	source "package/lutok/Config.in"
+	source "package/micropython/Config.in"
+	source "package/micropython-lib/Config.in"
 	source "package/moarvm/Config.in"
 	source "package/mono/Config.in"
 if BR2_PACKAGE_MONO
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +12 -0
new file mode 100644
index 0000000..c0e6a2a
@@ -0,0 +1,12 @@
+################################################################################
+# micropython-lib
+################################################################################
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+	$(MAKE) -C $(@D) PREFIX=$(TARGET_DIR)/usr/lib/micropython install
+endef
+
+$(eval $(generic-package))
package/micropython/Config.in new file +8 -0
new file mode 100644
index 0000000..ca60f01
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_MICROPYTHON
+	bool "micropython"
+	select BR2_PACKAGE_LIBFFI
+	help
+	  MicroPython - a lean and efficient Python implementation for
+	  microcontrollers and constrained systems.
+
+	  http://micropython.org
package/micropython/micropython.mk new file +22 -0
new file mode 100644
index 0000000..9b5e7d2
@@ -0,0 +1,22 @@
+################################################################################
+# micropython
+################################################################################
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = libffi
+
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(MAKE) -C $(@D)/unix \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		DESTDIR=$(TARGET_DIR) \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+		install
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/1 micropython: new package

Dear Chris Packham,

Quoted 2 lines · Chris Packham

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems.

The website says:

"Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller."

So, why don't we use that comment instead? It also specifies the Python version which is important.

More comments below. Please scroll down.

Quoted 73 lines

---

Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Cheers,
Chris

 package/Config.in                          |  2 ++
 package/micropython-lib/Config.in          |  7 +++++++
 package/micropython-lib/micropython-lib.mk | 12 ++++++++++++
 package/micropython/Config.in              |  8 ++++++++
 package/micropython/micropython.mk         | 22 ++++++++++++++++++++++
 5 files changed, 51 insertions(+)
 create mode 100644 package/micropython-lib/Config.in
 create mode 100644 package/micropython-lib/micropython-lib.mk
 create mode 100644 package/micropython/Config.in
 create mode 100644 package/micropython/micropython.mk
package/Config.in +2 -0
index fc35f12..986fe16 100644
@@ -509,6 +509,8 @@ menu "Lua libraries/modules"
 endmenu
 endif
 	source "package/lutok/Config.in"
+	source "package/micropython/Config.in"
+	source "package/micropython-lib/Config.in"
 	source "package/moarvm/Config.in"
 	source "package/mono/Config.in"
 if BR2_PACKAGE_MONO
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +12 -0
new file mode 100644
index 0000000..c0e6a2a
@@ -0,0 +1,12 @@
+################################################################################
+# micropython-lib
+################################################################################
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+	$(MAKE) -C $(@D) PREFIX=$(TARGET_DIR)/usr/lib/micropython install
+endef
+
+$(eval $(generic-package))
package/micropython/Config.in new file +0 -0
new file mode 100644
index 0000000..ca60f01

package/micropython/Config.in line 6

Quoted 6 lines
package/micropython/Config.in new file +6 -0
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_MICROPYTHON
+	bool "micropython"
+	select BR2_PACKAGE_LIBFFI
+	help
+	  MicroPython - a lean and efficient Python implementation for
+	  microcontrollers and constrained systems.

Same here, I would use the same exact command you can find in mycropython's website.

Quoted 10 lines
package/micropython/Config.in new file +2 -0
+
+	  http://micropython.org
package/micropython/micropython.mk new file +2 -0
new file mode 100644
index 0000000..9b5e7d2
@@ -0,0 +1,22 @@
+################################################################################
+# micropython

package/micropython/micropython.mk line 12

Quoted 10 lines
package/micropython/micropython.mk new file +10 -0
+################################################################################
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = libffi
+
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif

A comment about why this is necessary for powerpc would be good, IMHO.

Regards,

Vincent.

Quoted 11 lines
package/micropython/micropython.mk new file +10 -0
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(MAKE) -C $(@D)/unix \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		DESTDIR=$(TARGET_DIR) \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+		install
+endef
+
+$(eval $(generic-package))
#2 lore raw

PATCH 1/1 micropython: new package

Hi Vincent,

Quoted 1 line · Vicente Olivert Riera

On 09/14/2015 11:21 AM, Chris Packham wrote:

<snip>

Quoted 6 lines

package/micropython/micropython.mk line 12

Quoted 3 lines
package/micropython/micropython.mk new file +3 -0
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif

A comment about why this is necessary for powerpc would be good, IMHO.

Full explanation is here
https://github.com/micropython/micropython#the-unix-version I'll try to include a short comment in the makefile.

#3 lore raw

PATCH 1/1 micropython: new package

In reply to Chris Packham

Dear Chris Packham,

more comments:

Quoted 6 lines · Chris Packham
package/micropython/micropython.mk new file +0 -0
new file mode 100644
index 0000000..9b5e7d2

package/micropython/micropython.mk line 8

Quoted 8 lines
package/micropython/micropython.mk new file +8 -0
@@ -0,0 +1,22 @@
+################################################################################
+# micropython
+################################################################################
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = libffi

micropython calls pkg-config in order to obtain the libraries and cflags for libffi:

ifeq ($(MICROPY_PY_FFI),1)
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi) LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi) CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1

So please, add host-pkgconf to MICROPYTHON_DEPENDENCIES. Otherwise it will fail to compile with an error like this one:

LINK micropython
build/modffi.o: In function `ffifunc_call':
modffi.c:(.text+0x24c): undefined reference to ffi_call' modffi.c:(.text+0x260): undefined reference to ffi_call' build/modffi.o: In function `mod_ffi_callback':
modffi.c:(.text+0x7b0): undefined reference to `ffi_closure_alloc' ... and many more

package/micropython/micropython.mk line 15

Quoted 7 lines
package/micropython/micropython.mk new file +7 -0
+
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(MAKE) -C $(@D)/unix \

Please add $(TARGET_MAKE_ENV) before $(MAKE). You need that in order to Buildroot set the PATH variable so the pkg-config executable and the libffi.pc file can be found.

Regards,

Vincent.

Quoted 8 lines
package/micropython/micropython.mk new file +7 -0
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		DESTDIR=$(TARGET_DIR) \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+		install
+endef
+
+$(eval $(generic-package))
#4 lore raw

PATCH 1/1 micropython: new package

Hi Vincent,

Quoted 55 lines · Vicente Olivert Riera

Dear Chris Packham,

more comments:

Quoted 6 lines · Chris Packham
package/micropython/micropython.mk new file +0 -0
new file mode 100644
index 0000000..9b5e7d2

package/micropython/micropython.mk line 8

Quoted 8 lines
package/micropython/micropython.mk new file +8 -0
@@ -0,0 +1,22 @@
+################################################################################
+# micropython
+################################################################################
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = libffi

micropython calls pkg-config in order to obtain the libraries and cflags for libffi:

ifeq ($(MICROPY_PY_FFI),1)
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi) LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi) CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1

So please, add host-pkgconf to MICROPYTHON_DEPENDENCIES. Otherwise it will fail to compile with an error like this one:

LINK micropython
build/modffi.o: In function `ffifunc_call':
modffi.c:(.text+0x24c): undefined reference to ffi_call' modffi.c:(.text+0x260): undefined reference to ffi_call' build/modffi.o: In function `mod_ffi_callback':
modffi.c:(.text+0x7b0): undefined reference to `ffi_closure_alloc' ... and many more

package/micropython/micropython.mk line 15

Quoted 7 lines
package/micropython/micropython.mk new file +7 -0
+
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+     $(MAKE) -C $(@D)/unix \

Please add $(TARGET_MAKE_ENV) before $(MAKE). You need that in order to Buildroot set the PATH variable so the pkg-config executable and the libffi.pc file can be found.

Regards,

Vincent.

Quoted 9 lines

package/micropython/micropython.mk line 22

Quoted 8 lines
package/micropython/micropython.mk new file +7 -0
+             CROSS_COMPILE=$(TARGET_CROSS) \
+             DESTDIR=$(TARGET_DIR) \
+             CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+             install
+endef
+
+$(eval $(generic-package))

OK thanks. Will look at these comments and the ones from the other mail. I was using qemu_x86_defconfig for testing so it probably picked up things from my host environment.

#5 lore raw

PATCH 1/1 micropython: new package

In reply to Chris Packham

Chris,

Thanks for this contribution.

Quoted 11 lines · Chris Packham

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems.

---

Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Some quick questions that come to mind:

* What happens if we have Micropython installed next to the regular Python 2 or Python 3 interpreters / standard library on the same system? Do they conflict or not?

* What about all the Python external modules (package/python-*/) we have in Buildroot? Do they work with Micropython?

Quoted 19 lines
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +0 -0
new file mode 100644
index 0000000..c0e6a2a

package/micropython-lib/micropython-lib.mk line 3

Quoted 3 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
@@ -0,0 +1,12 @@
+################################################################################
+# micropython-lib
+################################################################################

Nitpick: use the standard header for all packages. You lack an empty line before and after the package name. See all other Buildroot packages. Ditto for the micropython package.

package/micropython-lib/micropython-lib.mk line 6

Quoted 3 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE

You should define MICROPYTHON_LIB_LICENSE as well.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#6 lore raw

PATCH 1/1 micropython: new package

Dear Thomas Petazzoni,

Quoted 17 lines · Thomas Petazzoni

Chris,

Thanks for this contribution.

Quoted 11 lines · Chris Packham

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems.

---

Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Quoted 5 lines

Some quick questions that come to mind:

* What happens if we have Micropython installed next to the regular Python 2 or Python 3 interpreters / standard library on the same system? Do they conflict or not?

It shouldn't conflict as micropython installs the library files under /usr/lib/micropython/ directory. And the installed binaries are /usr/local/bin/{pip-}micropython. Perhaps this should be changed to install them in /usr instead of /usr/local.

Regards,

Vincent.

Quoted 38 lines

* What about all the Python external modules (package/python-*/) we have in Buildroot? Do they work with Micropython?

Quoted 19 lines
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +0 -0
new file mode 100644
index 0000000..c0e6a2a

package/micropython-lib/micropython-lib.mk line 3

Quoted 3 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
@@ -0,0 +1,12 @@
+################################################################################
+# micropython-lib
+################################################################################

Nitpick: use the standard header for all packages. You lack an empty line before and after the package name. See all other Buildroot packages. Ditto for the micropython package.

package/micropython-lib/micropython-lib.mk line 6

Quoted 3 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE

You should define MICROPYTHON_LIB_LICENSE as well.

Thomas

#7 lore raw

PATCH 1/1 micropython: new package

Quoted 22 lines · Vicente Olivert Riera

Dear Thomas Petazzoni,

Quoted 19 lines · Thomas Petazzoni

Chris,

Thanks for this contribution.

Quoted 11 lines · Chris Packham

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems.

---

Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Some quick questions that come to mind:

Quoted 8 lines
Quoted 3 lines

* What happens if we have Micropython installed next to the regular Python 2 or Python 3 interpreters / standard library on the same system? Do they conflict or not?

It shouldn't conflict as micropython installs the library files under /usr/lib/micropython/ directory. And the installed binaries are /usr/local/bin/{pip-}micropython. Perhaps this should be changed to install them in /usr instead of /usr/local.

The local part seems hard-coded to me. But we could always sed it on the way through.

Quoted 43 lines

Regards,

Vincent.

Quoted 38 lines

* What about all the Python external modules (package/python-*/) we have in Buildroot? Do they work with Micropython?

Quoted 19 lines
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+    bool "micropython-lib"
+    depends on BR2_PACKAGE_MICROPYTHON
+    help
+      Core Python libraries ported to MicroPython.
+
+      http://micropython.org
package/micropython-lib/micropython-lib.mk new file +0 -0
new file mode 100644
index 0000000..c0e6a2a

package/micropython-lib/micropython-lib.mk line 3

Quoted 3 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
@@ -0,0 +1,12 @@
+################################################################################
+# micropython-lib
+################################################################################

Nitpick: use the standard header for all packages. You lack an empty line before and after the package name. See all other Buildroot packages. Ditto for the micropython package.

package/micropython-lib/micropython-lib.mk line 6

Quoted 3 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE

You should define MICROPYTHON_LIB_LICENSE as well.

Thomas

#8 lore raw

PATCH 1/1 micropython: new package

Chris,

Quoted 7 lines · Chris Packham
Quoted 4 lines

It shouldn't conflict as micropython installs the library files under /usr/lib/micropython/ directory. And the installed binaries are /usr/local/bin/{pip-}micropython. Perhaps this should be changed to install them in /usr instead of /usr/local.

The local part seems hard-coded to me. But we could always sed it on the way through.

It's not normal for Buildroot systems to have stuff in /usr/local. Perhaps you could write a patch for micropython to make this configurable and submit the patch upstream?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#9 lore raw

PATCH 1/1 micropython: new package

In reply to Chris Packham
Quoted 4 lines · Chris Packham
Quoted 2 lines · Vicente Olivert Riera

Dear Thomas Petazzoni,

Quoted 8 lines
Quoted 5 lines

It shouldn't conflict as micropython installs the library files under
/usr/lib/micropython/ directory. And the installed binaries are /usr/local/bin/{pip-}micropython. Perhaps this should be changed to install them in /usr instead of /usr/local.

The local part seems hard-coded to me. But we could always sed it on the way through.

Adding PREFIX=$(TARGET_DIR)/usr to MICROPYTHON_INSTALL_TARGET_CMDS works for me:

$ ls output/target/usr/bin/
micropython  pip-micropython

Best regards
J?rg Krause

#10 lore raw

PATCH 1/1 micropython: new package

In reply to Thomas Petazzoni
Quoted 17 lines · Thomas Petazzoni

Chris,

Thanks for this contribution.

Quoted 11 lines · Chris Packham

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems.

---

Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Quoted 5 lines

Some quick questions that come to mind:

* What happens if we have Micropython installed next to the regular Python 2 or Python 3 interpreters / standard library on the same system? Do they conflict or not?

They're installed in with different executable names and library paths so they should co-exist happily.

Quoted 3 lines

* What about all the Python external modules (package/python-*/) we have in Buildroot? Do they work with Micropython?

Probably depends on the module, but I assume the answer is mostly no. Some of the "standard" libraries in micropython-lib are stubs to quote the readme: "micropython-lib is a highly experimental community project". Getting into buildroot is one way of helping them to move out of "experimental" status.

Quoted 18 lines
Quoted 18 lines
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+     bool "micropython-lib"
+     depends on BR2_PACKAGE_MICROPYTHON
+     help
+       Core Python libraries ported to MicroPython.
+
+       http://micropython.org
package/micropython-lib/micropython-lib.mk new file +0 -0
new file mode 100644
index 0000000..c0e6a2a
Quoted 9 lines

package/micropython-lib/micropython-lib.mk line 3

Quoted 4 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
@@ -0,0 +1,12 @@
+################################################################################
+# micropython-lib
+################################################################################

Nitpick: use the standard header for all packages. You lack an empty line before and after the package name. See all other Buildroot packages. Ditto for the micropython package.

Will do.

Quoted 5 lines

package/micropython-lib/micropython-lib.mk line 6

Quoted 3 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE

You should define MICROPYTHON_LIB_LICENSE as well.

That's an interesting problem. It's actually multiple licenses (depending on the source of the library) so nothing in the "normal"[1] list fits. I could say "various" or enumerate the ones I can identify but it would be hard to be accurate.

Quoted 6 lines

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[1] - http://buildroot.org/downloads/manual/manual.html#legal-info-list-licenses

#11 lore raw

PATCH 1/1 micropython: new package

Chris,

Quoted 6 lines · Chris Packham
Quoted 3 lines

* What happens if we have Micropython installed next to the regular Python 2 or Python 3 interpreters / standard library on the same system? Do they conflict or not?

They're installed in with different executable names and library paths so they should co-exist happily.

Good.

Quoted 4 lines
Quoted 2 lines

* What about all the Python external modules (package/python-*/) we have in Buildroot? Do they work with Micropython?

Probably depends on the module, but I assume the answer is mostly no.

Ok. Anyway, the Python external modules are installed
in /usr/lib/python<version>/, so micropython will not see them. So we're safe if someone enables both micropython, python 2 and a bunch of python external modules: python 2 will allow to use the python external modules, and micropython will live its own life without providing access to the python external modules.

Quoted 4 lines

Some of the "standard" libraries in micropython-lib are stubs to quote the readme: "micropython-lib is a highly experimental community project". Getting into buildroot is one way of helping them to move out of "experimental" status.

Sure, makes sense.

Quoted 10 lines
Quoted 5 lines

package/micropython-lib/micropython-lib.mk line 6

Quoted 3 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE

You should define MICROPYTHON_LIB_LICENSE as well.

That's an interesting problem. It's actually multiple licenses (depending on the source of the library) so nothing in the "normal"[1] list fits. I could say "various" or enumerate the ones I can identify but it would be hard to be accurate.

Isn't it a bit problematic for an open-source project to not have a clear license (or list of licenses) ? It basically means that you can't safely redistribute it.

I believe listing all the licenses is the proper course of action here. Something like:

<foo>_LICENSE = MIT (this, that), BSD-2c (foo, bar)

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#12 lore raw

PATCH v2 1/1 micropython: new package

In reply to Chris Packham

Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.

---

Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Cheers,
Chris

Changes since v1:
- Add dependency on host-pkgconf.
- Use $(TARGET_MAKE_ENV) in make invocation for micropython (micropython-lib doesn't need it because it doesn't use anything setup by it).
- Override PREFIX to install to /usr/bin instead of /usr/local/bin
- Update/add some comments.

 package/Config.in                          |  2 ++
 package/micropython-lib/Config.in          |  7 +++++++
 package/micropython-lib/micropython-lib.mk | 15 +++++++++++++++
 package/micropython/Config.in              |  8 ++++++++
 package/micropython/micropython.mk         | 27 +++++++++++++++++++++++++++
 5 files changed, 59 insertions(+)
 create mode 100644 package/micropython-lib/Config.in
 create mode 100644 package/micropython-lib/micropython-lib.mk
 create mode 100644 package/micropython/Config.in
 create mode 100644 package/micropython/micropython.mk
package/Config.in +2 -0
index fc35f12..986fe16 100644
@@ -509,6 +509,8 @@ menu "Lua libraries/modules"
 endmenu
 endif
 	source "package/lutok/Config.in"
+	source "package/micropython/Config.in"
+	source "package/micropython-lib/Config.in"
 	source "package/moarvm/Config.in"
 	source "package/mono/Config.in"
 if BR2_PACKAGE_MONO
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +15 -0
new file mode 100644
index 0000000..8eb3c1f
@@ -0,0 +1,15 @@
+################################################################################
+#
+# micropython-lib
+#
+################################################################################
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE = various
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+	$(MAKE) -C $(@D) PREFIX=$(TARGET_DIR)/usr/lib/micropython install
+endef
+
+$(eval $(generic-package))
package/micropython/Config.in new file +8 -0
new file mode 100644
index 0000000..ec47463
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_MICROPYTHON
+	bool "micropython"
+	select BR2_PACKAGE_LIBFFI
+	help
+	  Micro Python is a lean and fast implementation of the Python 3
+	  programming language that is optimised to run on a microcontroller.
+
+	  http://micropython.org
package/micropython/micropython.mk new file +27 -0
new file mode 100644
index 0000000..16dc263
@@ -0,0 +1,27 @@
+################################################################################
+#
+# micropython
+#
+################################################################################
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = host-pkgconf libffi
+
+# Use fallback implementation for exception handling on architectures that
+# don't have explicit support.
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		DESTDIR=$(TARGET_DIR) \
+		PREFIX=$(TARGET_DIR)/usr \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+		install
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.5.0
#13 lore raw

PATCH v2 1/1 micropython: new package

Dear Chris Packham, Thomas Petazzoni (license comment),

On 09/15/2015 01:01 AM, Chris Packham wrote:
[snip]

Quoted 6 lines
package/micropython-lib/micropython-lib.mk new file +0 -0
new file mode 100644
index 0000000..8eb3c1f

package/micropython-lib/micropython-lib.mk line 8

Quoted 8 lines
package/micropython-lib/micropython-lib.mk new file +8 -0
@@ -0,0 +1,15 @@
+################################################################################
+#
+# micropython-lib
+#
+################################################################################
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE = various

As Thomas suggested, improve that by listing the licenses. According to the LICENSE file, everything is MIT unless the setup.py of each module says something different, so I have done a quick check:

$ find micropython-lib-v0.5/ -type f -name "setup.py" -exec grep license
{} \; | sort -u
      license='MIT',
      license='Python',

So I think it would be enough by just having:

MICROPYTHON_LIB_LICENSE = Python (some modules), MIT (everything else)

Thomas, what do you think?

package/micropython-lib/micropython-lib.mk line 12

Quoted 4 lines
package/micropython-lib/micropython-lib.mk new file +4 -0
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+	$(MAKE) -C $(@D) PREFIX=$(TARGET_DIR)/usr/lib/micropython install

It will not harm to add $(TARGET_MAKE_ENV) before $(MAKE) here as well.

Quoted 3 lines
package/micropython-lib/micropython-lib.mk new file +3 -0
+endef
+
+$(eval $(generic-package))

[snip]

Quoted 9 lines
package/micropython/micropython.mk new file +3 -0
new file mode 100644
index 0000000..16dc263
@@ -0,0 +1,27 @@
+################################################################################
+#
+# micropython

package/micropython/micropython.mk line 13

Quoted 10 lines
package/micropython/micropython.mk new file +10 -0
+#
+################################################################################
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = host-pkgconf libffi
+
+# Use fallback implementation for exception handling on architectures that
+# don't have explicit support.

This comment, are you trying to keep the lines 80 characters long? In that case, you can put "don't" in the first line.

Regards,

Vincent.

Quoted 15 lines
package/micropython/micropython.mk new file +14 -0
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		DESTDIR=$(TARGET_DIR) \
+		PREFIX=$(TARGET_DIR)/usr \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+		install
+endef
+
+$(eval $(generic-package))
#15 lore raw

PATCH v2 1/1 micropython: new package

Quoted 6 lines · Vicente Olivert Riera

Dear Chris Packham,

by the way, can you please mark your previous patch as superseded?

http://patchwork.ozlabs.org/patch/517337/

Have done so now. I thought patchwork was smart enough to figure out a v2. I even used the --in-repy-to for that reason. I might have confused it by sending 2 v1s.

Quoted 3 lines

Regards,

Vincent.

#16 lore raw

PATCH v2 1/1 micropython: new package

In reply to Vicente Olivert Riera

Vicente, Chris,

Quoted 9 lines · Vicente Olivert Riera

As Thomas suggested, improve that by listing the licenses. According to the LICENSE file, everything is MIT unless the setup.py of each module says something different, so I have done a quick check:

$ find micropython-lib-v0.5/ -type f -name "setup.py" -exec grep license
{} \; | sort -u
      license='MIT',
      license='Python',
Quoted 5 lines

So I think it would be enough by just having:

MICROPYTHON_LIB_LICENSE = Python (some modules), MIT (everything else)

Thomas, what do you think?

I haven't checked micropython source code myself, but what you propose looks sensible, to the exception that "Python" isn't a license. The license of Python is "Python software foundation license v2".

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#17 lore raw

PATCH v2 1/1 micropython: new package

In reply to Chris Packham
Quoted 15 lines · Chris Packham

Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.

---

Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Cheers,
Chris

Quoted 8 lines

Changes since v1:
- Add dependency on host-pkgconf.
- Use $(TARGET_MAKE_ENV) in make invocation for micropython (micropython-lib doesn't need it because it doesn't use anything setup by it).
- Override PREFIX to install to /usr/bin instead of /usr/local/bin
- Update/add some comments.

<snip>

I'll send a v3 mopping up the additional comments at some point.

One issue I am facing is that the build process for micropython ties into git to generate it's version string which works when built from a clone of the micropython git repo. But when run via buildroot it ends up getting the version based on the buildroot git repo so the version number displayed is 2015.10-... instead of 1.4.5. I'll do some investigation to see if I can override the automatic logic but I was wondering if there are any other packages with similar problems and how they were addressed.

#18 lore raw

PATCH v3 1/1 micropython: new package

Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.

---
Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Cheers,
Chris

Changes since v1:
- Add dependency on host-pkgconf.
- Use $(TARGET_MAKE_ENV) in make invocation for micropython (micropython-lib doesn't need it because it doesn't use anything setup by it).
- Override PREFIX to install to /usr/bin instead of /usr/local/bin
- Update/add some comments.

Changes since v2:
- Use $(TARGET_MAKE_ENV) in micropython-lib for consistency
- Update LICENSE for micropython-lib (thanks to Vincent for the shell snippet that saved me having to check them manually).
- Add patch to take the version number from the package instead of from the buildroot git repository.

 package/Config.in                          |  2 ++
 package/micropython-lib/Config.in          |  7 +++++++
 package/micropython-lib/micropython-lib.mk | 17 +++++++++++++++++
 package/micropython/0001-fix-version.patch | 14 ++++++++++++++
 package/micropython/Config.in              |  8 ++++++++
 package/micropython/micropython.mk         | 27 +++++++++++++++++++++++++++
 6 files changed, 75 insertions(+)
 create mode 100644 package/micropython-lib/Config.in
 create mode 100644 package/micropython-lib/micropython-lib.mk
 create mode 100644 package/micropython/0001-fix-version.patch
 create mode 100644 package/micropython/Config.in
 create mode 100644 package/micropython/micropython.mk
package/Config.in +2 -0
index fc35f12..986fe16 100644
@@ -509,6 +509,8 @@ menu "Lua libraries/modules"
 endmenu
 endif
 	source "package/lutok/Config.in"
+	source "package/micropython/Config.in"
+	source "package/micropython-lib/Config.in"
 	source "package/moarvm/Config.in"
 	source "package/mono/Config.in"
 if BR2_PACKAGE_MONO
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +17 -0
new file mode 100644
index 0000000..4445306
@@ -0,0 +1,17 @@
+################################################################################
+#
+# micropython-lib
+#
+################################################################################
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE = Python software foundation license v2 (some modules), MIT (everything else)
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+		PREFIX=$(TARGET_DIR)/usr/lib/micropython \
+		install
+endef
+
+$(eval $(generic-package))
package/micropython/0001-fix-version.patch new file +14 -0
new file mode 100644
index 0000000..e2cad58
@@ -0,0 +1,14 @@
+diff -Naur micropython-v1.4.5-old/py/makeversionhdr.py micropython-v1.4.5/py/makeversionhdr.py
+--- micropython-v1.4.5-old/py/makeversionhdr.py	2015-08-12 00:42:30.000000000 +1200
++++ micropython-v1.4.5/py/makeversionhdr.py	2015-09-16 10:21:06.698962836 +1200
+@@ -70,9 +70,7 @@
+ 
+ def make_version_header(filename):
+     # Get version info using git, with fallback to docs/conf.py
+-    info = get_version_info_from_git()
+-    if info is None:
+-        info = get_version_info_from_docs_conf()
++    info = get_version_info_from_docs_conf()
+ 
+     git_tag, git_hash, ver = info
+ 
package/micropython/Config.in new file +8 -0
new file mode 100644
index 0000000..ec47463
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_MICROPYTHON
+	bool "micropython"
+	select BR2_PACKAGE_LIBFFI
+	help
+	  Micro Python is a lean and fast implementation of the Python 3
+	  programming language that is optimised to run on a microcontroller.
+
+	  http://micropython.org
package/micropython/micropython.mk new file +27 -0
new file mode 100644
index 0000000..75a517d
@@ -0,0 +1,27 @@
+################################################################################
+#
+# micropython
+#
+################################################################################
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = host-pkgconf libffi
+
+# Use fallback implementation for exception handling on architectures that don't
+# have explicit support.
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		DESTDIR=$(TARGET_DIR) \
+		PREFIX=$(TARGET_DIR)/usr \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+		install
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.5.0
#19 lore raw

PATCH v3 1/1 micropython: new package

Hi Chris,

Quoted 74 lines

Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.

---
Hi Buildroot,

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Cheers,
Chris

Changes since v1:
- Add dependency on host-pkgconf.
- Use $(TARGET_MAKE_ENV) in make invocation for micropython (micropython-lib doesn't need it because it doesn't use anything setup by it).
- Override PREFIX to install to /usr/bin instead of /usr/local/bin
- Update/add some comments.

Changes since v2:
- Use $(TARGET_MAKE_ENV) in micropython-lib for consistency
- Update LICENSE for micropython-lib (thanks to Vincent for the shell snippet that saved me having to check them manually).
- Add patch to take the version number from the package instead of from the buildroot git repository.

  package/Config.in                          |  2 ++
  package/micropython-lib/Config.in          |  7 +++++++
  package/micropython-lib/micropython-lib.mk | 17 +++++++++++++++++
  package/micropython/0001-fix-version.patch | 14 ++++++++++++++
  package/micropython/Config.in              |  8 ++++++++
  package/micropython/micropython.mk         | 27 +++++++++++++++++++++++++++
  6 files changed, 75 insertions(+)

create mode 100644 package/micropython-lib/Config.in create mode 100644 package/micropython-lib/micropython-lib.mk create mode 100644 package/micropython/0001-fix-version.patch create mode 100644 package/micropython/Config.in create mode 100644 package/micropython/micropython.mk

package/Config.in +2 -0
index fc35f12..986fe16 100644
@@ -509,6 +509,8 @@ menu "Lua libraries/modules"
  endmenu
  endif
  	source "package/lutok/Config.in"
+	source "package/micropython/Config.in"
+	source "package/micropython-lib/Config.in"
  	source "package/moarvm/Config.in"
  	source "package/mono/Config.in"
  if BR2_PACKAGE_MONO
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +0 -0
new file mode 100644
index 0000000..4445306

package/micropython-lib/micropython-lib.mk line 5

Quoted 5 lines
package/micropython-lib/micropython-lib.mk new file +5 -0
@@ -0,0 +1,17 @@
+################################################################################
+#
+# micropython-lib
+#
+################################################################################

Here and...

Quoted 52 lines
package/micropython-lib/micropython-lib.mk new file +12 -0
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE = Python software foundation license v2 (some modules), MIT (everything else)
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+		PREFIX=$(TARGET_DIR)/usr/lib/micropython \
+		install
+endef
+
+$(eval $(generic-package))
package/micropython/0001-fix-version.patch new file +14 -0
new file mode 100644
index 0000000..e2cad58
@@ -0,0 +1,14 @@
+diff -Naur micropython-v1.4.5-old/py/makeversionhdr.py micropython-v1.4.5/py/makeversionhdr.py
+--- micropython-v1.4.5-old/py/makeversionhdr.py	2015-08-12 00:42:30.000000000 +1200
++++ micropython-v1.4.5/py/makeversionhdr.py	2015-09-16 10:21:06.698962836 +1200
+@@ -70,9 +70,7 @@
+
+ def make_version_header(filename):
+     # Get version info using git, with fallback to docs/conf.py
+-    info = get_version_info_from_git()
+-    if info is None:
+-        info = get_version_info_from_docs_conf()
++    info = get_version_info_from_docs_conf()
+
+     git_tag, git_hash, ver = info
+
package/micropython/Config.in new file +8 -0
new file mode 100644
index 0000000..ec47463
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_MICROPYTHON
+	bool "micropython"
+	select BR2_PACKAGE_LIBFFI
+	help
+	  Micro Python is a lean and fast implementation of the Python 3
+	  programming language that is optimised to run on a microcontroller.
+
+	  http://micropython.org
package/micropython/micropython.mk new file +0 -0
new file mode 100644
index 0000000..75a517d

package/micropython/micropython.mk line 5

Quoted 5 lines
package/micropython/micropython.mk new file +5 -0
@@ -0,0 +1,27 @@
+################################################################################
+#
+# micropython
+#
+################################################################################

here, you should add an empty line.

Regards,
Jerzy

Quoted 22 lines
package/micropython/micropython.mk new file +22 -0
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = host-pkgconf libffi
+
+# Use fallback implementation for exception handling on architectures that don't
+# have explicit support.
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		DESTDIR=$(TARGET_DIR) \
+		PREFIX=$(TARGET_DIR)/usr \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+		install
+endef
+
+$(eval $(generic-package))
#20 lore raw

PATCH v3 1/1 micropython: new package

In reply to Chris Packham

Dear Chris Packham,

Quoted 4 lines · Chris Packham

Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.

It starts to look almost good, there are still a few things to adjust. See below.

Quoted 7 lines
 package/Config.in                          |  2 ++
 package/micropython-lib/Config.in          |  7 +++++++
 package/micropython-lib/micropython-lib.mk | 17 +++++++++++++++++
 package/micropython/0001-fix-version.patch | 14 ++++++++++++++
 package/micropython/Config.in              |  8 ++++++++
 package/micropython/micropython.mk         | 27 +++++++++++++++++++++++++++
 6 files changed, 75 insertions(+)

Could you split that up into two patches, one for micropython, and one for micropython-libs (in that order in the patch series) ?

Quoted 19 lines
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +0 -0
new file mode 100644
index 0000000..4445306

package/micropython-lib/micropython-lib.mk line 5

Quoted 5 lines
package/micropython-lib/micropython-lib.mk new file +5 -0
@@ -0,0 +1,17 @@
+################################################################################
+#
+# micropython-lib
+#
+################################################################################

One empty line here, as noted by Jerzy

package/micropython-lib/micropython-lib.mk line 13

Quoted 8 lines
package/micropython-lib/micropython-lib.mk new file +8 -0
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE = Python software foundation license v2 (some modules), MIT (everything else)
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+		PREFIX=$(TARGET_DIR)/usr/lib/micropython \

Is this really the correct value for PREFIX ? I haven't checked myself, but PREFIX=$(TARGET_DIR)/usr would look more traditional.

package/micropython/0001-fix-version.patch

Quoted 10 lines
package/micropython-lib/micropython-lib.mk new file +4 -0
+		install
+endef
+
+$(eval $(generic-package))
package/micropython/0001-fix-version.patch new file +0 -0
new file mode 100644
index 0000000..e2cad58
@@ -0,0 +1,14 @@

All patches need a description + Signed-off-by line. See
http://git.buildroot.net/buildroot/tree/package/python/100-optional-test-modules.patch
for example.

Quoted 20 lines
package/micropython/0001-fix-version.patch new file +14 -0
+diff -Naur micropython-v1.4.5-old/py/makeversionhdr.py micropython-v1.4.5/py/makeversionhdr.py
+--- micropython-v1.4.5-old/py/makeversionhdr.py	2015-08-12 00:42:30.000000000 +1200
++++ micropython-v1.4.5/py/makeversionhdr.py	2015-09-16 10:21:06.698962836 +1200
+@@ -70,9 +70,7 @@
+ 
+ def make_version_header(filename):
+     # Get version info using git, with fallback to docs/conf.py
+-    info = get_version_info_from_git()
+-    if info is None:
+-        info = get_version_info_from_docs_conf()
++    info = get_version_info_from_docs_conf()
+ 
+     git_tag, git_hash, ver = info
+ 
package/micropython/Config.in new file +0 -0
new file mode 100644
index 0000000..ec47463

package/micropython/Config.in line 3

Quoted 3 lines
package/micropython/Config.in new file +3 -0
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_MICROPYTHON
+	bool "micropython"
+	select BR2_PACKAGE_LIBFFI

If you select libffi, then you need to replicate the dependencies of libffi, so:

depends on BR2_TOOLCHAIN_HAS_THREADS

package/micropython/Config.in line 8

Quoted 5 lines
package/micropython/Config.in new file +5 -0
+	help
+	  Micro Python is a lean and fast implementation of the Python 3
+	  programming language that is optimised to run on a microcontroller.
+
+	  http://micropython.org

And:

comment "micropython needs a toolchain w/ thread"
depends on !BR2_TOOLCHAIN_HAS_THREADS

package/micropython/micropython.mk line 5

Quoted 11 lines
package/micropython/micropython.mk new file +5 -0
new file mode 100644
index 0000000..75a517d
@@ -0,0 +1,27 @@
+################################################################################
+#
+# micropython
+#
+################################################################################

Need an empty line here.

Quoted 10 lines
package/micropython/micropython.mk new file +10 -0
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = host-pkgconf libffi
+
+# Use fallback implementation for exception handling on architectures that don't
+# have explicit support.
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1

package/micropython/micropython.mk line 25

Quoted 10 lines
package/micropython/micropython.mk new file +10 -0
+endif
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		DESTDIR=$(TARGET_DIR) \
+		PREFIX=$(TARGET_DIR)/usr \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+		install
+endef

It seems like this is going to do the build and installation in the <pkg>_INSTALL_TARGET_CMDS, which isn't nice. I've done a quick test, and the following seems to work:

define MICROPYTHON_BUILD_CMDS

        $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
                CROSS_COMPILE=$(TARGET_CROSS) \
                CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS)

endef

define MICROPYTHON_INSTALL_TARGET_CMDS

        $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
                DESTDIR=$(TARGET_DIR) \
                PREFIX=$(TARGET_DIR)/usr \
                install

endef

Which is much more in line with Buildroot standards.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#21 lore raw

PATCH v3 1/1 micropython: new package

Hi Thomas,

Quoted 19 lines · Thomas Petazzoni

Dear Chris Packham,

Quoted 4 lines · Chris Packham

Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.

It starts to look almost good, there are still a few things to adjust. See below.

Quoted 7 lines
 package/Config.in                          |  2 ++
 package/micropython-lib/Config.in          |  7 +++++++
 package/micropython-lib/micropython-lib.mk | 17 +++++++++++++++++
 package/micropython/0001-fix-version.patch | 14 ++++++++++++++
 package/micropython/Config.in              |  8 ++++++++
 package/micropython/micropython.mk         | 27 +++++++++++++++++++++++++++
 6 files changed, 75 insertions(+)
Quoted 2 lines

Could you split that up into two patches, one for micropython, and one for micropython-libs (in that order in the patch series) ?

Will do.

Quoted 18 lines
Quoted 18 lines
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+     bool "micropython-lib"
+     depends on BR2_PACKAGE_MICROPYTHON
+     help
+       Core Python libraries ported to MicroPython.
+
+       http://micropython.org
package/micropython-lib/micropython-lib.mk new file +0 -0
new file mode 100644
index 0000000..4445306
Quoted 9 lines

package/micropython-lib/micropython-lib.mk line 5

Quoted 6 lines
package/micropython-lib/micropython-lib.mk new file +5 -0
@@ -0,0 +1,17 @@
+################################################################################
+#
+# micropython-lib
+#
+################################################################################

One empty line here, as noted by Jerzy

Done.

Quoted 11 lines

package/micropython-lib/micropython-lib.mk line 13

Quoted 8 lines
package/micropython-lib/micropython-lib.mk new file +8 -0
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE = Python software foundation license v2 (some modules), MIT (everything else)
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+     $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+             PREFIX=$(TARGET_DIR)/usr/lib/micropython \

Is this really the correct value for PREFIX ? I haven't checked myself, but PREFIX=$(TARGET_DIR)/usr would look more traditional.

Yes it's correct for the way the micropython-lib Makefile[1] is written.

Quoted 15 lines

package/micropython/0001-fix-version.patch

Quoted 11 lines
package/micropython-lib/micropython-lib.mk new file +4 -0
+             install
+endef
+
+$(eval $(generic-package))
package/micropython/0001-fix-version.patch new file +0 -0
new file mode 100644
index 0000000..e2cad58
@@ -0,0 +1,14 @@

All patches need a description + Signed-off-by line. See
http://git.buildroot.net/buildroot/tree/package/python/100-optional-test-modules.patch
for example.

Done

Quoted 27 lines
Quoted 20 lines
package/micropython/0001-fix-version.patch new file +14 -0
+diff -Naur micropython-v1.4.5-old/py/makeversionhdr.py micropython-v1.4.5/py/makeversionhdr.py
+--- micropython-v1.4.5-old/py/makeversionhdr.py      2015-08-12 00:42:30.000000000 +1200
++++ micropython-v1.4.5/py/makeversionhdr.py  2015-09-16 10:21:06.698962836 +1200
+@@ -70,9 +70,7 @@
+
+ def make_version_header(filename):
+     # Get version info using git, with fallback to docs/conf.py
+-    info = get_version_info_from_git()
+-    if info is None:
+-        info = get_version_info_from_docs_conf()
++    info = get_version_info_from_docs_conf()
+
+     git_tag, git_hash, ver = info
+
package/micropython/Config.in new file +0 -0
new file mode 100644
index 0000000..ec47463

package/micropython/Config.in line 3

Quoted 3 lines
package/micropython/Config.in new file +3 -0
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_MICROPYTHON
+     bool "micropython"
+     select BR2_PACKAGE_LIBFFI

If you select libffi, then you need to replicate the dependencies of libffi, so:

Quoted 2 lines

depends on BR2_TOOLCHAIN_HAS_THREADS

Done

Quoted 11 lines

package/micropython/Config.in line 8

Quoted 5 lines
package/micropython/Config.in new file +5 -0
+     help
+       Micro Python is a lean and fast implementation of the Python 3
+       programming language that is optimised to run on a microcontroller.
+
+       http://micropython.org

And:

comment "micropython needs a toolchain w/ thread"
depends on !BR2_TOOLCHAIN_HAS_THREADS

Done

Quoted 5 lines
Quoted 5 lines
package/micropython/micropython.mk new file +0 -0
new file mode 100644
index 0000000..75a517d
Quoted 9 lines

package/micropython/micropython.mk line 5

Quoted 6 lines
package/micropython/micropython.mk new file +5 -0
@@ -0,0 +1,27 @@
+################################################################################
+#
+# micropython
+#
+################################################################################

Need an empty line here.

Done

Quoted 31 lines
Quoted 10 lines
package/micropython/micropython.mk new file +10 -0
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = host-pkgconf libffi
+
+# Use fallback implementation for exception handling on architectures that don't
+# have explicit support.
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1

package/micropython/micropython.mk line 25

Quoted 10 lines
package/micropython/micropython.mk new file +10 -0
+endif
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+     $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+             CROSS_COMPILE=$(TARGET_CROSS) \
+             DESTDIR=$(TARGET_DIR) \
+             PREFIX=$(TARGET_DIR)/usr \
+             CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
+             install
+endef

It seems like this is going to do the build and installation in the <pkg>_INSTALL_TARGET_CMDS, which isn't nice. I've done a quick test, and the following seems to work:

define MICROPYTHON_BUILD_CMDS

        $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
                CROSS_COMPILE=$(TARGET_CROSS) \
                CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS)

endef

Quoted 9 lines

define MICROPYTHON_INSTALL_TARGET_CMDS

        $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
                DESTDIR=$(TARGET_DIR) \
                PREFIX=$(TARGET_DIR)/usr \
                install

endef

Which is much more in line with Buildroot standards.

Done.

Quoted 7 lines

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[1] - https://github.com/micropython/micropython-lib/blob/master/Makefile#L8

#22 lore raw

v4 cover Micropython package

Thought you might be interested in mircopython a minimal python 3 implementation. It's designed for micro controllers but is also well suited to other general purpose embedded CPUs.

Cheers,
Chris

Changes since v1:
- Add dependency on host-pkgconf.
- Use $(TARGET_MAKE_ENV) in make invocation for micropython (micropython-lib doesn't need it because it doesn't use anything setup by it).
- Override PREFIX to install to /usr/bin instead of /usr/local/bin
- Update/add some comments.

Changes since v2:
- Use $(TARGET_MAKE_ENV) in micropython-lib for consistency
- Update LICENSE for micropython-lib (thanks to Vincent for the shell snippet that saved me having to check them manually).
- Add patch to take the version number from the package instead of from the buildroot git repository.

Changes since v3:
- Split into 2 patches
- Separate build and install steps for micropython
- Minor style fixes

Chris Packham (2):
micropython: new package
micropython-lib: new packages

 package/Config.in                          |  2 ++
 package/micropython-lib/Config.in          |  7 +++++++
 package/micropython-lib/micropython-lib.mk | 18 +++++++++++++++++
 package/micropython/0001-fix-version.patch | 22 ++++++++++++++++++++
 package/micropython/Config.in              | 12 +++++++++++
 package/micropython/micropython.mk         | 32 ++++++++++++++++++++++++++++++
 6 files changed, 93 insertions(+)
 create mode 100644 package/micropython-lib/Config.in
 create mode 100644 package/micropython-lib/micropython-lib.mk
 create mode 100644 package/micropython/0001-fix-version.patch
 create mode 100644 package/micropython/Config.in
 create mode 100644 package/micropython/micropython.mk
Signature · 1 line
2.5.0
#23 lore raw

PATCH v4 1/2 micropython: new package

Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.

---
 package/Config.in                          |  1 +
 package/micropython/0001-fix-version.patch | 22 ++++++++++++++++++++
 package/micropython/Config.in              | 12 +++++++++++
 package/micropython/micropython.mk         | 32 ++++++++++++++++++++++++++++++
 4 files changed, 67 insertions(+)
 create mode 100644 package/micropython/0001-fix-version.patch
 create mode 100644 package/micropython/Config.in
 create mode 100644 package/micropython/micropython.mk
package/Config.in +1 -0
index fc35f12..94ac406 100644
@@ -509,6 +509,7 @@ menu "Lua libraries/modules"
 endmenu
 endif
 	source "package/lutok/Config.in"
+	source "package/micropython/Config.in"
 	source "package/moarvm/Config.in"
 	source "package/mono/Config.in"
 if BR2_PACKAGE_MONO
package/micropython/0001-fix-version.patch new file +22 -0
new file mode 100644
index 0000000..1bf2992
@@ -0,0 +1,22 @@
+Always use the fallback behaviour for determining the version number
+
+When built from within buildroot the micropython build process detects
+that it is inside a git repository and ends up using the buildroot
+version number instead of the correct micropython version number.
+
+Signed-off-by: Chris Packham <[email protected]>
+---
+diff -Naur micropython-v1.4.5-old/py/makeversionhdr.py micropython-v1.4.5/py/makeversionhdr.py
+--- micropython-v1.4.5-old/py/makeversionhdr.py	2015-08-12 00:42:30.000000000 +1200
++++ micropython-v1.4.5/py/makeversionhdr.py	2015-09-16 10:21:06.698962836 +1200
+@@ -70,9 +70,7 @@
+ 
+ def make_version_header(filename):
+     # Get version info using git, with fallback to docs/conf.py
+-    info = get_version_info_from_git()
+-    if info is None:
+-        info = get_version_info_from_docs_conf()
++    info = get_version_info_from_docs_conf()
+ 
+     git_tag, git_hash, ver = info
+ 
package/micropython/Config.in new file +12 -0
new file mode 100644
index 0000000..3ad38d6
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_MICROPYTHON
+	bool "micropython"
+	select BR2_PACKAGE_LIBFFI
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	help
+	  Micro Python is a lean and fast implementation of the Python 3
+	  programming language that is optimised to run on a microcontroller.
+
+	  http://micropython.org
+
+comment "micropython needs a toolchain w/ thread"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS
package/micropython/micropython.mk new file +32 -0
new file mode 100644
index 0000000..2d7c924
@@ -0,0 +1,32 @@
+################################################################################
+#
+# micropython
+#
+################################################################################
+
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = host-pkgconf libffi
+
+# Use fallback implementation for exception handling on architectures that don't
+# have explicit support.
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif
+
+define MICROPYTHON_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS)
+endef
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+		DESTDIR=$(TARGET_DIR) \
+		PREFIX=$(TARGET_DIR)/usr \
+		install
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.5.0
#24 lore raw

PATCH v4 1/2 micropython: new package

Dear Chris Packham,

Quoted 4 lines · Chris Packham

Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.

Build test for MIPS architecture:

$ file output/target/usr/bin/micropython
output/target/usr/bin/micropython: ELF 32-bit MSB executable, MIPS,
MIPS32 rel2 version 1 (SYSV), dynamically linked (uses shared libs), for
GNU/Linux 2.6.32, with unknown capability 0x41000000 = 0xf676e75, with
unknown capability 0x10000 = 0x70403, stripped

One more comment below. Please scroll down.

Quoted 57 lines
---
 package/Config.in                          |  1 +
 package/micropython/0001-fix-version.patch | 22 ++++++++++++++++++++
 package/micropython/Config.in              | 12 +++++++++++
 package/micropython/micropython.mk         | 32 ++++++++++++++++++++++++++++++
 4 files changed, 67 insertions(+)
 create mode 100644 package/micropython/0001-fix-version.patch
 create mode 100644 package/micropython/Config.in
 create mode 100644 package/micropython/micropython.mk
package/Config.in +1 -0
index fc35f12..94ac406 100644
@@ -509,6 +509,7 @@ menu "Lua libraries/modules"
 endmenu
 endif
 	source "package/lutok/Config.in"
+	source "package/micropython/Config.in"
 	source "package/moarvm/Config.in"
 	source "package/mono/Config.in"
 if BR2_PACKAGE_MONO
package/micropython/0001-fix-version.patch new file +22 -0
new file mode 100644
index 0000000..1bf2992
@@ -0,0 +1,22 @@
+Always use the fallback behaviour for determining the version number
+
+When built from within buildroot the micropython build process detects
+that it is inside a git repository and ends up using the buildroot
+version number instead of the correct micropython version number.
+
+Signed-off-by: Chris Packham <[email protected]>
+---
+diff -Naur micropython-v1.4.5-old/py/makeversionhdr.py micropython-v1.4.5/py/makeversionhdr.py
+--- micropython-v1.4.5-old/py/makeversionhdr.py	2015-08-12 00:42:30.000000000 +1200
++++ micropython-v1.4.5/py/makeversionhdr.py	2015-09-16 10:21:06.698962836 +1200
+@@ -70,9 +70,7 @@
+ 
+ def make_version_header(filename):
+     # Get version info using git, with fallback to docs/conf.py
+-    info = get_version_info_from_git()
+-    if info is None:
+-        info = get_version_info_from_docs_conf()
++    info = get_version_info_from_docs_conf()
+ 
+     git_tag, git_hash, ver = info
+ 
package/micropython/Config.in new file +1 -0
new file mode 100644
index 0000000..3ad38d6
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_MICROPYTHON

package/micropython/Config.in line 11

Quoted 10 lines
package/micropython/Config.in new file +10 -0
+	bool "micropython"
+	select BR2_PACKAGE_LIBFFI
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	help
+	  Micro Python is a lean and fast implementation of the Python 3
+	  programming language that is optimised to run on a microcontroller.
+
+	  http://micropython.org
+
+comment "micropython needs a toolchain w/ thread"

threads (in plural)

This is something the maintainer can amend for you, I guess, so you don't need to send another patch.

Regards,

Vincent.

Quoted 40 lines
package/micropython/Config.in new file +1 -0
+	depends on !BR2_TOOLCHAIN_HAS_THREADS
package/micropython/micropython.mk new file +32 -0
new file mode 100644
index 0000000..2d7c924
@@ -0,0 +1,32 @@
+################################################################################
+#
+# micropython
+#
+################################################################################
+
+MICROPYTHON_VERSION = v1.4.5
+MICROPYTHON_SITE = $(call github,micropython,micropython,$(MICROPYTHON_VERSION))
+MICROPYTHON_LICENSE = MIT
+MICROPYTHON_LICENSE_FILES = LICENSE
+MICROPYTHON_DEPENDENCIES = host-pkgconf libffi
+
+# Use fallback implementation for exception handling on architectures that don't
+# have explicit support.
+ifeq ($(BR2_powerpc),y)
+MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
+endif
+
+define MICROPYTHON_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+		CROSS_COMPILE=$(TARGET_CROSS) \
+		CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS)
+endef
+
+define MICROPYTHON_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
+		DESTDIR=$(TARGET_DIR) \
+		PREFIX=$(TARGET_DIR)/usr \
+		install
+endef
+
+$(eval $(generic-package))
#25 lore raw

PATCH v4 1/2 micropython: new package

Quoted 3 lines · Vicente Olivert Riera

Dear Chris Packham,

On 09/17/2015 12:29 AM, Chris Packham wrote:

<snip>

Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+comment "micropython needs a toolchain w/ thread"

threads (in plural)

This is something the maintainer can amend for you, I guess, so you don't need to send another patch.

D'oh I was doing that in a hurry yesterday. I see Thomas has committed it with a fix thanks to both for noticing/fixing.

#26 lore raw

PATCH v4 2/2 micropython-lib: new packages

In reply to Chris Packham

Core Python libraries ported to MicroPython.

---
 package/Config.in                          |  1 +
 package/micropython-lib/Config.in          |  7 +++++++
 package/micropython-lib/micropython-lib.mk | 18 ++++++++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 package/micropython-lib/Config.in
 create mode 100644 package/micropython-lib/micropython-lib.mk
package/Config.in +1 -0
index 94ac406..986fe16 100644
@@ -510,6 +510,7 @@ endmenu
 endif
 	source "package/lutok/Config.in"
 	source "package/micropython/Config.in"
+	source "package/micropython-lib/Config.in"
 	source "package/moarvm/Config.in"
 	source "package/mono/Config.in"
 if BR2_PACKAGE_MONO
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +18 -0
new file mode 100644
index 0000000..a4a6cf6
@@ -0,0 +1,18 @@
+################################################################################
+#
+# micropython-lib
+#
+################################################################################
+
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE = Python software foundation license v2 (some modules), MIT (everything else)
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+		PREFIX=$(TARGET_DIR)/usr/lib/micropython \
+		install
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.5.0
#27 lore raw

PATCH v4 2/2 micropython-lib: new packages

Dear Chris Packham,

Quoted 3 lines · Chris Packham

Core Python libraries ported to MicroPython.

Build test for MIPS architecture:

$ find output/target/usr/lib/micropython/ | wc -l
191

There are no binary files to check if it was build for the right architecture.

Regards,

Vincent.

Quoted 58 lines
---
 package/Config.in                          |  1 +
 package/micropython-lib/Config.in          |  7 +++++++
 package/micropython-lib/micropython-lib.mk | 18 ++++++++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 package/micropython-lib/Config.in
 create mode 100644 package/micropython-lib/micropython-lib.mk
package/Config.in +1 -0
index 94ac406..986fe16 100644
@@ -510,6 +510,7 @@ endmenu
 endif
 	source "package/lutok/Config.in"
 	source "package/micropython/Config.in"
+	source "package/micropython-lib/Config.in"
 	source "package/moarvm/Config.in"
 	source "package/mono/Config.in"
 if BR2_PACKAGE_MONO
package/micropython-lib/Config.in new file +7 -0
new file mode 100644
index 0000000..a7e017b
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_MICROPYTHON_LIB
+	bool "micropython-lib"
+	depends on BR2_PACKAGE_MICROPYTHON
+	help
+	  Core Python libraries ported to MicroPython.
+
+	  http://micropython.org
package/micropython-lib/micropython-lib.mk new file +18 -0
new file mode 100644
index 0000000..a4a6cf6
@@ -0,0 +1,18 @@
+################################################################################
+#
+# micropython-lib
+#
+################################################################################
+
+MICROPYTHON_LIB_VERSION = v0.5
+MICROPYTHON_LIB_SITE = $(call github,micropython,micropython-lib,$(MICROPYTHON_LIB_VERSION))
+MICROPYTHON_LIB_LICENSE = Python software foundation license v2 (some modules), MIT (everything else)
+MICROPYTHON_LIB_LICENSE_FILES = LICENSE
+
+define MICROPYTHON_LIB_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+		PREFIX=$(TARGET_DIR)/usr/lib/micropython \
+		install
+endef
+
+$(eval $(generic-package))
#28 lore raw

v4 cover Micropython package

In reply to Chris Packham

Dear Chris Packham,

Quoted 3 lines · Chris Packham

Chris Packham (2):
micropython: new package
micropython-lib: new packages

Both applied, thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#29 lore raw

v4 cover Micropython package

In reply to Chris Packham

Chris,

Quoted 3 lines · Chris Packham

Chris Packham (2):
micropython: new package
micropython-lib: new packages

There are a number of build failures caused by Micropython in the autobuilders:

* On MIPS64
http://autobuild.buildroot.org/results/99a/99a610c72877fef53d93e1a923bd5c71b3376618/build-end.log

* On Xtensa
http://autobuild.buildroot.org/results/670/670907760d6b3e7eb46b433647b392cec3bafdcd/build-end.log

* On SH4A
http://autobuild.buildroot.org/results/f5a/f5a2c563b8bdab9e345960a5b92d31f3f92dba00/build-end.log

See http://autobuild.buildroot.org/?reason=micropython-v1.4.5 for the complete list of build failures.

If you could look into these, it would be helpful.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#30 lore raw

v4 cover Micropython package

Quoted 17 lines · Thomas Petazzoni

Chris,

Quoted 3 lines · Chris Packham

Chris Packham (2):
micropython: new package
micropython-lib: new packages

There are a number of build failures caused by Micropython in the autobuilders:

* On MIPS64
http://autobuild.buildroot.org/results/99a/99a610c72877fef53d93e1a923bd5c71b3376618/build-end.log

* On Xtensa
http://autobuild.buildroot.org/results/670/670907760d6b3e7eb46b433647b392cec3bafdcd/build-end.log

Quoted 7 lines

* On SH4A
http://autobuild.buildroot.org/results/f5a/f5a2c563b8bdab9e345960a5b92d31f3f92dba00/build-end.log

See http://autobuild.buildroot.org/?reason=micropython-v1.4.5 for the complete list of build failures.

If you could look into these, it would be helpful.

Xtensa and SH4A look like they need MICROPY_GCREGS_SETJMP I'll send a patch for them shortly. The MIPS64 one looks different so might need some investigation.

Quoted 8 lines

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

#31 lore raw

PATCH 1/1 micropython: Set MICROPY_GCREGS_SETJMP=1 for xtensa and sh

These architectures don't have explicit exception handling support in micropython but can use the setjmp fallback behaviour instead.

---
 package/micropython/micropython.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/micropython/micropython.mk +1 -1
index 2d7c924..6266882 100644
@@ -12,7 +12,7 @@ MICROPYTHON_DEPENDENCIES = host-pkgconf libffi
 
 # Use fallback implementation for exception handling on architectures that don't
 # have explicit support.
-ifeq ($(BR2_powerpc),y)
+ifeq ($(BR2_powerpc)$(BR2_sh)$(BR2_xtensa),y)
 MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
 endif
 
Signature · 1 line
2.5.0
#32 lore raw

PATCH 1/1 micropython: Set MICROPY_GCREGS_SETJMP=1 for xtensa and sh

Dear Chris Packham,

Quoted 7 lines · Chris Packham

These architectures don't have explicit exception handling support in micropython but can use the setjmp fallback behaviour instead.

---
 package/micropython/micropython.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#33 lore raw

v4 cover Micropython package

In reply to Chris Packham

Dear Chris Packham,

Quoted 22 lines · Chris Packham
Quoted 20 lines · Thomas Petazzoni

Chris,

Quoted 3 lines · Chris Packham

Chris Packham (2):
micropython: new package
micropython-lib: new packages

There are a number of build failures caused by Micropython in the autobuilders:

* On MIPS64
http://autobuild.buildroot.org/results/99a/99a610c72877fef53d93e1a923bd5c71b3376618/build-end.log

* On Xtensa
http://autobuild.buildroot.org/results/670/670907760d6b3e7eb46b433647b392cec3bafdcd/build-end.log

* On SH4A
http://autobuild.buildroot.org/results/f5a/f5a2c563b8bdab9e345960a5b92d31f3f92dba00/build-end.log

Quoted 8 lines
Quoted 4 lines

See http://autobuild.buildroot.org/?reason=micropython-v1.4.5 for the complete list of build failures.

If you could look into these, it would be helpful.

Xtensa and SH4A look like they need MICROPY_GCREGS_SETJMP I'll send a patch for them shortly. The MIPS64 one looks different so might need some investigation.

as the build error says, a right shift is being performed in the py/objint_mpz.c file, and the offending one is at line #54:

MP_SSIZE_MAX >> MPZ_DIG_SIZE * 4

in MIPS64 n64 the MP_SSIZE_MAX is 64-bit wide and the value of MPZ_DIG_SIZE 16, so MPZ_DIG_SIZE * 4 is 64. That shift causes a warning because its trying to shift 64 bits of a 64-bit variable:

py/objint_mpz.c:54:5: error: right shift count >= width of type [-Werror]

MIPS32 and MIPS64 n32 are fine because MP_SSIZE_MAX is 32-bit wide and the #if clauses in the py/objint_mpz.c protect that to happen.

Look at this test for MIPS32:

$ mips-linux-gnu-gcc -mips32r2 -EB ssize_t.c -o ssize_t
$ qemu-mips ssize_t
MP_SSIZE_MAX: 32 bits
MPZ_DIG_SIZE: 16
right-shifting 0 bits
right-shifting 16 bits

And now look at the same test for MIPS64 n64:

$ mips-linux-gnu-gcc -mips64r2 -mabi=64 -EB ssize_t.c -o ssize_t
ssize_t.c: In function 'main':
ssize_t.c:24:2: warning: right shift count >= width of type
  (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 4) & DIG_MASK;
  ^
$ qemu-mips64 ssize_t
MP_SSIZE_MAX: 64 bits
MPZ_DIG_SIZE: 16
right-shifting 0 bits
right-shifting 16 bits
right-shifting 32 bits
right-shifting 48 bits
right-shifting 64 bits

I don't know what's the purpose of the code in py/objint_mpz.c and I don't know if they really want to do a 64-bit shift of a 64-bit variable. But the thing is that since it's compiled with the -Werror flag, that warning makes the compilation to fail.

If they really want to do such a shift, then they should remove the -Werror. But if they don't want to do such a shift, then more #if clauses are needed in order to prevent that to happen. Perhaps you could talk with upstream about this.

Regards,

Vincent.

Quoted 14 lines
Quoted 9 lines

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#34 lore raw

v4 cover Micropython package

Quoted 78 lines · Vicente Olivert Riera

Dear Chris Packham,

Quoted 22 lines · Chris Packham
Quoted 20 lines · Thomas Petazzoni

Chris,

Quoted 3 lines · Chris Packham

Chris Packham (2):
micropython: new package
micropython-lib: new packages

There are a number of build failures caused by Micropython in the autobuilders:

* On MIPS64
http://autobuild.buildroot.org/results/99a/99a610c72877fef53d93e1a923bd5c71b3376618/build-end.log

* On Xtensa
http://autobuild.buildroot.org/results/670/670907760d6b3e7eb46b433647b392cec3bafdcd/build-end.log

* On SH4A
http://autobuild.buildroot.org/results/f5a/f5a2c563b8bdab9e345960a5b92d31f3f92dba00/build-end.log

Quoted 8 lines
Quoted 4 lines

See http://autobuild.buildroot.org/?reason=micropython-v1.4.5 for the complete list of build failures.

If you could look into these, it would be helpful.

Xtensa and SH4A look like they need MICROPY_GCREGS_SETJMP I'll send a patch for them shortly. The MIPS64 one looks different so might need some investigation.

as the build error says, a right shift is being performed in the py/objint_mpz.c file, and the offending one is at line #54:

MP_SSIZE_MAX >> MPZ_DIG_SIZE * 4

in MIPS64 n64 the MP_SSIZE_MAX is 64-bit wide and the value of MPZ_DIG_SIZE 16, so MPZ_DIG_SIZE * 4 is 64. That shift causes a warning because its trying to shift 64 bits of a 64-bit variable:

py/objint_mpz.c:54:5: error: right shift count >= width of type [-Werror]

MIPS32 and MIPS64 n32 are fine because MP_SSIZE_MAX is 32-bit wide and the #if clauses in the py/objint_mpz.c protect that to happen.

Look at this test for MIPS32:

$ mips-linux-gnu-gcc -mips32r2 -EB ssize_t.c -o ssize_t
$ qemu-mips ssize_t
MP_SSIZE_MAX: 32 bits
MPZ_DIG_SIZE: 16
right-shifting 0 bits
right-shifting 16 bits

And now look at the same test for MIPS64 n64:

$ mips-linux-gnu-gcc -mips64r2 -mabi=64 -EB ssize_t.c -o ssize_t
ssize_t.c: In function 'main':
ssize_t.c:24:2: warning: right shift count >= width of type
  (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 4) & DIG_MASK;
  ^
$ qemu-mips64 ssize_t
MP_SSIZE_MAX: 64 bits
MPZ_DIG_SIZE: 16
right-shifting 0 bits
right-shifting 16 bits
right-shifting 32 bits
right-shifting 48 bits
right-shifting 64 bits

I don't know what's the purpose of the code in py/objint_mpz.c and I don't know if they really want to do a 64-bit shift of a 64-bit variable. But the thing is that since it's compiled with the -Werror flag, that warning makes the compilation to fail.

Quoted 5 lines

If they really want to do such a shift, then they should remove the -Werror. But if they don't want to do such a shift, then more #if clauses are needed in order to prevent that to happen. Perhaps you could talk with upstream about this.

I raised an issue [1]. But in the meantime I think I've found the right setting to pass for a 64 bit target. Patch to follow.

[1] - https://github.com/micropython/micropython/issues/1465

#35 lore raw

PATCH 1/1 micropython: Set MPZ_DIG_SIZE=32 for 64 bit targets

From the micropython source:

This mpz module implements arbitrary precision integers.

The storage for each digit is defined by mpz_dig_t. The actual number of bits in mpz_dig_t that are used is defined by MPZ_DIG_SIZE. The machine must also provide a type that is twice as wide as mpz_dig_t, in both signed and unsigned versions

MPZ_DIG_SIZE can be between 4 and 8*sizeof(mpz_dig_t), but it makes most sense to have it as large as possible.

Micropython detects x86_64 targets and sets MPZ_DIG_SIZE appropriately but for other 64-bit targets we need to explicitly pass -DMPZ_DIG_SIZE=32 in CFLAGS.

---
 package/micropython/micropython.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/micropython/micropython.mk +4 -0
index 6266882..1ac2e8d 100644
@@ -16,6 +16,10 @@ ifeq ($(BR2_powerpc)$(BR2_sh)$(BR2_xtensa),y)
 MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
 endif
 
+ifeq ($(BR2_ARCH_IS_64),y)
+MICROPYTHON_CFLAGS += -DMPZ_DIG_SIZE=32
+endif
+
 define MICROPYTHON_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
 		CROSS_COMPILE=$(TARGET_CROSS) \
Signature · 1 line
2.5.0
#36 lore raw

PATCH 1/1 micropython: Set MPZ_DIG_SIZE=32 for 64 bit targets

Dear Chris Packham,

Quoted 26 lines · Chris Packham

From the micropython source:

This mpz module implements arbitrary precision integers.

The storage for each digit is defined by mpz_dig_t. The actual number of bits in mpz_dig_t that are used is defined by MPZ_DIG_SIZE. The machine must also provide a type that is twice as wide as mpz_dig_t, in both signed and unsigned versions

MPZ_DIG_SIZE can be between 4 and 8*sizeof(mpz_dig_t), but it makes most sense to have it as large as possible.

Micropython detects x86_64 targets and sets MPZ_DIG_SIZE appropriately but for other 64-bit targets we need to explicitly pass -DMPZ_DIG_SIZE=32 in CFLAGS.

---
 package/micropython/micropython.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/micropython/micropython.mk +0 -0
index 6266882..1ac2e8d 100644

package/micropython/micropython.mk ifeq ($(BR2_powerpc)$(BR2_sh)$(BR2_xtensa),y) · line 22

Quoted 7 lines
package/micropython/micropython.mk +4 -0
@@ -16,6 +16,10 @@ ifeq ($(BR2_powerpc)$(BR2_sh)$(BR2_xtensa),y)
 MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
 endif
 
+ifeq ($(BR2_ARCH_IS_64),y)
+MICROPYTHON_CFLAGS += -DMPZ_DIG_SIZE=32
+endif
+

you have to take into account that MIPS64 n32 is a 64-bit target as well, but it has a MP_SSIZE_MAX of 32-bit. So, if you set MPZ_DIG_SIZE to 32 for all 64-bit arches, then you will see the same failure for the when building for MIPS64 n32.

I suggest you to do modify the "ifeq" like this:

# MIPS64 n32 is a 64-bit arch, but it has a 32-bit wide SSIZE_MAX which

# means we still need the default MPZ_DIG_SIZE of 16.
ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)

Regards,

Vincent.

Quoted 4 lines
package/micropython/micropython.mk +0 -0
 define MICROPYTHON_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/unix \
 		CROSS_COMPILE=$(TARGET_CROSS) \
#37 lore raw

PATCH 1/1 micropython: Set MPZ_DIG_SIZE=32 for 64 bit targets

Hi Vincent,

Quoted 42 lines · Vicente Olivert Riera

Dear Chris Packham,

Quoted 26 lines · Chris Packham

From the micropython source:

This mpz module implements arbitrary precision integers.

The storage for each digit is defined by mpz_dig_t. The actual number of bits in mpz_dig_t that are used is defined by MPZ_DIG_SIZE. The machine must also provide a type that is twice as wide as mpz_dig_t, in both signed and unsigned versions

MPZ_DIG_SIZE can be between 4 and 8*sizeof(mpz_dig_t), but it makes most sense to have it as large as possible.

Micropython detects x86_64 targets and sets MPZ_DIG_SIZE appropriately but for other 64-bit targets we need to explicitly pass -DMPZ_DIG_SIZE=32 in CFLAGS.

---
 package/micropython/micropython.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/micropython/micropython.mk +0 -0
index 6266882..1ac2e8d 100644

package/micropython/micropython.mk ifeq ($(BR2_powerpc)$(BR2_sh)$(BR2_xtensa),y) · line 22

Quoted 7 lines
package/micropython/micropython.mk +4 -0
@@ -16,6 +16,10 @@ ifeq ($(BR2_powerpc)$(BR2_sh)$(BR2_xtensa),y)
 MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
 endif
 
+ifeq ($(BR2_ARCH_IS_64),y)
+MICROPYTHON_CFLAGS += -DMPZ_DIG_SIZE=32
+endif
+

you have to take into account that MIPS64 n32 is a 64-bit target as well, but it has a MP_SSIZE_MAX of 32-bit. So, if you set MPZ_DIG_SIZE to 32 for all 64-bit arches, then you will see the same failure for the when building for MIPS64 n32.

Quoted 6 lines

I suggest you to do modify the "ifeq" like this:

# MIPS64 n32 is a 64-bit arch, but it has a 32-bit wide SSIZE_MAX which

# means we still need the default MPZ_DIG_SIZE of 16.
ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)

I'll take a look. The remote machine I was doing my buildroot hacking on has gone AWOL so it may take a while for me to get it back up and running (there was a planned server outage so I suspect it's trying to access some non-existent mounts).

When I asked upstream there was a thought that this commit[1] might fix the issue. So I'll try adding that as a patch first.

--
[1] - https://github.com/micropython/micropython/commit/8b4fb4fe140e9cf57fcfa258d0d2d6fe19090fc5