The minimum supported version of Python is 3.4 according to dependencies.md. This PR makes the Travis linter use this version in order to catch accidental use of modern syntax.
Travis: enforce Python 3.4 support through linter #14884
pull Sjors wants to merge 2 commits into bitcoin:master from Sjors:2018/12/python-3-4 changing 4 files +12 −3-
Sjors commented at 2:50 PM on December 6, 2018: member
- laanwj added the label Tests on Dec 6, 2018
-
practicalswift commented at 2:58 PM on December 6, 2018: contributor
Concept ACK
Good idea!
~What about bumping the requirement to 3.5 to allow for Xenial?~
-
laanwj commented at 2:59 PM on December 6, 2018: member
utACK
-
hebasto commented at 3:07 PM on December 6, 2018: member
Concept ACK
-
in .travis.yml:108 in 400a46c629 outdated
103 | @@ -104,6 +104,8 @@ jobs: 104 | BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=thread --disable-hardening --disable-asm CC=clang CXX=clang++" 105 | # x86_64 Linux (no depends, only system libs, sanitizers: address/leak (ASan + LSan) + undefined (UBSan) + integer) 106 | - stage: test 107 | + language: python 108 | + python: '3.4' # Minimum supported version according to dependencies.md
MarcoFalke commented at 4:28 PM on December 6, 2018:No idea how this is supposed to work. We run the tests in a docker, which is completely separate from the travis environment?
Sjors commented at 4:41 PM on December 6, 2018:In that case this probably won't work indeed... I thought we only used Docker on the Xenial host? I'm still waiting for Travis to build my test branch.
MarcoFalke commented at 4:46 PM on December 6, 2018:
Sjors commented at 4:48 PM on December 6, 2018:I see, trying a different approach...
MarcoFalke commented at 4:47 PM on December 6, 2018: memberI mean of course strong Concept ACK if you figure out a way to install older versions (specific versions) of packages in ubuntu.
Sjors force-pushed on Dec 6, 2018Sjors force-pushed on Dec 6, 2018Sjors renamed this:[WIP] Travis: use Python 3.4 on one instance to check support
[WIP] bump Python min version to 3.5 and enforce through Travis linter
on Dec 6, 2018Sjors force-pushed on Dec 6, 2018Sjors commented at 6:56 PM on December 6, 2018: memberThe only way to install older or newer versions of Python is through pyenv. I'd rather not add another dependency.
~Instead, a more practical solution is to bump the minimum Python version to 3.5, because our linters use that. It's available on Ubuntu Xenial, but we would lose support for (almost EOL) Trusty (Python 3.4).~
In fact,
check-doc.py,optimize-pngs.py,gitian-build.py, andverify-commits.pyrely on Python 3.6 viacheck_output(encoding='utf8'). However only a small subset of developers need those scripts. I made trivial workaround forcheck-doc.pyso Travis can use it with Python ~3.5~ 3.4, but this workaround is not safe for the other scripts, see #14128~Alternatively we could modify the linter to work with Python 3.4 syntax. I personally can't be bothered, but I'll happily cherry-pick a solution :-)~
I also added
.python-versionforpyenvwhich will cause tests with too modern syntax to fail on a developer machine before Travis. When using a script that does require Python >=3.5, you'll have to dopyenv local 3.7.1.Sjors force-pushed on Dec 6, 2018Sjors commented at 6:59 PM on December 6, 2018: member- Travis build fails if I add commit 5b742441bbc70a0b15a00d214321e79c58738395 with too modern syntax: https://travis-ci.org/bitcoin/bitcoin/jobs/464559620#L609
Sjors renamed this:[WIP] bump Python min version to 3.5 and enforce through Travis linter
Bbump Python min version to 3.5 and enforce through Travis linter
on Dec 6, 2018MarcoFalke commented at 7:02 PM on December 6, 2018: memberThe python 3.4 requirement is only for the tests, which might be run by users that compile from source. Personally I don't care about the python version of developer tools and linters and I don't mind not supporting 3.4 for those.
Sjors force-pushed on Dec 6, 2018Sjors force-pushed on Dec 6, 2018Sjors commented at 7:16 PM on December 6, 2018: member@MarcoFalke I initially thought the linter itself needed Python 3.5, but that's not true anymore. So in that case we don't have to bump the version, nice!
Travis build failure demo when you use too modern syntax: https://travis-ci.org/bitcoin/bitcoin/jobs/464581145#L609
Sjors renamed this:Bbump Python min version to 3.5 and enforce through Travis linter
Travis: enforce Python 3.4 support through linter
on Dec 6, 2018in .travis.yml:46 in bef76361ac outdated
42 | @@ -43,7 +43,7 @@ jobs: 43 | env: 44 | cache: false 45 | language: python 46 | - python: '3.6' 47 | + python: '3.4' # Oldest supported version according to doc/dependencies.md
MarcoFalke commented at 7:28 PM on December 6, 2018:Hmm, that would set the minimum version of the linters to 3.4, but not of the functional test suite. (Note that only parsing code according to 3.4 syntax does not mean it can run 3.4)
Sjors commented at 7:33 PM on December 6, 2018:The linter uses the available Python executable to lint the functional tests. It will throw an error if sees a syntax that it doesn't recognise, see above demo. So it's not necessary to run the functional tests themselves in Python 3.4, which would require adding pyenv as a dependency inside the Docker container and slow things down.
Sjors commented at 7:35 PM on December 6, 2018:Also, though hopefully not needed, any developer who uses pyenv on their machine will detect any mistake that slips through the cracks once they run the functional test suite on master.
laanwj commented at 1:59 PM on December 7, 2018: memberI would prefer having all tools work with the supported version of Python (3.4), for consistency for developers, but agree it's not urgent—having the tests pass is most important.
practicalswift commented at 2:42 PM on December 7, 2018: contributor@laanwj That's a good point. Agree.
laanwj commented at 4:34 PM on December 7, 2018: memberI agree with that too, but it's non-trivial because #14128 had to introduce Python 3.6 syntax in those tools to deal with some sort of encoding hell.
Yes, that particular functionality looks hard to replace. I didn't know that was Python 3.6 specific. (edit: whoops accidental close)
Edit: One way to handle this would be to wrap the appropriate
subprocesscalls and do the encoding magic only for 3.6, fall back to the system encoding in 3.4 so that it'd at least work. But I don't know it's worth it. At some point in the future we'll be able to bump the minimum to 3.6 and any work there will be a waste of time.laanwj closed this on Dec 7, 2018laanwj reopened this on Dec 7, 201874ce326831[test] Travis: enforce Python 3.4 support in functional tests
Make lint/check-doc.py Python 3.4 compatible. Also add .python-version for pyenv which will cause tests with too modern syntax to fail on developer machine rather than on Travis.
31926ee8cf[test] functional framework: add CScript hex() for Python 3.4
test/functional/wallet_importmulti.py failed with: AttributeError: 'CScript' object has no attribute 'hex'
Sjors force-pushed on Dec 12, 2018laanwj commented at 12:16 PM on December 13, 2018: memberutACK 31926ee8cfc73501524dfa0fef2ccbaa786d6a00
Going to merge this immediately to avoid any non-Python3.4isms from sneaking in.
laanwj merged this on Dec 13, 2018laanwj closed this on Dec 13, 2018laanwj referenced this in commit 84dc252a02 on Dec 13, 2018in .python-version:1 in 31926ee8cf
0 | @@ -0,0 +1 @@ 1 | +3.4.9
jnewbery commented at 3:30 PM on December 13, 2018:Does pyenv allow you to comment this file? It's not immediately obvious that this is for pyenv, how it's supposed to work, or when we should update this.
Sjors commented at 5:52 PM on December 13, 2018:I'll look into that. At least you can find out via git-blame :-P
jnewbery commented at 3:31 PM on December 13, 2018: memberutACK 31926ee8cfc73501524dfa0fef2ccbaa786d6a00. One request inline.
Thanks for catching my
hex()mistake!Sjors deleted the branch on Dec 13, 2018MarcoFalke referenced this in commit 391a27376b on Jan 15, 2019MarcoFalke referenced this in commit 33480c6366 on Feb 14, 2019PastaPastaPasta referenced this in commit c0ec92e9e2 on Jun 26, 2021PastaPastaPasta referenced this in commit 2ee07e0da2 on Jun 27, 2021PastaPastaPasta referenced this in commit 89972eeca7 on Jun 28, 2021PastaPastaPasta referenced this in commit 97e53da21d on Jun 28, 2021PastaPastaPasta referenced this in commit 589bbc9166 on Jun 29, 2021linuxsh2 referenced this in commit f273da1c2a on Jul 29, 2021linuxsh2 referenced this in commit d70d401c72 on Aug 3, 2021DrahtBot locked this on Dec 16, 2021
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 09:15 UTC
More mirrored repositories can be found on mirror.b10c.me