Skip to content

Migrate all scripts, symlinks, and installed tools to Python3 #6376

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

Closed
earlephilhower opened this issue Aug 2, 2019 · 2 comments · Fixed by #6378
Closed

Migrate all scripts, symlinks, and installed tools to Python3 #6376

earlephilhower opened this issue Aug 2, 2019 · 2 comments · Fixed by #6378

Comments

@earlephilhower
Copy link
Collaborator

Python 2 has less than 5 months left to live (or at least, until all support ends)
https://pythonclock.org/

#6364 had an issue with a symlink to Python 2 being installed in the tools directory, which is one part but not all.

We need to:
. Update all script refs from /usr/bin/python to /usr/bin/python3
. Update the tools python-wrapper.tgz to point to python3
. Update the Windows standalone installation to python3
. Update platform.txt/etc. to ensure it's using the right python verison
. Validate things still work.

It's not as simple as changing scripts to #/usr/bin/env python, either, as that only works if there is a Python2 installation somewhere. Newer OS releases may not install Python2 by default.

@TD-er
Copy link
Contributor

TD-er commented Aug 3, 2019

And what about using virtualenv as wrapper?
Then you can also have a very well contained set of included libraries.
Not sure how easy virtualenv is setup in all OS'es (e.g. Windows), but on Linux I use it all the time.

This also allows to create a stand-alone Python 2.7 environment if conversion takes more time than expected.

@earlephilhower
Copy link
Collaborator Author

I think the point is that Python 2.7 is dead as of January 1, 2020, so virtualenv's not really a solution. Without the python 2 executable, the virtualenv would run under the Python 3 interpreter, in fact. I don't think there's any issue with scripts we're using, they should already run fine under Py3.

The standalone Python we're using for Windows is kind of a virtualenv. We install the needed libraries right in the core directories, and it only uses PYCs from inside the installation dir, not system-wide ones (assuming there's some system-wide Python installed on the user's Windows).

earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Aug 3, 2019
Python 2 EOL is Jan 1, 2020.  Migrate scripts to run under Python 3.

Under Windows, we're already running Python 3.7, by dumb luck.  The
oddness is that the Windows standalone executable for Python 3 is called
"python" whereas under UNIX-like OSes it's called "python3" with
"python" always referring to the Python 2 executable.  The ZIP needs to
be updated to include a Python3.exe (copy of Python.exe) so that we can
use the same command lines under Linux and Windows, and to preserve my
sanity.

Fixes esp8266#6376
earlephilhower added a commit that referenced this issue Aug 28, 2019
* Move all scripts and documentation to Python3

Python 2 EOL is Jan 1, 2020.  Migrate scripts to run under Python 3.

Under Windows, we're already running Python 3.7, by dumb luck.  The
oddness is that the Windows standalone executable for Python 3 is called
"python" whereas under UNIX-like OSes it's called "python3" with
"python" always referring to the Python 2 executable.  The ZIP needs to
be updated to include a Python3.exe (copy of Python.exe) so that we can
use the same command lines under Linux and Windows, and to preserve my
sanity.

Fixes #6376

* Add new Windows ZIP with python3.exe file

* Sort options in boards.txt generation for repeatability

The order of the board opts dict changes depending on the Python version
and machine, so sort the options before printing them to get a stable
ordering.

* Re-add Python2 compatibility tweaks

Most scripts can run as Python 2 or Python 3 with minimal changes, so
re-add (and fix, as necessary) compatibility tweaks to the scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants