Skip to content

Commit

Permalink
[python] Fix CLI option synonym handling for old click
Browse files Browse the repository at this point in the history
Click < 6.8 has a bug [1] where if you specify option alias, it chooses
last long option as a name for keyword argument that gets passed to the
underlying command function (instead of the first one as documented in
newer versions [2]. Fix this by specifying option name explicitly.

[1] pallets/click#793 fixed in
    pallets/click@f15f425
[2] https://click.palletsprojects.com/en/8.1.x/options/#name-your-options
    (point 2)

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
  • Loading branch information
woju authored and dimakuv committed Sep 7, 2023
1 parent b9aea0a commit 8f65e6a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Depends:
libprotobuf-c1,
python3,
python3 (>= 3.10) | python3-pkg-resources,
python3-click,
python3-click (>= 6.7),
python3-cryptography,
python3-jinja2,
python3-pyelftools,
Expand Down
2 changes: 1 addition & 1 deletion gramine.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ BuildRequires: python3-recommonmark
BuildRequires: python3-sphinx
BuildRequires: python3-sphinx_rtd_theme

Requires: python3-click
Requires: python3-click >= 6.7
Requires: python3-cryptography
Requires: python3-jinja2
Requires: python3-protobuf
Expand Down
2 changes: 1 addition & 1 deletion packaging/alpine/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ makedepends="
py3-pytest
"
depends="
py3-click
py3-click>=6.7
py3-cryptography
py3-elftools
py3-jinja2
Expand Down
5 changes: 4 additions & 1 deletion python/graminelibos/sgx_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,10 @@ def get_tbssigstruct(manifest_path, date, libpal=SGX_LIBPAL, verbose=False):
type=click.File('rb'),
default=os.fspath(SGX_RSA_KEY_PATH),
help='specify signing key (.pem) file')
@click.option('--passphrase', '--password', '-p', metavar='PASSPHRASE',
# Explicit 'passphrase' below is for compatibility with click < 6.8 (supported on .el8),
# see https://github.com/pallets/click/issues/793 for more info.
# TODO after deprecating .el8: remove this workaround
@click.option('--passphrase', '--password', '-p', 'passphrase', metavar='PASSPHRASE',
help='optional passphrase to decrypt the key')
def sign_with_file(ctx, key, passphrase):
try:
Expand Down

0 comments on commit 8f65e6a

Please sign in to comment.