Search code examples
devpi

devpi - how to get "root/<package>/json" served


my goal is to install python-packages on a micropython-device. Anyway I got the devpi-server to run and and upload a package.

What I could not achieve is, that the devpi-server delivers something like you get from: https://micropython.org/pi/micropython-pystone_lowmem/json

Accessing the above url is, how "upip" gets its package information.

So I'm new to Pypy-server and devpi-server and this might be a trivial question, anyway I get stuck at this point.

Thank you for any help in advance, Axel.


Solution

  • There was two steps needed, to get micropython packages installed via devpi-server.

    1st: Thanks to the support from @fschulze from the devpi-server project a Gist is provided gist.github.com/fschulze/077320ab51f8ae91381d5e7faa0ac647 which adds /json capbility to devpi-server.

    Update: You can install devpi-json-info with pip install devpi-json-info from https://pypi.org/project/devpi-json-info/

    2nd: upip.py needs a patch to support port numbers:

    Update 2020-10-20: The patch below has made it in the micropython repository, thanks to @dpgeorge, 56e0932

    Update 2020-10-08: added the patch below as PR:6521

     --- upip.py.orig   2020-09-01 21:14:20.410287796 +0200
     +++ upip.py    2020-09-11 21:54:03.567011061 +0200
     @@ -129,7 +129,11 @@
      
          proto, _, host, urlpath = url.split("/", 3)
          try:
     -        ai = usocket.getaddrinfo(host, 443, 0, usocket.SOCK_STREAM)
     +        port = 443
     +        if ":" in host:
     +            host, port = host.split(":")
     +            port = int(port)
     +        ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM)
          except OSError as e:
              fatal("Unable to resolve %s (no Internet?)" % host, e)
          # print("Address infos:", ai)
     @@ -147,7 +151,7 @@
                      warn_ussl = False
      
              # MicroPython rawsocket module supports file interface directly
     -        s.write("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (urlpath, host))
     +        s.write("GET /%s HTTP/1.0\r\nHost: %s:%s\r\n\r\n" % (urlpath, host, port))
              l = s.readline()
              protover, status, msg = l.split(None, 2)
              if status != b"200":