addition to Merge #11830. I looked through the source files looking for other files with
#!/usr/bin/env python2
and found that contrib/devtools/test-security-check.py had the same error that @hkjn pointed out.
It might simply mean that the tool needs python 2.
Did you verify and test that this code is compatible with python 3?
#!bin/env python
is targeted for unix users and other POSIX based OSs where some of them dont have the #!bin/env python2
symlink like MacOS. So i would argue that using #!bin/env python
is preferred over #!bin/env python2
.
It looks like we use #!/usr/bin/env python3
in most places:
0git ls-files \*.py | xargs head -n 1|less
I’m ok with doing that instead.
FWIW I also agree that setting python3
explicitly is the best path, assuming python2
support no longer is necessary. I went the other way in #11830 to try to be gentle to the long tail of python2
-only folks that are still out there.
Any such users on python2
only could still call scripts with python2 somescript.py
if they for some reason don’t want to upgrade, assuming we keep the scripts compatible with both major versions.
doc/dependencies.md
, we still target py2 support for user facing scripts. Functional tests are the only exception.
ACK after squash
Even though it is not mentioned in doc/dependencies.md, we still target py2 support for user facing scripts. Functional tests are the only exception.
Yes, agree it’s somewhat weird now. I think it’s about time to move away from that, and just settle on Python 3. But not be a discussion that we need to do here.
(In any case, changing the default interpreter when this script is called separately does not affect compatibility of the build system, which calls python scripts with an explicit interpreter. I think defaulting to python 3 here makes sense going forward. But I don’t care deeply.)
Yes, agree it’s somewhat weird now. I think it’s about time to move away from that, and just settle on Python 3. But not be a discussion that we need to do here.
I completely agree with @laanwj. Here are the hashbangs for python files not in the test directory:
0share/qt/extract_strings_qt.py|1 col 12| #!/usr/bin/env python
1share/rpcauth/rpcauth.py|1 col 12| #!/usr/bin/env python
2contrib/testgen/gen_base58_test_vectors.py|1 col 12| #!/usr/bin/env python
3contrib/linearize/linearize-hashes.py|1 col 12| #!/usr/bin/env python3
4contrib/linearize/linearize-data.py|1 col 12| #!/usr/bin/env python3
5contrib/zmq/zmq_sub3.4.py|1 col 12| #!/usr/bin/env python3
6contrib/zmq/zmq_sub.py|1 col 12| #!/usr/bin/env python3
7contrib/macdeploy/custom_dsstore.py|1 col 12| #!/usr/bin/env python
8contrib/macdeploy/macdeployqtplus|1 col 12| #!/usr/bin/env python
9contrib/seeds/generate-seeds.py|1 col 12| #!/usr/bin/env python3
10contrib/seeds/makeseeds.py|1 col 12| #!/usr/bin/env python3
11contrib/filter-lcov.py|1 col 12| #!/usr/bin/env python3
12contrib/devtools/check-doc.py|1 col 12| #!/usr/bin/env python
13contrib/devtools/copyright_header.py|1 col 12| #!/usr/bin/env python3
14contrib/devtools/check-rpc-mappings.py|1 col 12| #!/usr/bin/env python3
15contrib/devtools/security-check.py|1 col 12| #!/usr/bin/env python
16contrib/devtools/optimize-pngs.py|1 col 12| #!/usr/bin/env python
17contrib/devtools/test-security-check.py|1 col 12| #!/usr/bin/env python2
18contrib/devtools/update-translations.py|1 col 12| #!/usr/bin/env python
19contrib/devtools/github-merge.py|1 col 12| #!/usr/bin/env python3
20contrib/devtools/symbol-check.py|1 col 12| #!/usr/bin/env python
21contrib/devtools/clang-format-diff.py|1 col 12| #!/usr/bin/env python
Almost all specify python3. Having some which nominally support python2 is a bad idea, since I’d imagine no-one is even testing that they maintain compatibility with python2.
But not be a discussion that we need to do here.
I’ll open a PR to completely remove support for python2. We can move the discussion there.
I think you need a couple more changes:
from __future__ import division,print_function
lineuniversal_newlines=True
argument to the subprocess.Popen()
callI’ll open a PR to completely remove support for python2. We can move the discussion there.
I think the only exception would be some of the python scripts for macdeploy that still require Python 2 (@cfields probably knows).
git rebase -i HEAD~3
and then selecting f
for the second and third commits), and remove the @ jnewbery tag from the commit message (credit is not generally required for reviewers, and having @ tags in commit messages makes github spam the user).
security-check.py
to py3-only as well. As I read the current code, it will run the test in py3 and the actual script in py2. Imo, this should be avoided.