diff mbox

[PATCHv2] micropython: new package

Message ID 1442275305-10690-1-git-send-email-judge.packham@gmail.com
State Superseded
Headers show

Commit Message

Chris Packham Sept. 15, 2015, 12:01 a.m. UTC
Micro Python is a lean and fast implementation of the Python 3
programming language that is optimised to run on a microcontroller.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---

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

Comments

Vicente Olivert Riera Sept. 15, 2015, 10:14 a.m. UTC | #1
Dear Chris Packham, Thomas Petazzoni (license comment),

On 09/15/2015 01:01 AM, Chris Packham wrote:
[snip]
> diff --git a/package/micropython-lib/micropython-lib.mk b/package/micropython-lib/micropython-lib.mk
> new file mode 100644
> index 0000000..8eb3c1f
> --- /dev/null
> +++ b/package/micropython-lib/micropython-lib.mk
> @@ -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?

> +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.

> +endef
> +
> +$(eval $(generic-package))

[snip]

> diff --git a/package/micropython/micropython.mk b/package/micropython/micropython.mk
> new file mode 100644
> index 0000000..16dc263
> --- /dev/null
> +++ b/package/micropython/micropython.mk
> @@ -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.

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.

> +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))
>
Vicente Olivert Riera Sept. 15, 2015, 10:19 a.m. UTC | #2
Dear Chris Packham,

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

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

Regards,

Vincent.
Chris Packham Sept. 15, 2015, 9:30 p.m. UTC | #3
On Tue, Sep 15, 2015 at 10:19 PM, Vicente Olivert Riera
<Vincent.Riera@imgtec.com> wrote:
> 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.

> Regards,
>
> Vincent.
Chris Packham Sept. 15, 2015, 9:54 p.m. UTC | #4
On Tue, Sep 15, 2015 at 12:01 PM, Chris Packham <judge.packham@gmail.com> wrote:
> Micro Python is a lean and fast implementation of the Python 3
> programming language that is optimised to run on a microcontroller.
>
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
> ---
>
> 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.
>
<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.
Thomas Petazzoni Sept. 15, 2015, 10:03 p.m. UTC | #5
Vicente, Chris,

On Tue, 15 Sep 2015 11:14:45 +0100, Vicente Olivert Riera wrote:

> 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?

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
diff mbox

Patch

diff --git a/package/Config.in b/package/Config.in
index fc35f12..986fe16 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -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
diff --git a/package/micropython-lib/Config.in b/package/micropython-lib/Config.in
new file mode 100644
index 0000000..a7e017b
--- /dev/null
+++ b/package/micropython-lib/Config.in
@@ -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
diff --git a/package/micropython-lib/micropython-lib.mk b/package/micropython-lib/micropython-lib.mk
new file mode 100644
index 0000000..8eb3c1f
--- /dev/null
+++ b/package/micropython-lib/micropython-lib.mk
@@ -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))
diff --git a/package/micropython/Config.in b/package/micropython/Config.in
new file mode 100644
index 0000000..ec47463
--- /dev/null
+++ b/package/micropython/Config.in
@@ -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
diff --git a/package/micropython/micropython.mk b/package/micropython/micropython.mk
new file mode 100644
index 0000000..16dc263
--- /dev/null
+++ b/package/micropython/micropython.mk
@@ -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))