Python 2 is no longer supported by the Python Development Team. Should we drop it as well?
I don't know .. it'd be interesting to know the state of Python 3 on the main platforms where Node.js is deployed. Is it universally installed by default now on those? Even CentOS 7 and Ubuntu 16.04?
CentOS 7 ships with an unsafe 2.7.5 which should at a minimum be upgraded to Py2.7.9 for security reasons. Py3 upgrade is https://linuxize.com/post/how-to-install-python-3-on-centos-7
https://wiki.ubuntu.com/Python Ubuntu 16.04 comes with both Python 2.7 and Python 3.5 by default.
Well, while we're breaking stuff for node-gyp 7 we could certainly bundle this in too. I think I'd defer to you on this choice if you think it's safe enough on common platforms.
Anyone else?
Random internet user here. MacOS still ships with Python 2.7.16. Removing support for Python 2 would require your users to first download and install Python3 in some manner. That would suck (IMHO).
I would add that you should follow this guidance specifically, if you aren't already: https://docs.python.org/dev/howto/pyporting.html
That is - aim for Python2/3 compatibility so it works on both:
The Short Explanation
To make your project be single-source Python 2/3 compatible, the basic steps are:
- Only worry about supporting Python 2.7
- Make sure you have good test coverage (coverage.py can help; python -m pip install coverage)
- Learn the differences between Python 2 & 3
- Use Futurize (or Modernize) to update your code (e.g. python -m pip install future)
- Use Pylint to help make sure you don鈥檛 regress on your Python 3 support (python -m pip install pylint)
- Use caniusepython3 to find out which of your dependencies are blocking your use of Python 3 (python -m pip install caniusepython3)
- Once your dependencies are no longer blocking you, use continuous integration to make sure you stay compatible with Python 2 & 3 (tox can help test against multiple versions of Python; python -m pip install tox)
- Consider using optional static type checking to make sure your type usage works in both Python 2 & 3 (e.g. use mypy to check your typing under both Python 2 & Python 3; python -m pip install mypy).
Essentially, you can _target_ Python 3 while making it (mostly) backwards compatible with Python 2.7. Anything older than 2.7 is ancient, hasn't been supported in many years, and should be avoided accordingly.
I'd be very curious to see if any dependencies used in the project aren't already supported by Python3, which is likely the only major blocker you'll have in the process of converting to target py3. Futurize goes a _very_ long way to getting to python3 support.
The biggest consideration to completely dropping support of Python2 shouldn't necessarily be "is it still actively supported", but rather if the project needs to _use features_ exclusive to Python3 - things like asyncio or dataclasses or any of the newer PEPs.
Your users (like me) won't care if you use the latest python3 bells and whistles, but will definitely care if you break their applications and tooling on their current OS's which are still distributed with Python2 (again, like MacOS!)
macOS Catalina ships with a python3 executable because Python 2 died on 1/1/2020.
I think this chart holds _some_ answers: https://gs.statcounter.com/macos-version-market-share/desktop/worldwide
Interestingly it doesn't look like Catalina adoption is slower than previous versions (anecdotally I would have thought it would be!).
You also have to consider the target audience here: almost entirely developers, who are (a) more likely to have the latest of something (although my anecdotes come into play here because I know a lot of devs who still haven't adopted Catalina) and (b) quite capable and not too uncomfortable installing newer versions of dependencies when they're clearly made aware of the need.
And a Python 3 compatibility "only" ? Did anyone already try to do that ?
Yes.
I would definitely drop Python 2 as well as old Node versions as mentioned in #1945. It's reasonable to think that those who don't want to upgrade their Python and Node distributions, won't upgrade node-gyp as well anyway