darling
darling copied to clipboard
Migrate from `python2` to `python3`
Considering that the support of Python 2 by the Python Foundation was ended at 2020-01-01, and some platforms like Nixpkgs are planning to drop the Python 2 support (NixOS/nixpkgs #148779). It would be a good idea to migrate to Python 3, or use PyPy2 instead.
https://www.python.org/doc/sunset-python-2/
Well, we can't just drop Python 2 support. I agree that Python 2 should be long gone by now, but as long as macOS supports it, Darling has to support it as well. Actually, even if macOS were to drop Python 2 support, we would probably want to keep supporting it for backwards compatibility.
As for distros removing Python 2, Darling really only needs the host system's Python 2 at build time in order to precompile the Python 2 sources included in Darling. At runtime, the Python 2 used is the one built with Darling, not the host's Python 2. All we really need from the host's Python 2 is pyc
compilation. I prefer if they're generated from source at build time; however, if there's no other choice, we could precompile the pyc
files ourselves and include them in a Git repo (like we do for the Swift libraries).
As far as I know, PyPy2 should run the build scripts just fine as long as they are in pure Python (with no third-party, C-binded modules). It would be great if there's an option to specify the build-time Python interpreter being used. Nevertheless, is there a special reason why to keep the build scripts in Python 2 instead of Python 3?
As for pyc
compilation, PyPy2 inherently produces different result than CPython does. It sounds like a good idea for those *.pyc
bytecodes to be included in the source code (along with some bootstrapping instructions).
For the difference between CPython and PyPy, this article might help: https://doc.pypy.org/en/latest/cpython_differences.html