gpt4 book ai didi

python - 如何将 httpie 与 httpie-aws-authv4 捆绑到 Python zipapp 中?

转载 作者:行者123 更新时间:2023-12-01 06:55:55 26 4
gpt4 key购买 nike

打包起来很简单httpie转换为 Python“PYZ”(zipapp),例如使用

$ pip install --upgrade zapp
$ zapp httpie.pyz httpie.__main__:main httpie
$ python ./httpie.pyz --version
1.0.3

现在我尝试包含 httpie-aws-authv4作为 httpie 的插件,用于 AWS 身份验证。唉,httpie 没有安装该插件。

$ zapp httpie-aws4.pyz httpie.__main__:main httpie httpie-aws-authv4
$ python ./httpie-aws4.pyz
usage: http [--json] [--form] [--pretty {all,colors,format,none}]
...
[--auth USER[:PASS]] [--auth-type {basic,digest}]

$ python ./httpie-aws4.pyz -A aws4 http://localhost:9200/
...
http: error: argument --auth-type/-A: invalid choice: u'aws4' (choose from 'basic', 'digest')

应该显示[--auth-type {basic,digest,aws4}]

有人知道如何实现这一点吗?

最佳答案

郑重声明,我通过使用内置的身份验证机制列表注册扩展来解决插件加载问题。尽管通过不同的机制,这使得插件可用且可操作。对于 zipapp 使用来说这是完全可以的:

zapp httpie-aws4.pyz httpie.__main__:main httpie httpie-aws-authv4
mkdir -p httpie/plugins
unzip -q -c httpie-aws4.pyz httpie/plugins/__init__.py | gsed \
-e '15i from httpie_aws_authv4 import AWSv4AuthPlugin # ADDED' \
-e '19i AWSv4AuthPlugin, # ADDED' \
> httpie/plugins/__init__.py
zip httpie-aws4.pyz httpie/plugins/__init__.py

然后根据需要出现 aws4 身份验证机制:

python ./httpie-aws4.pyz 2>&1 | grep auth-type
[--auth USER[:PASS]] [--auth-type {aws4,basic,digest}]

关于python - 如何将 httpie 与 httpie-aws-authv4 捆绑到 Python zipapp 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58806102/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com