-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Remove Python2 support #11881
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
Remove Python2 support #11881
Conversation
Strong concept ACK! Pros:
Cons:
|
ACK for devtools. Not sure about unit tests and user facing scripts such as rpcauth.py, see also discussion in #11433 |
Marco, your comment from #11433:
Would you support this PR for all Python files including user-facing scripts and tests if it met those conditions? |
Concept ACK. I'm not aware of any major projects still on Py2 and intending to stay there. AFAIK, just about everything that's still Py2 is due to legacy and/or manpower issues. Here's how I'd like to see things handled.
|
@jnewbery I'd be -0 on that. The reason that the functional tests run at 3.4+ only, is because it would be nearly impossible to have them compatible with both 2.7 and 3.4. However, the python code used for the unit tests and the few scripts meant for users is rather condensed and hopefully not much refactored in the future. So by not touching them, they should keep their compatibility. |
ACK on the idea to go Py3-only long-term. There's a burden on supporting multiple versions of python and that burden will only become larger as Python 3 progresses, by locking us out of new features and better ways to do things. (this is a similar argument as that for going to C++11) The only problematic case are scripts that depend on libraries that only support Python2. These are rare, but I vaguely remember some of the macdeploy scripts do, so please test those carefully.
I also agree with this, though. There's no urgent reason to make this change at once, certainly for scripts that are hardly touched. |
@laanwj - I haven't tried the scripts yet but I think macdeploy's libraries all support Py3. It looks like there are three external packages: biplist, ds_store, and mac_alias. The commit lists seem to indicate that there's a reasonable chance all of them have Py3 support, or at least enough to get macdeploy to run. I'll give macdeploy a spin soon and submit upstream patches if necessary. EDIT: Wrong biplist link. |
We are still patching biplist and mac_alias, so you could definitely send those patches upstream. |
OTOH the situation of having some things work in py2 but not others is confusing. It doesn't really benefit anyone, and there's also an overhead explaining it to contributors. That's one argument for doing this at once.
|
@fanquake - Yep, mac_alias doesn't have those fixes. I'll submit upstream. I'll also try with biplist but I don't know how that'll go, since it's not a Py3 fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK bbe67bdd82925cc72a868bb3de1896e61cae79db. Since this marked WIP, it might be good to update the PR description to say what other changes are underway or planned.
contrib/devtools/optimize-pngs.py
Outdated
@@ -37,7 +37,7 @@ def content_hash(filename): | |||
for file in os.listdir(absFolder): | |||
extension = os.path.splitext(file)[1] | |||
if extension.lower() == '.png': | |||
print("optimizing "+file+"..."), | |||
print("optimizing "+file+"...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing comma in python2 outputs space instead of newline. I think equivalent in python3 would be
print("optimizing {}...".format(file), end=' ')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this fixed?
contrib/devtools/optimize-pngs.py
Outdated
sys.exit(1) | ||
|
||
fileMetaMap['psize'] = os.path.getsize(file_path) | ||
outputArray.append(fileMetaMap) | ||
print("done\n"), | ||
print("done\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
equivalent would be print("done")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
contrib/macdeploy/macdeployqtplus
Outdated
output, unused_err = process.communicate() | ||
retcode = process.poll() | ||
if retcode: | ||
cmd = kwargs.get("args") | ||
if cmd is None: | ||
cmd = popenargs[0] | ||
raise CalledProcessError(retcode, cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just broken before, I guess? I don't see how it could have worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed
Needs rebase, I think we should do this for 0.17. |
Just for cross-referencing, the mac_alias patch made it into the mainline and was removed from Core here. I pinged the biplist maintainer. He said he'd been busy and would take a look at my PR eventually. |
@laanwj Excellent! Let's get rid of Python 2! |
Hi. Andrew (the biplist maintainer) reviewed the Core patch and rejected it. Here's his rationale. Any thoughts? I admit that I'm not super familiar with the biplist codebase, so it would take a little time for me to come up with a coherent response. (Technically, this isn't a Py3 issue, but since I brought it up here earlier....)
EDIT 1: I think the "two changes" comment had to do with this commit, which is the 1.0.2 commit that supposedly adds sorting. EDIT 2: biplist has been sorted out. |
bbe67bd
to
3b1467c
Compare
Rebased and addressed @ryanofsky's review comments.
This is marked as WIP since I was looking for initial feedback and haven't tested or carefully reviewed my suggested changes. Since there seems to be some enthusiasm for removing python2 support, I'll clean this PR up. |
Concept ACK |
8096152
to
4f32382
Compare
Concept ACK. wrt the comments from @droark, it's easy to wrap iterator types using |
utACK 4f3238250bc01eedee7c60b4d6681d3e21c6783c. Changes since last review were porting |
utACK 4f3238250bc01eedee7c60b4d6681d3e21c6783c |
@@ -203,7 +202,7 @@ def getFrameworks(binaryPath, verbose): | |||
if verbose >= 3: | |||
print("Inspecting with otool: " + binaryPath) | |||
otoolbin=os.getenv("OTOOL", "otool") | |||
otool = subprocess.Popen([otoolbin, "-L", binaryPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |||
otool = subprocess.Popen([otoolbin, "-L", binaryPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) | |||
o_stdout, o_stderr = otool.communicate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You changed this to universal_newlines
, so the type should be str
.
Thus, the decode
a couple of lines down will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fixed
huh. That's confusing. All the other calls to |
@ken2812221 thanks for reporting this. Can you try again with https://github.com/jnewbery/bitcoin/tree/python3_fixup and let me know if it resolves your issue? |
@jnewbery After apply your commit + make -j4 -C src check-security make: Entering directory `/home/ubuntu/build/bitcoin/distsrc-i686-w64-mingw32/src' Checking binary security... Traceback (most recent call last): File "../contrib/devtools/security-check.py", line 201, in if not func(filename): File "../contrib/devtools/security-check.py", line 144, in check_PE_DYNAMIC_BASE (arch,bits) = get_PE_dll_characteristics(executable) File "../contrib/devtools/security-check.py", line 133, in get_PE_dll_characteristics arch = tokens[1].rstrip(',') TypeError: 'str' does not support the buffer interface make: *** [check-security] Error 1 make: Leaving directory `/home/ubuntu/build/bitcoin/distsrc-i686-w64-mingw32/src' |
It also fails on building linux |
Thanks @ken2812221 . I've pushed a new commit. Can you retry? |
+ make -j4 -C src check-security make: Entering directory `/home/ubuntu/build/bitcoin/distsrc-i686-w64-mingw32/src' Checking binary security... Traceback (most recent call last): File "../contrib/devtools/security-check.py", line 192, in etype = identify_executable(filename) File "../contrib/devtools/security-check.py", line 182, in identify_executable if magic.startswith('MZ'): TypeError: startswith first arg must be bytes or a tuple of bytes, not str make: *** [check-security] Error 1 make: Leaving directory `/home/ubuntu/build/bitcoin/distsrc-i686-w64-mingw32/src' |
New branch pushed. Can you try again? |
pngCrushOutput = subprocess.check_output( | ||
[pngcrush, "-brute", "-ow", "-rem", "gAMA", "-rem", "cHRM", "-rem", "iCCP", "-rem", "sRGB", "-rem", "alla", "-rem", "text", file_path], | ||
stderr=subprocess.STDOUT).rstrip('\n') | ||
subprocess.call([pngcrush, "-brute", "-ow", "-rem", "gAMA", "-rem", "cHRM", "-rem", "iCCP", "-rem", "sRGB", "-rem", "alla", "-rem", "text", file_path], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post-merge nit: Should probably use check_call
instead.
Building windows is OK, but buiding linux still fail at check-symbols as I post on gist |
Please retry check-symbols.py with latest commit. |
This commit really works. Thanks.
John Newbery <notifications@github.com> 於 2018年3月29日 週四 上午5:00 寫道:
… Please retry check-symbols.py with latest commit.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11881 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKoyxmr-s3wbujdQem_HsInxNN1Agzk7ks5ti_nagaJpZM4Q_imm>
.
|
@ken2812221 , thanks so much for your patience and help here. I've opened a PR to fix symbol-check and security-check: #12829 |
Goodbye Python 2. Welcome Python 3! |
f50975b [contrib] fixup symbol-check.py Python3 support (John Newbery) 5de2b18 [contrib] fixup security-check.py Python3 support (John Newbery) Pull request description: security-check.py and symbol-check.py were broken by #11881. Fix them. Tree-SHA512: 86de3d6dc3292b1ae4cc04c2d7d7dbbf39c9270551d7b224b8d8b19e3184c30c897dbf823200403706d06bb405c0decad5cfd690cb2c0312992a235a4ffcf6bf
1874058 Make base58 python contrib code work with python3 (Evan Klitzke) bc6fdf2 Change all python files to use Python3 (John Newbery) Pull request description: Following discussion here: bitcoin#11843 (comment) It's easier for maintainers if all python tools/scripts support only a single version of Python. There are only a few scripts that aren't explicitly python3 at this point, so this PR changes those remaining scripts to explicitly require python3. Tree-SHA512: 5d38eef6e0fc7d8515e23a1f4c75e8b4160fd0fe23cba52a1f41689b114e54a9e503e0724829e8b41982ef98f2d113df80d9e238213b74f09ceaed0344a19e24
f50975b [contrib] fixup symbol-check.py Python3 support (John Newbery) 5de2b18 [contrib] fixup security-check.py Python3 support (John Newbery) Pull request description: security-check.py and symbol-check.py were broken by bitcoin#11881. Fix them. Tree-SHA512: 86de3d6dc3292b1ae4cc04c2d7d7dbbf39c9270551d7b224b8d8b19e3184c30c897dbf823200403706d06bb405c0decad5cfd690cb2c0312992a235a4ffcf6bf
* Merge bitcoin#11881: Remove Python2 support 1874058 Make base58 python contrib code work with python3 (Evan Klitzke) bc6fdf2 Change all python files to use Python3 (John Newbery) Pull request description: Following discussion here: bitcoin#11843 (comment) It's easier for maintainers if all python tools/scripts support only a single version of Python. There are only a few scripts that aren't explicitly python3 at this point, so this PR changes those remaining scripts to explicitly require python3. Tree-SHA512: 5d38eef6e0fc7d8515e23a1f4c75e8b4160fd0fe23cba52a1f41689b114e54a9e503e0724829e8b41982ef98f2d113df80d9e238213b74f09ceaed0344a19e24 * Merge bitcoin#12829: Python3 fixup f50975b [contrib] fixup symbol-check.py Python3 support (John Newbery) 5de2b18 [contrib] fixup security-check.py Python3 support (John Newbery) Pull request description: security-check.py and symbol-check.py were broken by bitcoin#11881. Fix them. Tree-SHA512: 86de3d6dc3292b1ae4cc04c2d7d7dbbf39c9270551d7b224b8d8b19e3184c30c897dbf823200403706d06bb405c0decad5cfd690cb2c0312992a235a4ffcf6bf
fa0f92a build: depends: Switch to python3 (MarcoFalke) Pull request description: Actually try to switch to python3 after the incomplete attempts: * Remove Python2 support bitcoin#11881 * build: Require python 3.5 bitcoin#14954 * ... Tree-SHA512: ba689c3788f2dd91c15d4ff5f6a73219c1a73893c18d3bb8e6da5c35acfef9897c7e100439ce5cac05624c66f7619d13528b60065c36545608fb387aab25e117
* Merge bitcoin#11881: Remove Python2 support 1874058 Make base58 python contrib code work with python3 (Evan Klitzke) bc6fdf2 Change all python files to use Python3 (John Newbery) Pull request description: Following discussion here: bitcoin#11843 (comment) It's easier for maintainers if all python tools/scripts support only a single version of Python. There are only a few scripts that aren't explicitly python3 at this point, so this PR changes those remaining scripts to explicitly require python3. Tree-SHA512: 5d38eef6e0fc7d8515e23a1f4c75e8b4160fd0fe23cba52a1f41689b114e54a9e503e0724829e8b41982ef98f2d113df80d9e238213b74f09ceaed0344a19e24 * Merge bitcoin#12829: Python3 fixup f50975b [contrib] fixup symbol-check.py Python3 support (John Newbery) 5de2b18 [contrib] fixup security-check.py Python3 support (John Newbery) Pull request description: security-check.py and symbol-check.py were broken by bitcoin#11881. Fix them.
1874058 Make base58 python contrib code work with python3 (Evan Klitzke) bc6fdf2 Change all python files to use Python3 (John Newbery) Pull request description: Following discussion here: bitcoin#11843 (comment) It's easier for maintainers if all python tools/scripts support only a single version of Python. There are only a few scripts that aren't explicitly python3 at this point, so this PR changes those remaining scripts to explicitly require python3. Tree-SHA512: 5d38eef6e0fc7d8515e23a1f4c75e8b4160fd0fe23cba52a1f41689b114e54a9e503e0724829e8b41982ef98f2d113df80d9e238213b74f09ceaed0344a19e24
1874058 Make base58 python contrib code work with python3 (Evan Klitzke) bc6fdf2 Change all python files to use Python3 (John Newbery) Pull request description: Following discussion here: bitcoin#11843 (comment) It's easier for maintainers if all python tools/scripts support only a single version of Python. There are only a few scripts that aren't explicitly python3 at this point, so this PR changes those remaining scripts to explicitly require python3. Tree-SHA512: 5d38eef6e0fc7d8515e23a1f4c75e8b4160fd0fe23cba52a1f41689b114e54a9e503e0724829e8b41982ef98f2d113df80d9e238213b74f09ceaed0344a19e24
Following discussion here: #11843 (comment)
It's easier for maintainers if all python tools/scripts support only a single version of Python. There are only a few scripts that aren't explicitly python3 at this point, so this PR changes those remaining scripts to explicitly require python3.