简体   繁体   English

devpi - 如何获得“root/<package> /json”服务

[英]devpi - how to get “root/<package>/json” served

my goal is to install python-packages on a micropython-device.我的目标是在 micropython 设备上安装 python 包。 Anyway I got the devpi-server to run and and upload a package.无论如何,我让 devpi-server 运行并上传了一个包。

What I could not achieve is, that the devpi-server delivers something like you get from: https://micropython.org/pi/micropython-pystone_lowmem/json我无法实现的是,devpi-server 提供了类似于您从以下位置获得的内容: https ://micropython.org/pi/micropython-pystone_lowmem/json

Accessing the above url is, how "upip" gets its package information.访问上面的url,就是“upip”是如何获取它的包信息的。

So I'm new to Pypy-server and devpi-server and this might be a trivial question, anyway I get stuck at this point.所以我是 Pypy-server 和 devpi-server 的新手,这可能是一个微不足道的问题,无论如何我在这一点上卡住了。

Thank you for any help in advance, Axel.提前感谢您的任何帮助,阿克塞尔。

There was two steps needed, to get micropython packages installed via devpi-server.需要两个步骤,通过 devpi-server 安装 micropython 包。

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.第一:感谢来自 devpi-server 项目的 @fschulze 的支持,提供了 Gist gist.github.com/fschulze/077320ab51f8ae91381d5e7faa0ac647,它为 devpi-server 添加了 /json 能力。

Update: You can install devpi-json-info with pip install devpi-json-info from https://pypi.org/project/devpi-json-info/更新:您可以从https://pypi.org/project/devpi-json-info/使用pip install devpi-json-info

2nd: upip.py needs a patch to support port numbers:第二:upip.py 需要一个补丁来支持端口号:

Update 2020-10-20: The patch below has made it in the micropython repository, thanks to @dpgeorge, 56e0932 2020 年 10 月 20 日更新:感谢 @dpgeorge, 56e0932在 micropython 存储库中添加了以下补丁

Update 2020-10-08: added the patch below as PR:6521 2020-10-08 更新:添加以下补丁为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":

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM