You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Migrate Python dependency From Python 2 to Python 3 #20585
Python 2 is being deprecated by Debian and Ubuntu, in favor of Python 3, in a move toward not shipping Python 2 at all. (Python 2 is already End-Of-Life'd by the Python maintainers*). In the long term, it will help Atom stay installable/working on these distros to specify a Python 3 dependency (in addition to or instead of Python 2). Even longer-term, Python 2 will no-longer be available, so it will make sense to drop it entirely. If Python 2 gives Atom any trouble in the medium-term, it can simply be dropped.
Motivation
Doing this keeps Atom installable and working on newer distros/operating systems.
Furthermore, making sure the build process doesn't require Python 2 makes it easy to continue building Atom once Python 2 is End-of-Life'd.
Describe alternatives you've considered
Un-bundle node-gyp and remove any other usage of Python from within this package.
OR: Allow users to install Atom on all platforms without requiring Python on their system.
Additional context
According to this comment, Python is only needed for node-gyp.
Furthermore: the default package manager for Fedora, dnf, is written in Python. Python 3 is installed out-of-the-box on recent Fedora, and can't be uninstalled, because dnf refuses to uninstall itself (or by extension, its own dependencies). So we can pretty safely assume Python 3 is available on supported Fedora releases.
I found a sort of "minimal reproducer" to invoke usage of Python.
First, have atom installed.
Then, run apm install tree-view.
(This is just an arbitrary, well-known package that happens to activate gyp when being built/installed.)
This will error out if your python setup is inadequate for running gyp, with an error like this:
gyp ERR! stack Error: Python executable "/usr/share/atom/resources/app/apm/bin/python-interceptor.sh" is v3.8.2, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
$ apm install tree-view
The tree-view package is bundled with Atom and should not be explicitly installed.
You can run `apm uninstall tree-view` to uninstall it and then the version bundled
with Atom will be used.
Installing tree-view to /home/[user]/.atom/packages ✗
> pathwatcher@8.1.0 install /tmp/apm-install-dir-12033-11366-ljo9wx.osrxt/node_modules/tree-view/node_modules/pathwatcher
> node-gyp rebuild
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/share/atom/resources/app/apm/bin/python-interceptor.sh -c import platform; print(platform.python_version());
gyp ERR! stack /usr/share/atom/resources/app/apm/bin/python-interceptor.sh: line 40: exec: python: not found
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:291:12)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at maybeClose (internal/child_process.js:961:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:380:11)
gyp ERR! stack at Socket.emit (events.js:182:13)
gyp ERR! stack at Pipe._handle.close [as _onclose] (net.js:596:12)
gyp ERR! System Linux 5.4.0-21-generic
gyp ERR! command "/usr/share/atom/resources/app/apm/bin/node" "/usr/share/atom/resources/app/apm/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/apm-install-dir-12033-11366-ljo9wx.osrxt/node_modules/tree-view/node_modules/pathwatcher
gyp ERR! node -v v10.2.1
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/tmp/apm-install-dir-12033-11366-ljo9wx.osrxt/package.json'
npm WARN apm-install-dir-12033-11366-ljo9wx.osrxt No description
npm WARN apm-install-dir-12033-11366-ljo9wx.osrxt No repository field.
npm WARN apm-install-dir-12033-11366-ljo9wx.osrxt No README data
npm WARN apm-install-dir-12033-11366-ljo9wx.osrxt No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pathwatcher@8.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pathwatcher@8.1.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/[user]/.atom/.apm/_logs/2020-04-03T16_22_59_288Z-debug.log
`atom --version` output (click to expand)
$ atom --version
Atom : 1.45.0
Electron: 4.2.7
Chrome : 69.0.3497.128
Node : 10.11.0
Short summary: We need newer node-gyp. (The current dependencies for atom include a version of node-gyp that is too old to support Python 3.)
I get the impression that Python really is only needed for apm, which in turn only needs it for node-gyp.
(If anyone knows this to be wrong, please do let me know/post a correction in this issue! It's a critical assumption I'm making, in order to narrow down the path forward toward get atom migrated fully to Python 3.)
apm bundles its own node and npm versions. (apm depends on a pinned npm version.) npm in turn depends on a version range of node-gyp.
There is a sort of "dependency chain" beyond the atom repo that must be traversed, making sure the whole chain supports Python 3:
atom > apm > npm > node-gyp
These are some pretty old bundled versions.
apm specified in the master branch of the atom repo is currently apm@2.4.5.
In the next link of the chain, apm@2.4.5 (and apm's master branch on GitHub) specify npm@6.2.0
Meanwhile, at the last link of the chain, node-gyp only works with python3 "by default" (without an "experimental" CLI flag used) starting with version 6.0: https://github.com/nodejs/node-gyp/blob/master/CHANGELOG.md#v600-2019-10-04 [Edit: Or the latest 5.x series release, 5.1.0. This has Python 3 support backported.]
Edit: npm 6.14.2 or newer depends on node-gyp 5.1.0, which has Python 3 support backported. We should depend on npm 6.14.2 or newer in apm.
Bottom line: We need newer node-gyp that supports Python 3.
I believe that PR is already working, but the tests at that repo need updating if the PR is going to pass tests/CI.
(Regarding my previous comment: This seems easier to solve than I had assumed. The only thing required at the apm repo turned out to be bumping npm.
Background info:
The latest npm releases, as it turns out, already depend on node-gyp new enough to support python3. See: npm/cli#927 and npm/cli#771
More background on node-gyp Python 3 support: Crucially, node-gyp 5.1.0 was released after the most recent node-gyp 6.x release. 5.1.0 also supports Python 3. It's just different from node-gyp 6.x in that 5.1.0 uses python2 preferentially over python3 in some cases. (node-gyp 6.x prefers python3 in those cases.) The PR I linked to at the beginning of this comment upgrades apm's npm dependency to a version that depends on node-gyp 5.1.0... So the only thing required at apm turned out to be bumping npm. And... updating the CI tests at that repo. The only thing required at this repo, then, would be bumping apm to a new version once atom/apm#875 or similar lands at apm.)
By the way, none of the other platforms' Atom installers appear to require Python in any way, shape or form. They install even if there is no Python on your system.
Only the Debian/Ubuntu (.deb) packages seem to "require" a Python dependency.
Edit to add: Not having Python on the system presumably breaks apm... Maybe the installers for other platforms bundle a Python interpreter? I know macOS ships with Python (2.7.x still!!!!), so it probably isn't needed there. And Fedora, well... Fedora ships with Python 3... Hmm. (apm would probably be broken by default on Fedora, then?) But I'm not aware what is being done for Windows.
Can confirm the Windows packaging doesn't include Python.
Zipped apm apm -v:
C:\Users\[User]\Downloads\atom-x64-windows\Atom x64\resources\cli>.\apm.cmd -v
apm 2.4.3
npm 6.2.0
node 10.2.1 x64
atom 1.45.0
python
git
visual studio
Error message when trying to apm install tree-view (no Python):
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
Full error message (click to expand):
C:\Users\[User]\Downloads\atom-x64-windows\Atom x64\resources\cli>.\apm.cmd install tree-view
The tree-view package is bundled with Atom and should not be explicitly installed.
You can run `apm uninstall tree-view` to uninstall it and then the version bundled
with Atom will be used.
Installing tree-view to C:\Users\[User]\.atom\packages failed
> pathwatcher@8.1.0 install C:\Users\[User]\AppData\Local\Temp\apm-install-dir-120318-4456-jo76ma.jg0c\node_modules\tree-view\node_modules\pathwatcher
> node-gyp rebuild
C:\Users\[User]\AppData\Local\Temp\apm-install-dir-120318-4456-jo76ma.jg0c\node_modules\tree-view\node_modules\pathwatcher>if not defined npm_config_node_gyp (node "C:\Users\[User]\Downloads\atom-x64-windows\Atom x64\resources\app\apm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Users\[User]\Downloads\atom-x64-windows\Atom x64\resources\app\apm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (C:\Users\[User]\Downloads\atom-x64-windows\Atom x64\resources\app\apm\node_modules\npm\node_modules\node-gyp\lib\configure.js:492:19)
gyp ERR! stack at PythonFinder.<anonymous> (C:\Users\[User]\Downloads\atom-x64-windows\Atom x64\resources\app\apm\node_modules\npm\node_modules\node-gyp\lib\configure.js:517:16)
gyp ERR! stack at C:\Users\[User]\Downloads\atom-x64-windows\Atom x64\resources\app\apm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:182:21)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Users\\[User]\\Downloads\\atom-x64-windows\\Atom x64\\resources\\app\\apm\\bin\\node.exe" "C:\\Users\\[User]\\Downloads\\atom-x64-windows\\Atom x64\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\[User]\AppData\Local\Temp\apm-install-dir-120318-4456-jo76ma.jg0c\node_modules\tree-view\node_modules\pathwatcher
gyp ERR! node -v v10.2.1
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\[User]\AppData\Local\Temp\apm-install-dir-120318-4456-jo76ma.jg0c\package.json'
npm WARN apm-install-dir-120318-4456-jo76ma.jg0c No description
npm WARN apm-install-dir-120318-4456-jo76ma.jg0c No repository field.
npm WARN apm-install-dir-120318-4456-jo76ma.jg0c No README data
npm WARN apm-install-dir-120318-4456-jo76ma.jg0c No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pathwatcher@8.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pathwatcher@8.1.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\[User]\.atom\.apm\_logs\2020-04-18T17_22_03_188Z-debug.log
Installed apm apm -v:
C:\Users\[User]\AppData\Local\atom\app-1.45.0\resources\cli>.\apm.cmd -v
apm 2.4.3
npm 6.2.0
node 10.2.1 x64
atom 1.45.0
python
git
visual studio
Installed apm, error message when doing apm install tree-view:
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
Full error message (click to expand):
C:\Users\[User]\AppData\Local\atom\app-1.45.0\resources\cli>.\apm.cmd install tree-view
The tree-view package is bundled with Atom and should not be explicitly installed.
You can run `apm uninstall tree-view` to uninstall it and then the version bundled
with Atom will be used.
Installing tree-view to C:\Users\[User]\.atom\packages failed
> pathwatcher@8.1.0 install C:\Users\[User]\AppData\Local\Temp\apm-install-dir-120318-16440-ycddwg.rtoo\node_modules\tree-view\node_modules\pathwatcher
> node-gyp rebuild
C:\Users\[User]\AppData\Local\Temp\apm-install-dir-120318-16440-ycddwg.rtoo\node_modules\tree-view\node_modules\pathwatcher>if not defined npm_config_node_gyp (node "C:\Users\[User]\AppData\Local\atom\app-1.45.0\resources\app\apm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Users\[User]\AppData\Local\atom\app-1.45.0\resources\app\apm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (C:\Users\[User]\AppData\Local\atom\app-1.45.0\resources\app\apm\node_modules\npm\node_modules\node-gyp\lib\configure.js:492:19)
gyp ERR! stack at PythonFinder.<anonymous> (C:\Users\[User]\AppData\Local\atom\app-1.45.0\resources\app\apm\node_modules\npm\node_modules\node-gyp\lib\configure.js:517:16)
gyp ERR! stack at C:\Users\[User]\AppData\Local\atom\app-1.45.0\resources\app\apm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:182:21)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Users\\[User]\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\bin\\node.exe" "C:\\Users\\[User]\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\[User]\AppData\Local\Temp\apm-install-dir-120318-16440-ycddwg.rtoo\node_modules\tree-view\node_modules\pathwatcher
gyp ERR! node -v v10.2.1
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\[User]\AppData\Local\Temp\apm-install-dir-120318-16440-ycddwg.rtoo\package.json'
npm WARN apm-install-dir-120318-16440-ycddwg.rtoo No description
npm WARN apm-install-dir-120318-16440-ycddwg.rtoo No repository field.
npm WARN apm-install-dir-120318-16440-ycddwg.rtoo No README data
npm WARN apm-install-dir-120318-16440-ycddwg.rtoo No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pathwatcher@8.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pathwatcher@8.1.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\[User]\.atom\.apm\_logs\2020-04-18T17_54_02_053Z-debug.log
Miscellaneous note: I also noticed a package that won't install without Git on the system.
Installing “ide-rust@0.21.2” failed. [Hide output…]
Failed to install ide-rust because Git was not found.
The ide-rust package has module dependencies that cannot be installed without Git.
You need to install Git and add it to your path environment variable in order to install this package.
You can install Git by downloading, installing, and launching GitHub for Windows: https://windows.github.com
Run apm -v after installing Git to see what version has been detected.
Final note: many packages can be successfully installed without using node-gyp (and thus Python) nor using Git, so there is some lee-way regarding if either of those should be bundled, or if they should be considered install-time dependencies at all. Maybe bundling or requiring Python on the system at install-time for Atom is heavy-handed?
I have had the chance to confirm the macOS app doesn't bundle Python with it, nor does it seem to check whether there is a certain version of Python on the system.
So that leaves the Debian/Ubuntu (.deb) package as the only one currently specifying a Python dependency.
As mentioned in the other thread, IMO this could be made an optional dependency, or dropped, in the .deb package.
Regarding Fedora: I found that the current apm with old node-gyp is unlikely to work, broadly speaking, on modern Fedora.
Python 3 is the default python there; To use apm on Fedora 31, one has to remove the symlink from python -> python3, and then manually symlink python -> python2. There is no package that does this for you (unlike on Ubuntu 20.04 or Debian Buster), so it has to be done by hand.
IMO, the elegant solution (good for all OSes) is to support both Python 2 and Python 3 in apm. Once again, see: atom/apm#875
Until then there is no packaging we can do to have apm work out of the box on Fedora. (As far as I can tell.)
Update: There are a few smaller things left to do, actually.
Some of these things are beyond my skill level at the moment (particularly, I'm struggling with asynchronous Javascript/race conditions, and I don't know how to use callbacks properly at the moment), but I'll get to them as and when I get the time. (Starting with the ones I know how to fix, like simple documentation updates...) Help wanted/would be much appreciated!
Actually, I did find some parts of this repo that could be updated to reflect Python 3. Here are my findings looking at all files that mention "python" (case-insensitive search):
Not related to actual use of the python interpreter/executable by Atom (so, no changes needed):
Click to expand.
CONTRIBUTING.md (A sentence from this documentation file refers to hypothetically editing a Python source file, as an example of context you might want to include in a bug report if that's when a bug happens.)
docs/build-instructions/build-status.md (A line shows the build status of language-python, a package that "Adds syntax highlighting and snippets to Python files in Atom.")
(all of the above are fancy CSS stylesheets having to do with syntax highlighting for Python.)
resources/mac/atom-Info.plist (Appears to inform macOS that Atom is a good program to open Python source files with... I understand this would be for editing, not running said Python files.)
script/deprecated-packages.json (A json array listing some old deprecated packages, some of which have "python" in the name.)
script/license-overrides.js (Some package named JSChardet, which is a "Port of python's chardet")
spec/helpers/words.js (A long list of English-language words. One of which is the word "python", as in literally the type of snake. Not related to the programming language whatsoever. Test-related, not used in the final Atom product.)
spec/tree-sitter-language-mode-spec.js (language-python and tree-sitter-python again. Test-related anyhow, not built/used in the final Atom product for end-users.)
src/deprecated-syntax-selectors.js (Another list of old, deprecated packages, two of which are called python and python-function, respectively.)
Actually related to python usage (with suggested changes):
README.md (A line of this documentation file suggests installing the versionless python package on Ubuntu. Maybe this should be updated to suggest python3 or python2 if python isn't available.)
resources/linux/debian/control.in (versionless python dependency in the .deb package for Debian/Ubuntu of Atom. Debating whether to drop this/make it optional, update it, etc.)
resources/linux/debian/lintian-overrides (This is just metadata for a linter (lintian) that checks for common issues with .deb packages. But it's a very "sensitive" linter and IMO has lots of false positives/noise. No-one has been running this linter apparently, so maybe remove the metadata for it?)
script/lib/verify-machine-requirements.js (build-time script that appears to check for Python on the system in a way that isn't python3-aware, or ready for the split of python into python2 and python3 on Linux. Should probably be updated.)
script/vsts/platforms/windows.yml (vsts = "Visual Studio Team System"? aka Azure DevOps Server? This seems to be the CI configuration file for the project, specifically the configuration for the "Windows" tests. This hard-codes that the build should use Python 2.7... maybe consider also testing on Python 3? Or updating to just use Python 3?)
Not super important, arguably, since it is upstream node-gyp's responsibility to continue to support Python 2 and 3 properly. Continuing to test against just Python 2 could be okay, I suppose.
Update: For Ubuntu 20.10As of Ubuntu 19.10, Canonical have moved every form of Python 2 to the "universe" component of the repositories. (Meaning, "community-maintained," as opposed to "Canonical-supported" -- Canonical being the company that runs Ubuntu. Per: https://help.ubuntu.com/community/Repositories/Ubuntu)
Tried to install Python 2 in an Ubuntu 20.10 VM (click to expand).
None of these can be installed anymore:
ubuntu@ubuntu:~$ sudo apt updateIgn:1 cdrom://Ubuntu 20.10 _Groovy Gorilla_ - Alpha amd64 (20200527) groovy InReleaseHit:2 cdrom://Ubuntu 20.10 _Groovy Gorilla_ - Alpha amd64 (20200527) groovy ReleaseGet:3 http://archive.ubuntu.com/ubuntu groovy InRelease [268 kB]Hit:4 http://security.ubuntu.com/ubuntu groovy-security InReleaseHit:5 http://archive.ubuntu.com/ubuntu groovy-updates InReleaseGet:7 http://archive.ubuntu.com/ubuntu groovy/main amd64 Packages [971 kB] Get:8 http://archive.ubuntu.com/ubuntu groovy/main Translation-en [507 kB] Get:9 http://archive.ubuntu.com/ubuntu groovy/main amd64 DEP-11 Metadata [495 kB]Get:10 http://archive.ubuntu.com/ubuntu groovy/main amd64 c-n-f Metadata [29.3 kB]Fetched 2,271 kB in 12s (182 kB/s) Reading package lists... DoneBuilding dependency tree Reading state information... Done23 packages can be upgraded. Run 'apt list --upgradable' to see them.ubuntu@ubuntu:~$ sudo apt install python python2 python-is-python2Reading package lists... DoneBuilding dependency tree Reading state information... DonePackage python is not available, but is referred to by another package.This may mean that the package is missing, has been obsoleted, oris only available from another sourceHowever the following packages replace it: python-is-python3Package python-is-python2 is not available, but is referred to by another package.This may mean that the package is missing, has been obsoleted, oris only available from another sourceHowever the following packages replace it: python-is-python3E: Package 'python' has no installation candidateE: Unable to locate package python2E: Package 'python-is-python2' has no installation candidateubuntu@ubuntu:~$ sudo add-apt-repository universe'universe' distribution component enabled for all sources.Ign:1 cdrom://Ubuntu 20.10 _Groovy Gorilla_ - Alpha amd64 (20200527) groovy InReleaseHit:2 cdrom://Ubuntu 20.10 _Groovy Gorilla_ - Alpha amd64 (20200527) groovy ReleaseHit:3 http://security.ubuntu.com/ubuntu groovy-security InReleaseGet:4 http://archive.ubuntu.com/ubuntu groovy InRelease [268 kB]Hit:5 http://archive.ubuntu.com/ubuntu groovy-updates InReleaseGet:7 http://security.ubuntu.com/ubuntu groovy-security/universe amd64 c-n-f Metadata [116 B]Get:8 http://archive.ubuntu.com/ubuntu groovy/main amd64 Packages [971 kB]Get:9 http://archive.ubuntu.com/ubuntu groovy/main Translation-en [507 kB]Get:10 http://archive.ubuntu.com/ubuntu groovy/main amd64 DEP-11 Metadata [495 kB]Get:11 http://archive.ubuntu.com/ubuntu groovy/main amd64 c-n-f Metadata [29.3 kB]Get:12 http://archive.ubuntu.com/ubuntu groovy/universe amd64 Packages [8716 kB]Get:13 http://archive.ubuntu.com/ubuntu groovy/universe Translation-en [5172 kB]Get:14 http://archive.ubuntu.com/ubuntu groovy/universe amd64 DEP-11 Metadata [3652 kB]Get:15 http://archive.ubuntu.com/ubuntu groovy/universe DEP-11 48x48 Icons [3079 kB]Get:16 http://archive.ubuntu.com/ubuntu groovy/universe DEP-11 64x64 Icons [7843 kB]Get:17 http://archive.ubuntu.com/ubuntu groovy/universe DEP-11 64x64@2 Icons [42.4 kB]Get:18 http://archive.ubuntu.com/ubuntu groovy/universe amd64 c-n-f Metadata [267 kB]Get:19 http://archive.ubuntu.com/ubuntu groovy-updates/universe amd64 c-n-f Metadata [112 B]Fetched 31.0 MB in 14s (2235 kB/s) Reading package lists... Doneubuntu@ubuntu:~$ sudo apt install python python2 python-is-python2 -sReading package lists... DoneBuilding dependency tree Reading state information... DoneNote, selecting 'python-is-python2' instead of 'python'The following additional packages will be installed: libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python2-minimal python2.7 python2.7-minimalSuggested packages: python2-doc python-tk python2.7-doc binfmt-supportThe following NEW packages will be installed: libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python-is-python2 python2 python2-minimal python2.7 python2.7-minimal0 upgraded, 8 newly installed, 0 to remove and 23 not upgraded.Inst libpython2.7-minimal (2.7.18-1 Ubuntu:20.10/groovy [amd64])Inst python2.7-minimal (2.7.18-1 Ubuntu:20.10/groovy [amd64])Inst python2-minimal (2.7.17-2ubuntu4 Ubuntu:20.10/groovy [amd64])Inst libpython2.7-stdlib (2.7.18-1 Ubuntu:20.10/groovy [amd64])Inst python2.7 (2.7.18-1 Ubuntu:20.10/groovy [amd64])Inst libpython2-stdlib (2.7.17-2ubuntu4 Ubuntu:20.10/groovy [amd64])Conf libpython2.7-minimal (2.7.18-1 Ubuntu:20.10/groovy [amd64])Conf python2.7-minimal (2.7.18-1 Ubuntu:20.10/groovy [amd64])Conf python2-minimal (2.7.17-2ubuntu4 Ubuntu:20.10/groovy [amd64])Inst python2 (2.7.17-2ubuntu4 Ubuntu:20.10/groovy [amd64])Inst python-is-python2 (2.7.17-4 Ubuntu:20.10/groovy [all])Conf libpython2.7-stdlib (2.7.18-1 Ubuntu:20.10/groovy [amd64])Conf python2.7 (2.7.18-1 Ubuntu:20.10/groovy [amd64])Conf libpython2-stdlib (2.7.17-2ubuntu4 Ubuntu:20.10/groovy [amd64])Conf python2 (2.7.17-2ubuntu4 Ubuntu:20.10/groovy [amd64])Conf python-is-python2 (2.7.17-4 Ubuntu:20.10/groovy [all])
Doesn't mean end-users won't be able to install Python 2, just that Canonical are serious about demoting it from being officially "supported." Now that we support Python 3, I think Python 3 should be the default Python we target, where that makes sense on a technical basis.
Activity
DeeDeeG commentedon Apr 3, 2020
Info for Fedora (RPM package): I don't think we have to worry about this for Fedora/RPM-based distros.
The current RPM package doesn't even list python in its dependencies:
Furthermore: the default package manager for Fedora,
dnf, is written in Python. Python 3 is installed out-of-the-box on recent Fedora, and can't be uninstalled, becausednfrefuses to uninstall itself (or by extension, its own dependencies). So we can pretty safely assume Python 3 is available on supported Fedora releases.(As of writing this, Fedora 30 and 31 are still active/supported. Fedora 32 will be out April 20th. Judging by past releases, Fedora 30 will probably become EOL about a month later/late May.)
DeeDeeG commentedon Apr 3, 2020
I found a sort of "minimal reproducer" to invoke usage of Python.
atominstalled.apm install tree-view.gypwhen being built/installed.)This will error out if your python setup is inadequate for running
gyp, with an error like this:DeeDeeG commentedon Apr 3, 2020
Full error message (click to expand)
`atom --version` output (click to expand)
`apm --version` output (click to expand)
DeeDeeG commentedon Apr 3, 2020
Short summary: We need newer
node-gyp. (The current dependencies foratominclude a version ofnode-gypthat is too old to support Python 3.)I get the impression that Python really is only needed for
apm, which in turn only needs it fornode-gyp.(If anyone knows this to be wrong, please do let me know/post a correction in this issue! It's a critical assumption I'm making, in order to narrow down the path forward toward get atom migrated fully to Python 3.)
apmbundles its ownnodeandnpmversions. (apmdepends on a pinnednpmversion.)npmin turn depends on a version range ofnode-gyp.There is a sort of "dependency chain" beyond the
atomrepo that must be traversed, making sure the whole chain supports Python 3:atom>apm>npm>node-gypThese are some pretty old bundled versions.
apm@2.4.5(andapm'smasterbranch on GitHub) specify npm@6.2.0npm@6.2.0specifies node-gyp@^3.7.0.npm'slatestbranch (currentlynpm@6.14.4) specifies node-gyp@^5.1.0.npmon the WIP 7.x beta branch: node-gyp@^5.1.0node-gyponly works withpython3"by default" (without an "experimental" CLI flag used) starting with version 6.0: https://github.com/nodejs/node-gyp/blob/master/CHANGELOG.md#v600-2019-10-04 [Edit: Or the latest 5.x series release, 5.1.0. This has Python 3 support backported.]Edit:
npm6.14.2 or newer depends onnode-gyp5.1.0, which has Python 3 support backported. We should depend onnpm6.14.2 or newer inapm.Bottom line: We need newer
node-gypthat supports Python 3.DeeDeeG commentedon Apr 6, 2020
See efforts over at atom/apm#875
I believe that PR is already working, but the tests at that repo need updating if the PR is going to pass tests/CI.
(Regarding my previous comment: This seems easier to solve than I had assumed. The only thing required at the
apmrepo turned out to be bumpingnpm.Background info:
The latest
npmreleases, as it turns out, already depend onnode-gypnew enough to supportpython3. See: npm/cli#927 and npm/cli#771More background on
node-gypPython 3 support: Crucially,node-gyp5.1.0 was released after the most recentnode-gyp6.x release. 5.1.0 also supports Python 3. It's just different fromnode-gyp6.x in that 5.1.0 usespython2preferentially overpython3in some cases. (node-gyp6.x preferspython3in those cases.) The PR I linked to at the beginning of this comment upgrades apm'snpmdependency to a version that depends onnode-gyp5.1.0... So the only thing required atapmturned out to be bumpingnpm. And... updating the CI tests at that repo. The only thing required at this repo, then, would be bumpingapmto a new version once atom/apm#875 or similar lands atapm.)DeeDeeG commentedon Apr 6, 2020
By the way, none of the other platforms' Atom installers appear to require Python in any way, shape or form. They install even if there is no Python on your system.
Only the Debian/Ubuntu (
.deb) packages seem to "require" a Python dependency.Edit to add: Not having Python on the system presumably breaks
apm... Maybe the installers for other platforms bundle a Python interpreter? I know macOS ships with Python (2.7.x still!!!!), so it probably isn't needed there. And Fedora, well... Fedora ships with Python 3... Hmm. (apmwould probably be broken by default on Fedora, then?) But I'm not aware what is being done for Windows.Have to check into all of these.
DeeDeeG commentedon Apr 18, 2020
Can confirm the Windows packaging doesn't include Python.
Zipped apm
apm -v:Error message when trying to
apm install tree-view(no Python):Full error message (click to expand):
Installed apm
apm -v:Installed apm, error message when doing
apm install tree-view:Full error message (click to expand):
Miscellaneous note: I also noticed a package that won't install without Git on the system.
Final note: many packages can be successfully installed without using node-gyp (and thus Python) nor using Git, so there is some lee-way regarding if either of those should be bundled, or if they should be considered install-time dependencies at all. Maybe bundling or requiring Python on the system at install-time for Atom is heavy-handed?
DeeDeeG commentedon Apr 25, 2020
I have had the chance to confirm the macOS app doesn't bundle Python with it, nor does it seem to check whether there is a certain version of Python on the system.
So that leaves the Debian/Ubuntu (
.deb) package as the only one currently specifying a Python dependency.As mentioned in the other thread, IMO this could be made an optional dependency, or dropped, in the
.debpackage.DeeDeeG commentedon Apr 25, 2020
Regarding Fedora: I found that the current
apmwith oldnode-gypis unlikely to work, broadly speaking, on modern Fedora.Python 3 is the default
pythonthere; To useapmon Fedora 31, one has to remove the symlink frompython->python3, and then manually symlinkpython->python2. There is no package that does this for you (unlike on Ubuntu 20.04 or Debian Buster), so it has to be done by hand.IMO, the elegant solution (good for all OSes) is to support both Python 2 and Python 3 in
apm. Once again, see: atom/apm#875Until then there is no packaging we can do to have
apmwork out of the box on Fedora. (As far as I can tell.)DeeDeeG commentedon May 4, 2020
atom/apm#875 --> (now atom/apm#887) is almost done.
The only things required after that, here at this repo (
atom/atom), are to:apmto a version having Upgrade node gyp with fixes apm#887 merged. (Updateapm/package.jsonin this repo.)npmto 6.14.2 or newer inscript/package.jsonin this repo..deband/or.rpmpackages to reflect Python 3 support.Proof-of-concept branch: https://github.com/DeeDeeG/atom/commits/update-apm-test
DeeDeeG commentedon May 13, 2020
Update: There are a few smaller things left to do, actually.Some of these things are beyond my skill level at the moment (particularly, I'm struggling with asynchronous Javascript/race conditions, and I don't know how to use callbacks properly at the moment), but I'll get to them as and when I get the time. (Starting with the ones I know how to fix, like simple documentation updates...) Help wanted/would be much appreciated!Edit: Done and ready for review.Edit 2: Merged: #20856
Copy-pasting from here: #20670 (comment)
Actually, I did find some parts of this repo that could be updated to reflect Python 3. Here are my findings looking at all files that mention "python" (case-insensitive search):
Not related to actual use of the
pythoninterpreter/executable by Atom (so, no changes needed):Click to expand.
language-python, a package that "Adds syntax highlighting and snippets to Python files in Atom.")language-pythonagain.)language-python)language-pythonandtree-sitter-python, which are both related to Python syntax highlighting.)language-pythonagain)language-pythonandtree-sitter-pythonagain. Test-related anyhow, not built/used in the final Atom product for end-users.)pythonandpython-function, respectively.)Actually related to
pythonusage (with suggested changes):pythonpackage on Ubuntu. Maybe this should be updated to suggestpython3orpython2ifpythonisn't available.)pythondependency in the.debpackage for Debian/Ubuntu of Atom. Debating whether to drop this/make it optional, update it, etc.)lintian) that checks for common issues with.debpackages. But it's a very "sensitive" linter and IMO has lots of false positives/noise. No-one has been running this linter apparently, so maybe remove the metadata for it?)python3-aware, or ready for the split ofpythonintopython2andpython3on Linux. Should probably be updated.)For some reason, thisverifyPythoncheck is only being run on Windows??Need to re-write this test if it is going to work against Python 3. Help wanted/appreciated!node-gyp's responsibility to continue to support Python 2 and 3 properly. Continuing to test against just Python 2 could be okay, I suppose.DeeDeeG commentedon May 13, 2020
DeeDeeG commentedon May 27, 2020
Update:
For Ubuntu 20.10As of Ubuntu 19.10, Canonical have moved every form of Python 2 to the "universe" component of the repositories. (Meaning, "community-maintained," as opposed to "Canonical-supported" -- Canonical being the company that runs Ubuntu. Per: https://help.ubuntu.com/community/Repositories/Ubuntu)Tried to install Python 2 in an Ubuntu 20.10 VM (click to expand).
None of these can be installed anymore:
Doesn't mean end-users won't be able to install Python 2, just that Canonical are serious about demoting it from being officially "supported." Now that we support Python 3, I think Python 3 should be the default Python we target, where that makes sense on a technical basis.
DeeDeeG commentedon Jul 10, 2020
#20856 is merged! 🎉
The very last thing here is to update the Docs, "Hacking on Atom Core" to reflect Python 3 support.
See: atom/flight-manual.atom.io#630
DeeDeeG commentedon Nov 14, 2020
Docs were updated (atom/flight-manual.atom.io#630). Atom is Python-3-ready/compatible.
Happened a while ago, just now getting around to closing this.