Skip to content
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

Should we drop legacy Python? #2093

Closed
cclauss opened this issue Apr 7, 2020 · 11 comments
Closed

Should we drop legacy Python? #2093

cclauss opened this issue Apr 7, 2020 · 11 comments
Labels

Comments

@cclauss
Copy link
Contributor

cclauss commented Apr 7, 2020

Python 2 is no longer supported by the Python Development Team. Should we drop it as well?

@cclauss cclauss added the Python label Apr 7, 2020
@cclauss cclauss assigned cclauss and unassigned cclauss Apr 7, 2020
@rvagg
Copy link
Member

rvagg commented Apr 7, 2020

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?

@cclauss
Copy link
Contributor Author

cclauss commented Apr 7, 2020

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.

@rvagg
Copy link
Member

rvagg commented Apr 7, 2020

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?

@rrrix
Copy link

rrrix commented May 4, 2020

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:

  1. Only worry about supporting Python 2.7
  2. Make sure you have good test coverage (coverage.py can help; python -m pip install coverage)
  3. Learn the differences between Python 2 & 3
  4. Use Futurize (or Modernize) to update your code (e.g. python -m pip install future)
  5. Use Pylint to help make sure you don’t regress on your Python 3 support (python -m pip install pylint)
  6. Use caniusepython3 to find out which of your dependencies are blocking your use of Python 3 (python -m pip install caniusepython3)
  7. 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)
  8. 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!)

@cclauss
Copy link
Contributor Author

cclauss commented May 4, 2020

macOS Catalina ships with a python3 executable because Python 2 died on 1/1/2020.

@rvagg
Copy link
Member

rvagg commented May 5, 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.

@Archloy
Copy link

Archloy commented May 13, 2020

And a Python 3 compatibility "only" ? Did anyone already try to do that ?

@cclauss
Copy link
Contributor Author

cclauss commented May 13, 2020

Yes.

@jkomyno
Copy link

jkomyno commented May 13, 2020

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

@owl-from-hogvarts
Copy link
Contributor

Have we already remove support of python 2? If so, can this issue be closed?

@richardlau
Copy link
Member

#2300 dropped support for Python 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants