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

ScanCode stops with the following error message: AttributeError: module 'click' has no attribute 'get_terminal_size' #2904

Closed
vargenau opened this issue Mar 31, 2022 · 8 comments
Labels

Comments

@vargenau
Copy link
Contributor

Description

ScanCode stops with the following error message:

AttributeError: module 'click' has no attribute 'get_terminal_size'

How To Reproduce

 scancode -c -l -i --spdx-tv reuse.spdx /home/vargenau/git/reuse-tool/

/home/vargenau/venv/lib/python3.9/site-packages/cluecode/copyrights.py:3382: FutureWarning: Possible set difference at position 3
  remove_tags = re.compile(
Setup plugins...
Collect file inventory...
Scan files for: info, licenses, copyrights with 1 process(es)...
[--------------------] 0
Removing temporary files...done.
Traceback (most recent call last):
  File "/home/vargenau/venv/bin/scancode", line 8, in <module>
    sys.exit(scancode())
  File "/home/vargenau/venv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/vargenau/venv/lib/python3.9/site-packages/commoncode/cliutils.py", line 69, in main
    return click.Command.main(
  File "/home/vargenau/venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/vargenau/venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/vargenau/venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/vargenau/venv/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/vargenau/venv/lib/python3.9/site-packages/scancode/cli.py", line 451, in scancode
    success, _results = run_scan(
  File "/home/vargenau/venv/lib/python3.9/site-packages/scancode/cli.py", line 887, in run_scan
    scan_success = run_scanners(
  File "/home/vargenau/venv/lib/python3.9/site-packages/scancode/cli.py", line 1125, in run_scanners
    scan_success = scan_codebase(
  File "/home/vargenau/venv/lib/python3.9/site-packages/scancode/cli.py", line 1236, in scan_codebase
    scan_timings) = next(scans)
  File "/home/vargenau/venv/lib/python3.9/site-packages/click/_termui_impl.py", line 116, in __next__
    return next(iter(self))
  File "/home/vargenau/venv/lib/python3.9/site-packages/commoncode/cliutils.py", line 174, in generator
    self.update(1)
  File "/home/vargenau/venv/lib/python3.9/site-packages/click/_termui_impl.py", line 302, in update
    self.render_progress()
  File "/home/vargenau/venv/lib/python3.9/site-packages/commoncode/cliutils.py", line 189, in render_progress
    return super(EnhancedProgressBar, self).render_progress()
  File "/home/vargenau/venv/lib/python3.9/site-packages/click/_termui_impl.py", line 242, in render_progress
    line = self.format_progress_line()
  File "/home/vargenau/venv/lib/python3.9/site-packages/click/_termui_impl.py", line 199, in format_progress_line
    item_info = self.item_show_func(self.current_item)
  File "/home/vargenau/venv/lib/python3.9/site-packages/commoncode/cliutils.py", line 373, in path_progress_message
    max_file_name_len = file_name_max_len()
  File "/home/vargenau/venv/lib/python3.9/site-packages/commoncode/cliutils.py", line 356, in file_name_max_len
    term_width, _height = click.get_terminal_size()
AttributeError: module 'click' has no attribute 'get_terminal_size'

System configuration

  • What OS are you running on? Ubuntu 21.10
  • What version of scancode-toolkit was used to generate the scan file?
scancode --version
/home/vargenau/venv/lib/python3.9/site-packages/cluecode/copyrights.py:3382: FutureWarning: Possible set difference at position 3
  remove_tags = re.compile(
ScanCode version 30.1.0
ScanCode Output Format version 1.0.0
SPDX License list version 3.14
  • What installation method was used to install/run scancode? pip
@vargenau vargenau added the bug label Mar 31, 2022
@pombredanne
Copy link
Member

@vargenau Thanks for the report!
How did you install scancode? using pip?

@pombredanne
Copy link
Member

pombredanne commented Mar 31, 2022

@vargenau I am pretty sure you did so!

I think we need to run a daily test that runs against the latest and great of every dependency.
The root of this issue is https://click.palletsprojects.com/en/8.1.x/changes/#version-8-1-0

Version 8.1.0
Released 2022-03-28
Drop support for Python 3.6. pallets/click#2129
Remove previously deprecated code. pallets/click#2130
Group.resultcallback is renamed to result_callback.
autocompletion parameter to Command is renamed to shell_complete.
get_terminal_size is removed, use shutil.get_terminal_size instead.
get_os_args is removed, use sys.argv[1:] instead.

Basically click dropped features in a dot release :|
I do not blame them for this, but that's unfortunate.
We have release tarballs that contain pinned version of all deps to protect against this... and we have pinned requirements files too... but there is no easy way to get both relaxed dependency constraints to minimize conflicts when using as a pip installation and at the same getting pinned versions.

The only way will be to get frequent tests and more frequent releases?

@pombredanne
Copy link
Member

Short term, your fix is going to be pip install click==8.0.4 scancode-toolkit

@vargenau
Copy link
Contributor Author

Hi Philippe,

Thank you for your quick answer.
Yes, I have installed with pip, it was mentioned at the end of the report.

pip install click==8.0.4 scancode-toolkit

solved the issue.

@AyanSinhaMahapatra
Copy link
Member

AyanSinhaMahapatra commented Mar 31, 2022

@pombredanne
Copy link
Member

@vargenau re:

Yes, I have installed with pip, it was mentioned at the end of the report.

pip install click==8.0.4 scancode-toolkit

solved the issue.

Great!

FWIW, 1/2 of the whole Python FOSS world started to bug and crash over the last few days following this release of Click 8.1.0
At least we are not alone there.

@pombredanne
Copy link
Member

A proper fix is in aboutcode-org/commoncode@14a142d by @georgthegreat

@pombredanne
Copy link
Member

and commoncode has been bumped in the latest develop branch. Closing this ... this is part of the next 31 beta release that I will publish over the weekend!
Thank you all 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants