Skip to content

Conversation

@omarandlorraine
Copy link
Contributor

in Debian 11 which is Bullseye, /usr/bin/python is a Python2
interpreter, which means that cppcheck-htmlreport fails to run here.
So I've changed the shebang to use python3

I'm really not sure what the package supplied by Debian themselves does; maybe they have to maintain a diff themselves or something!

in Debian 11 which is Bullseye, /usr/bin/python is a Python2
interpreter, which means that cppcheck-htmlreport fails to run here.
So I've chenged the shebang to use python3
@firewave
Copy link
Collaborator

firewave commented Feb 8, 2022

Thanks for your contribution.

How does it fail with Python 2.7? We are currently still targeting Python 2.7 as the minimum version for most of our scripts (something that might change soon) so it should be working. The tests for cppcheck-htmlreport are currently passing on Python 2.7 - see

- name: test htmlreport
for the test execution in the CI.

@omarandlorraine
Copy link
Contributor Author

omarandlorraine commented Feb 9, 2022

It's an import error actually; debian seems to not ship python-pygments in the standard repositories. Perhaps they stopped shipping it with Bullseye. But of course, they do ship python3-pygments.

EDIT: I just checked, Debian stopped shipping python-pygments with Buster, which is oldstable now. This means any new debian installs will not be able to run cppcheck-htmlreport without this change.

@firewave
Copy link
Collaborator

It's an import error actually; debian seems to not ship python-pygments in the standard repositories. Perhaps they stopped shipping it with Bullseye. But of course, they do ship python3-pygments.

Ugh. Well - you can still install it yourself via pip.

EDIT: I just checked, Debian stopped shipping python-pygments with Buster, which is oldstable now. This means any new debian installs will not be able to run cppcheck-htmlreport without this change.

Depending on the alternative set for python.
I came across this in our CI when I was switching over to Python provided by the platform (see #3776). I guess it's time to finally sunset Python 2.7 support.

IIRC there's a patch in the debian packaging which also does this change so if you are using the packaged version it will work.

@danmar
Copy link
Owner

danmar commented Feb 10, 2022

well we could change the shebang I guess. for most users it would make better sense to use python3. For users that have old unix systems it's possible to run with explicit python, they can execute the script like: python htmlreport.

@firewave
Copy link
Collaborator

well we could change the shebang I guess. for most users it would make better sense to use python3. For users that have old unix systems it's possible to run with explicit python, they can execute the script like: python htmlreport.

As seen in the overview at #3596 (comment) Python 3.x is available across even quite old platforms. I really thinking we should get rid of Python 2.7. We are also inconsistent with python and python3 in our scripts and in our CI so a user and dev with both versions on their system will have an inconsistent experience as well. We did not recognize this since we use a fixed Python version in the CI. So similar to Qt we need to make sure it actually works on the actual platform.

@danmar
Copy link
Owner

danmar commented Feb 10, 2022

I really thinking we should get rid of Python 2.7.

I don't have a very strong opinion right now actually. Python 2.x is probably not entirely dead yet. But even if a user is stuck with python 2.x for some reason, the cppcheck core functionality can still be used without python scripts.

@firewave
Copy link
Collaborator

I don't have a very strong opinion right now actually. Python 2.x is probably not entirely dead yet. But even if a user is stuck with python 2.x for some reason, the cppcheck core functionality can still be used without python scripts.

In that case he could override it with python2 <file>.py. We have tests that ensure we should be working with it. But the out-of-the-box behavior should be consistent i.e. use the python3 shebang across all files. In that case we would also have to do no additional changes if we remove Python 2.7 support.

@danmar
Copy link
Owner

danmar commented Feb 10, 2022

In that case he could override it with python2 .py. We have tests that ensure we should be working with it. But the out-of-the-box behavior should be consistent i.e. use the python3 shebang across all files.

That is OK. Use python3 in all the shebangs. People that are stuck with python2 have to override..

@omarandlorraine
Copy link
Contributor Author

omarandlorraine commented Feb 11, 2022

That is OK. Use python3 in all the shebangs.

I've changed all the shebangs that had python to python3

@firewave
Copy link
Collaborator

I've changed all the shebangs that had python to python3

So let me adjust the CI first via #3776 first and then we should be able to put this in.

@firewave
Copy link
Collaborator

I think we should flag all those .py files as executable as well.

@danmar
Copy link
Owner

danmar commented Feb 12, 2022

Merge branch 'danmar:main' into main

I would suggest that you use git rebase .. instead of git merge ...

@firewave
Copy link
Collaborator

I need to adjust the docker jobs as well - I already expected such. Will take a look later.

I would suggest that you use git rebase .. instead of git merge ...

It's definitely better but since we "squash merge" it doesn't matter at all.

FYI It makes a big difference in case you utilize reviews since a merge doesn't reset the review status where as a rebase does..

@firewave
Copy link
Collaborator

There's also a ticket about this - https://trac.cppcheck.net/ticket/10274.

@firewave
Copy link
Collaborator

Please rebase this after #4004 has been merged. I had to switch to Python 3.x in some of the jobs and made several adjustments which should make these changes work at last.

@firewave
Copy link
Collaborator

That PR has been merged. Please rebase.

@danmar danmar merged commit 6488650 into danmar:main Nov 3, 2022
@danmar
Copy link
Owner

danmar commented Jan 28, 2023

@omarandlorraine I would like to add you in our AUTHORS file. What name would you like that I add?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants