1

It is straightforward to package httpie into a Python "PYZ" (zipapp), e.g. using

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

Now I tried to include httpie-aws-authv4 as a plug-in to httpie, for AWS authentication. Alas, httpie does not pick up that plug-in.

$ 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')

It should say [--auth-type {basic,digest,aws4}]

Anyone knows how to make that work?

mgaert
  • 2,338
  • 21
  • 27

1 Answers1

1

For the record, I worked around the plug-in loading issue by registering the extension with the built-in list of authentication mechanisms. This makes the plug-in available and operational, albeit through a different mechanism. For the zipapp use this is perfectly fine:

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

The aws4 authentication mechanims then appears, as desired:

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