[Python-Dev] Single-file Python executables (including case of self-sufficient package manager)

Paul Sokolovsky pmiscml at gmail.com
Fri May 29 16:23:16 CEST 2015


Hello,

On Fri, 29 May 2015 08:35:44 -0400
Donald Stufft <donald at stufft.io> wrote:

[]
 
> Another example is one that I personally worked on recently, where
> the company I worked for wanted to distribute a CLI to our customers
> which would "just work" that they could use to interact with the
[]
> particular piece I was feeling like I should be suggesting to my
> manager that we throw away the Python code and just write it in Go.

Please consider next time thinking about MicroPython for this usecase,
as that's exactly why there're people who think that MicroPython is
interesting for "desktop" systems, not just bare-metal
microcontrollers. There're too few such people so far, unfortunately,
so progress is slow.

> An example of a product that does this is Chef, they install their
> own Ruby and everything but libc into /opt/chef to completely isolate
> themselves from the host system. I’m told this made things *much*
> easier for them as they don't really have to worry at all about
> what's available on the host system, Chef pretty much just works.

[]
> As folks may or may not know, I'm heavily involved in pip which is
> probably one of the most widely used CLIs written in Python. A single
> file executable won't help pip, however through my experience there I

It's interesting you bring up this case of pip (and Chef), as I had
similar concerns/issues when developing a self-hosted package manager
for MicroPython. MicroPython doesn't come out of the box with standard
library - beyond few builtin modules ("core" library), every other
module/package needs to be installed individually (micropython-*
modules on PyPI). That makes a package manager a critical component, and
means that package manager itself cannot rely on standard library -
presence, absence, of specific version (or contents of standard
modules).

My initial idea was to write single-file script, but we're not ready
for self-sufficiency yet anyway (no SSL support, have to rely on wget),
and it's a bit of chore anyway. So instead, I made a semi-automated
"library subset package" (e.g. os renamed to upip_os), and all such
modules comes package together with the main script:
https://github.com/micropython/micropython-lib/tree/master/upip ,
https://pypi.python.org/pypi/micropython-upip . Then we have a script
to bootstrap upip:
https://github.com/micropython/micropython/blob/master/tools/bootstrap_upip.sh ,
after which any package can be installed using upip proper.



-- 
Best regards,
 Paul                          mailto:pmiscml at gmail.com


More information about the Python-Dev mailing list