upip - Self-hosted package manager

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Self-hosted package manager

Post by stijn » Mon May 04, 2015 2:33 pm

Works fine on fresh debian installation

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Self-hosted package manager

Post by pfalcon » Tue May 05, 2015 1:40 pm

Thanks for testing!
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Self-hosted package manager (upip)

Post by pfalcon » Sat Jun 06, 2015 8:41 am

upip is now bundled with Unix binary as a frozen module. To use:

Code: Select all

micropython -m upip
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: upip - Self-hosted package manager

Post by pfalcon » Wed Oct 14, 2015 9:32 pm

Ok, the last thing which was required to fully enable upip was builtin SSL support on MicroPython level. Module "ussl", using axTLS library was recently committed to master. Here are the steps to try it:

1. Clone uPy with submodules (recursively):

Code: Select all

git clone --recursive https://github.com/micropython/micropython
2. If you already have non-recursive clone, pull submodules using:

Code: Select all

git submodule update --init
3. cd unix

4. Build axtls:

Code: Select all

make axtls
You can specify crosscompiling and target options as usual, e.g. MICROPY_FORCE_32BIT=1. Note that this will rebuild axtls each time (this is done to make sure that library corresponds to crosscompiling and target options passed).

5. Build unix port, enabling module ussl:

Code: Select all

make MICROPY_PY_USSL=1
6. Test that module ussl is there:

Code: Select all

./micropython
>>> import ussl
>>>
7. That's all, upip is now fully self-contained and doesn't depend on wget binary present (it still falls back to it if ussl is not available).

Code: Select all

micropython -m upip install micropython-os


I'd appreciate if different people tested the steps above on their systems. The eventual plan is to enable modussl by default. And of course, this opens up possibility to use upip on baremetal targets (but of course, this will require some work).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: upip - Self-hosted package manager

Post by platforma » Wed Oct 14, 2015 10:07 pm

Hi pfalcon, ran this in my local repo and worked absolutely fine.
The default path for libs is ~/.micropython, is there a way to configure this so the micropython executable picks up the libs also?
Thank you for your work!

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: upip - Self-hosted package manager

Post by pfalcon » Wed Oct 14, 2015 11:28 pm

Thanks for testing!
The default path for libs is ~/.micropython, is there a way to configure this so the micropython executable picks up the libs also?
What do you mean? The default for upip is the same as for micropython executable, so after you installed module(s) with upip, you can start up executable and import them.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: upip - Self-hosted package manager

Post by dhylands » Thu Oct 15, 2015 12:32 am

I'll also confirm that this worked for me (including the install of micropython-os) and I was able to import os when I reran micropython after installing it.

I was building using Ubuntu 14.04.3 LTS.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: upip - Self-hosted package manager

Post by dhylands » Thu Oct 15, 2015 12:41 am

@pfalcon - so assuming that I've installed some modules (like micropython-os) what's the procedure for keeping them up-to-date?

Right now it looks like I'd have to keep track of all of the various modules installed and then reinstall them.

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: upip - Self-hosted package manager

Post by platforma » Thu Oct 15, 2015 3:07 pm

pfalcon wrote:...you can start up executable and import them.
Yes, importing and using the libs works fine, I tried the os module. What I meant was, upip creates a directory in the user folder called .micropython/lib under which the installed libs go, unless I'm missing something. Is it possible to keep the libraries someplace else, for example the same directory as the unix build, rather than in user home dir.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: upip - Self-hosted package manager

Post by dhylands » Thu Oct 15, 2015 3:42 pm

Here's the code which determines the path used:
https://github.com/micropython/micropyt ... #L385-L392

So, you can do:

Code: Select all

MICROPYPATH=/some/other/dir ./micropython
and it will use that.

You can examine the library search path from within micropython by doing:

Code: Select all

2530 >./micropython 
MicroPython v1.4.6-89-g556c8a9 on 2015-10-14; linux version
Use CTRL-D to exit, CTRL-E for paste mode
>>> import sys
>>> sys.path
['', '/home/dhylands/.micropython/lib', '/usr/lib/micropython']
>>> import os
>>> 
and if I were instead to do:

Code: Select all

2531 >MICROPYPATH=/home/mmm ./micropython 
MicroPython v1.4.6-89-g556c8a9 on 2015-10-14; linux version
Use CTRL-D to exit, CTRL-E for paste mode
>>> import sys
>>> sys.path
['', '/home/mmm']
>>> import os
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'os'
>>> 
we see that the import of os fails because I don't have it installed in /home/mmm.

You can also influence the directory that the builtin upip uses by using the -p option on the upip install command:

Code: Select all

2532 >./micropython -m upip install -p ~/mp micropython-os
Installing to: /home/dhylands/mp/
Installing micropython-os 0.3 from https://pypi.python.org/packages/source/m/micropython-os/micropython-os-0.3.tar.gz
Created /home/dhylands/mp/
Created /home/dhylands/mp/os/
Installing micropython-ffilib 0.1.2 from https://pypi.python.org/packages/source/m/micropython-ffilib/micropython-ffilib-0.1.2.tar.gz
Installing micropython-errno 0.1.3 from https://pypi.python.org/packages/source/m/micropython-errno/micropython-errno-0.1.3.tar.gz
Installing micropython-stat 0.5 from https://pypi.python.org/packages/source/m/micropython-stat/micropython-stat-0.5.tar.gz

Post Reply