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

Analyzer Python compatibility check might fail, resulting in Python2 fallback #4289

Closed
nicorikken opened this issue Jul 16, 2021 · 3 comments
Labels
analyzer About the analyzer tool

Comments

@nicorikken
Copy link
Member

If there is an error with parsing the Python file into a Python3 ast, the python_compatibility.py script fails:

file_content = open(file_path, encoding="UTF-8").read()

I wasn't able to debug this on first glance. Perhaps I should have enabled debug level logging to get a proper warning. I'm now trying to debug this issue some more to come up with ideas for usability improvements.

Thanks to @edulix for pinpointing the issue.

Possible improvements

  • Adjust log levels to make it clearer what is causing the false behavior
  • Just raise the error with print(e)
  • Suggest running the python_compatibility.py script locally to find the troublesome files
@edulix
Copy link

edulix commented Jul 16, 2021

Another important issue is that it is not clear which package manager is being run and with which python version. Without any previous knowledge of the code and as a noob user, I had to write some debugging code in the Pip.kt code to show the python version being used and found this python_compatibility.py script and more or less how it worked.

04:11:06.620 [DefaultDispatcher-worker-3] WARN  org.ossreviewtoolkit.analyzer.managers.PythonVersion - EDU: using python version '3'
04:11:06.628 [DefaultDispatcher-worker-3] WARN  org.ossreviewtoolkit.analyzer.managers.PythonVersion - EDU: using 3 pythonVersionCommand = 'Python 3.6.9`

Possible improvements / suggestions

  • Always show a clear indication of which is the package manager detected (and perhaps even why, like package.json found => using NPM package manager).
  • In the case of the Pip package manager, show the output of python --version to tell the user what version of python is being detected.

@sschuberth sschuberth added analyzer About the analyzer tool enhancement labels Jul 26, 2021
@nicorikken
Copy link
Member Author

@edulix I like your suggested generic debug information.

This specific issue was solved for me with newer version of Python through #3902 Still I'm now sure why a Python file would not be read correctly as utf-8, which makes it difficult to debug or solve. I haven't been able to pinpoint the issue.

sschuberth added a commit that referenced this issue Oct 12, 2022
This is a fixup for c885541. Not relying on the script anymore
implicitly resolved issue #4289.

Signed-off-by: Sebastian Schuberth <[email protected]>
sschuberth added a commit that referenced this issue Oct 12, 2022
This is a fixup for c885541. Not relying on the script anymore
implicitly resolved issue #4289.

Signed-off-by: Sebastian Schuberth <[email protected]>
@sschuberth
Copy link
Member

The python_compatibility.py script is not in use anymore as of c885541, so I believe this can be closed.

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

No branches or pull requests

3 participants