1

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}]

任何人都知道如何使这项工作?

4

1 回答 1

1

作为记录,我通过使用内置身份验证机制列表注册扩展来解决插件加载问题。这使得插件可用且可操作,尽管通过不同的机制。对于 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}]
于 2019-11-13T11:49:01.077 回答