static compilation

0 views
Skip to first unread message

Kees ter Brugge

unread,
Aug 27, 2016, 7:00:20 AM8/27/16
to Numba Public Discussion - Public
Hi,

I've been experimenting with algorithms, docker and microservices. If one wants to create a microservice with languages like go and c one could compile that program to a static binary. This binary can be used to create a really small docker container that inherits from the scratch image by only adding the binary.

I would like to make a microservice using docker and numba. I haven't seen anything written about this use case yet. Can this be done without needing to have the python runtime and numpy installed in the docker container?  

In an old version of the numba documentation (http://numba.pydata.org/numba-doc/0.7/doc/pycc.html) it says the following: 
 "Options exist to compile to native object files instead of a shared library, to emit LLVM code or to generate a C header file with function prototypes. "

But in a more recent version of the documentation () it says: 
  1. "AOT compilation produces a compiled extension module which does not depend on Numba: you can distribute the module on machines which do not have Numba installed (but Numpy is required)."
Is it possible to create a small binary that has everything in it, without needing python or numpy, to keep the size of the container small?

I hope somebody can shed some light on this. 


Stanley Seibert

unread,
Aug 29, 2016, 4:34:11 PM8/29/16
to Numba Public Discussion - Public
Hi,

This is not a use case we have looked at.  Because Numba does not compile entire Python applications or generic Python code (or the Python standard library), there isn't any performance benefit to static linkage.  Numba still depends on the full Python interpreter to be available to run things.

If you are concerned about space, you might be able to prune unneeded packages out of a standard Python installation, but this will be tricky.

Something like Nuitka might be more what you are looking for:

http://nuitka.net/pages/overview.html


--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users+unsubscribe@continuum.io.
To post to this group, send email to numba...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/400c8e5f-1849-43dd-b961-233ce62ef3e4%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Antoine Pitrou

unread,
Aug 30, 2016, 7:19:34 AM8/30/16
to numba...@continuum.io
On Sat, 27 Aug 2016 04:00:20 -0700 (PDT)
Kees ter Brugge <keeste...@gmail.com>
wrote:
>
> I would like to make a microservice using docker and numba. I haven't seen
> anything written about this use case yet. Can this be done without needing
> to have the python runtime and numpy installed in the docker container?

Are you really that short on disk space?

If not, have you checked pyinstaller (http://www.pyinstaller.org/)?

Regards

Antoine.


Antoine Pitrou

unread,
Aug 30, 2016, 7:25:08 AM8/30/16
to numba...@continuum.io
By the way, someone (Hartmut Goebel) just contributed Numba + llvmlite
support to pyinstaller! It should be in pyinstaller 3.3 apparently.

https://github.com/pyinstaller/pyinstaller/pull/2113

Regards

Antoine.


Kees ter Brugge

unread,
Aug 30, 2016, 8:22:42 AM8/30/16
to numba...@continuum.io
Awesome, I will explore that.
Btw, love the work you're doing on numba.

Thanks!




Antoine.


--
You received this message because you are subscribed to a topic in the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/numba-users/Q8sxa3ZZgaQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to numba-users+unsubscribe@continuum.io.

To post to this group, send email to numba...@continuum.io.
Reply all
Reply to author
Forward
0 new messages