Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commoncode fails with Click < 8 #31

Closed
pombredanne opened this issue Sep 1, 2021 · 2 comments
Closed

Commoncode fails with Click < 8 #31

pombredanne opened this issue Sep 1, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@pombredanne
Copy link
Member

See in #30 by @vznncv:

The pull request #27 adds update_min_steps option usage of click._termui_impl.ProgressBar that is available from click 8.0. But existed setup.cfg contains the following restriction: click >= 6.7, !=7.0. It breaks scancode with click<8 version installation. For example: https://github.com/ARMmbed/mbed-os/pull/14981/checks?check_run_id=3470879205

This pull request updates minimal click version in the setup.cfg according changes in the pull request #27.

@pombredanne
Copy link
Member Author

from #30 (comment)

The pull request #27 adds update_min_steps option usage of click._termui_impl.ProgressBar that is available from click 8.0. But existed setup.cfg contains the following restriction: click >= 6.7, !=7.0. It breaks scancode with click<8 version installation. For example: https://github.com/ARMmbed/mbed-os/pull/14981/checks?check_run_id=3470879205

This pull request updates minimal click version in the setup.cfg according changes in the pull request #27.

I ran these tests:
/scancode-toolkit$ for clk_ver in 8.0.1 7.1.2 7.1.1 7.1 6.7; do pip uninstall -y click; pip install click==$clk_ver; scancode -i samples/ -n3 --json-pp - ; done
and
commoncode$ for clk_ver in 8.0.1 7.1.2 7.1.1 7.1 6.7; do pip uninstall -y click; pip install click==$clk_ver; pytest -vvs -n3; done

and all pass with this patch:

diff --git a/src/commoncode/cliutils.py b/src/commoncode/cliutils.py
index 4ff8c8e..5a2a3b6 100644
--- a/src/commoncode/cliutils.py
+++ b/src/commoncode/cliutils.py
@@ -267,7 +267,8 @@
             '[%(bar)s]' + ' ' + '%(info)s'
             if bar_template is None else bar_template
         )
-    return progress_class(
+
+    kwargs = dict(
         iterable=iterable,
         length=length,
         fill_char=fill_char,
@@ -281,10 +282,15 @@
         label=label,
         file=file,
         color=color,
-        update_min_steps=update_min_steps,
         width=width,
     )
 
+    pb = progress_class([])
+    if hasattr(pb, 'update_min_steps'):
+        kwargs['update_min_steps'] = update_min_steps
+
+    return progress_class(**kwargs)
+
 
 def fixed_width_file_name(path, max_length=25):
     """

The lines

+    pb = progress_class([])
+    if hasattr(pb, 'update_min_steps'): 

... are duck typing at its best... Not super elegant but effective nonetheless!

So with this patch we can accept all currently supported Click versions and not only > 8

@pombredanne pombredanne added the bug Something isn't working label Sep 1, 2021
pombredanne added a commit that referenced this issue Sep 24, 2021
This ensures that we work with all supported click versions and that
this is tested

Reference: aboutcode-org/scancode-toolkit#2713
Reference: #31
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
pombredanne pushed a commit that referenced this issue Sep 24, 2021
Signed-off-by: Jono Yang <jyang@nexb.com>
pombredanne pushed a commit that referenced this issue Sep 24, 2021
Check for deps in local thirdparty directory #31
@pombredanne
Copy link
Member Author

Fixed and released in 30.0.0

pombredanne added a commit to aboutcode-org/scancode-toolkit that referenced this issue Sep 24, 2021
This is a fix for #2713

Reference: aboutcode-org/commoncode#31
Reference: #2713
Reported-by: Thomas Druez <tdruez@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
pombredanne added a commit to aboutcode-org/scancode-toolkit that referenced this issue Sep 24, 2021
Following a commoncode update this adds tests for running scancode
on all supported Click versions.

Reference: aboutcode-org/commoncode#31
Reference: #2713
Reported-by: Thomas Druez <tdruez@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
pombredanne added a commit to aboutcode-org/scancode-toolkit that referenced this issue Sep 24, 2021
Reference: aboutcode-org/commoncode#31
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant