From b43b0d5d291776999be9ec27c2e1f88221be701c Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 13 May 2020 15:20:02 -0400 Subject: [PATCH 01/14] :memo: README.md: Update python for manual Linux installs We support Python 3 now. Use that in the default instructions, but explain that `python2` or `python` will work in its place. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 23a37611b..b8b9ff9da 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,8 @@ An archive is available for people who don't want to install `atom` as root. This version enables you to install multiple Atom versions in parallel. It has been built on Ubuntu 64-bit, but should be compatible with other Linux distributions. -1. Install dependencies (on Ubuntu): `sudo apt install git gconf2 gconf-service libgtk2.0-0 libudev1 libgcrypt20 libnotify4 libxtst6 libnss3 python gvfs-bin xdg-utils libcap2` +1. Install dependencies (on Ubuntu): `sudo apt install git gconf2 gconf-service libgtk2.0-0 libudev1 libgcrypt20 libnotify4 libxtst6 libnss3 python3 gvfs-bin xdg-utils libcap2` + 1. (If the `python3` package isn't available, or is too old (Python 3 should be >= 3.5), either `python2` or `python` will work in its place.) 2. Download `atom-amd64.tar.gz` from the [Atom releases page](https://github.com/atom/atom/releases/latest). 3. Run `tar xf atom-amd64.tar.gz` in the directory where you want to extract the Atom folder. 4. Launch Atom using the installed `atom` command from the newly extracted directory. From 10811f1158d7956fafb78aeff490f3a65de0f137 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 13 May 2020 15:28:11 -0400 Subject: [PATCH 02/14] :fire: Lintian overrides These overrides are very outdated. (Haven't been updated since the day they were added, back in 2014.) Even with these applied, Lintian still prints many warns/errors. I think no-one has been running Lintian against the .deb package for a while now. --- resources/linux/debian/lintian-overrides | 7 ------- script/lib/create-debian-package.js | 20 -------------------- 2 files changed, 27 deletions(-) delete mode 100644 resources/linux/debian/lintian-overrides diff --git a/resources/linux/debian/lintian-overrides b/resources/linux/debian/lintian-overrides deleted file mode 100644 index 8a33af0a7..000000000 --- a/resources/linux/debian/lintian-overrides +++ /dev/null @@ -1,7 +0,0 @@ -atom: arch-dependent-file-in-usr-share -atom: changelog-file-missing-in-native-package -atom: copyright-file-contains-full-apache-2-license -atom: copyright-should-refer-to-common-license-file-for-apache-2 -atom: embedded-library -atom: package-installs-python-bytecode -atom: unstripped-binary-or-object diff --git a/script/lib/create-debian-package.js b/script/lib/create-debian-package.js index e79d256e8..af94058aa 100644 --- a/script/lib/create-debian-package.js +++ b/script/lib/create-debian-package.js @@ -54,11 +54,6 @@ module.exports = function(packagedAppPath) { debianPackageShareDirPath, 'pixmaps' ); - const debianPackageLintianOverridesDirPath = path.join( - debianPackageShareDirPath, - 'lintian', - 'overrides' - ); const debianPackageDocsDirPath = path.join( debianPackageShareDirPath, 'doc', @@ -93,7 +88,6 @@ module.exports = function(packagedAppPath) { fs.mkdirpSync(debianPackageShareDirPath); fs.mkdirpSync(debianPackageApplicationsDirPath); fs.mkdirpSync(debianPackageIconsDirPath); - fs.mkdirpSync(debianPackageLintianOverridesDirPath); fs.mkdirpSync(debianPackageDocsDirPath); fs.mkdirpSync(debianPackageBinDirPath); @@ -190,20 +184,6 @@ module.exports = function(packagedAppPath) { path.join(debianPackageDocsDirPath, 'copyright') ); - console.log( - `Copying lintian overrides into "${debianPackageLintianOverridesDirPath}"` - ); - fs.copySync( - path.join( - CONFIG.repositoryRootPath, - 'resources', - 'linux', - 'debian', - 'lintian-overrides' - ), - path.join(debianPackageLintianOverridesDirPath, atomExecutableName) - ); - console.log( `Copying polkit configuration into "${debianPackageShareDirPath}"` ); From b86afa5854c84bfa223a5e4d7ed3866f06b35ca5 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Fri, 29 May 2020 00:34:00 -0400 Subject: [PATCH 03/14] script: Reimplement node-gyp's find-python library Use this to find python for the verify-machine-requirements.js script. --- script/lib/verify-machine-requirements.js | 114 +++++++++++++++++----- 1 file changed, 87 insertions(+), 27 deletions(-) diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 51ca5a6cd..d3f0009ce 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -9,9 +9,7 @@ const CONFIG = require('../config'); module.exports = function(ci) { verifyNode(); verifyNpm(ci); - if (process.platform === 'win32') { - verifyPython(); - } + verifyPython(); }; function verifyNode() { @@ -50,36 +48,98 @@ function verifyNpm(ci) { } function verifyPython() { - const systemDrive = process.env.SystemDrive || 'C:\\'; - let pythonExecutable; - if (process.env.PYTHON) { - pythonExecutable = process.env.PYTHON; - } else { - const pythonBinPath = path.join(systemDrive, 'Python27', 'python.exe'); - if (fs.existsSync(pythonBinPath)) { - pythonExecutable = pythonBinPath; - } else { - pythonExecutable = 'python'; + // This function essentially re-implements node-gyp's "find-python.js" library, + // but in a synchronous, bootstrap-script-friendly way. + // It is based off of the logic of the file from node-gyp v5.x: + // https://github.com/nodejs/node-gyp/blob/v5.1.1/lib/find-python.js + // This node-gyp is the version in use by current npm (in mid 2020). + // + // TODO: If apm ships a newer version of node-gyp (v6.x or later), please update this script. + // Particularly, node-gyp v6.x looks for python3 first, then python, then python2. + // (In contrast: node-gyp v5.x looks for python first, then python2, then python3.) + // Also, node-gyp v7.x or later will probably drop the "-2" flag from "py.exe", + // so as to allow finding Python 3 as well, not just Python 2. + // https://github.com/nodejs/node-gyp/pull/2124#issuecomment-633812957 + + var stdout; + var fullVersion; + var usablePythonWasFound; + + function verifyBinary(binary, prependFlag) { + if (binary && !usablePythonWasFound) { + let allFlags = ['-c', 'import platform\nprint(platform.python_version())']; + if (prependFlag) { + // prependFlag is an optional argument, + // used to prepend "-2" for the "py.exe" launcher. + // TODO: Refactor by eliminating prependFlag + // once apm updates to node-gyp v7.x+, when it is anticipated + // that the "-2" flag will be dropped for invoking the py launcher. + allFlags.unshift(prependFlag); + } + + try { + stdout = childProcess.execFileSync( + binary, + allFlags, + { env: process.env, stdio: ['ignore', 'pipe', 'ignore'] } + ); + } catch { + } + + if (stdout) { + if (stdout.indexOf('+') !== -1) stdout = stdout.toString().replace(/\+/g, ''); + if (stdout.indexOf('rc') !== -1) stdout = stdout.toString().replace(/rc(.*)$/gi, ''); + fullVersion = stdout.toString().trim(); + } + + if (fullVersion) { + var versionComponents = fullVersion.split('.'); + var majorVersion = Number(versionComponents[0]); + var minorVersion = Number(versionComponents[1]); + if (majorVersion === 2 && minorVersion === 7 || majorVersion === 3 && minorVersion >= 5) { + usablePythonWasFound = true; + } else { + stdout = ''; + } + } } } - let stdout = childProcess.execFileSync( - pythonExecutable, - ['-c', 'import platform\nprint(platform.python_version())'], - { env: process.env } - ); - if (stdout.indexOf('+') !== -1) stdout = stdout.replace(/\+/g, ''); - if (stdout.indexOf('rc') !== -1) stdout = stdout.replace(/rc(.*)$/gi, ''); - const fullVersion = stdout.toString().trim(); - const versionComponents = fullVersion.split('.'); - const majorVersion = Number(versionComponents[0]); - const minorVersion = Number(versionComponents[1]); - if (majorVersion === 2 && minorVersion === 7) { + function verifyForcedBinary(binary) { + if (typeof binary !== 'undefined' && binary.length > 0) { + verifyBinary(binary); + if (!usablePythonWasFound){ + throw new Error( + `NODE_GYP_FORCE_PYTHON is set to: "${binary}", but this is not a valid Python.\n` + + 'Please set NODE_GYP_FORCE_PYTHON to something valid, or unset it entirely.\n' + + '(Python 2.7 or 3.5+ is required to build Atom.)\n' + ); + } + } + } + + // These first two checks do nothing if the relevant + // environment variables aren't set. + verifyForcedBinary(process.env.NODE_GYP_FORCE_PYTHON); + // All the following checks will no-op if a previous check has succeeded. + verifyBinary(process.env.PYTHON); + verifyBinary('python'); + verifyBinary('python2'); + verifyBinary('python3'); + if (process.platform === 'win32') { + verifyBinary('py.exe', '-2'); + verifyBinary(path.join(process.env.SystemDrive || 'C:', 'Python27', 'python.exe')); + verifyBinary(path.join(process.env.SystemDrive || 'C:', 'Python37', 'python.exe')); + } + + if (usablePythonWasFound) { console.log(`Python:\tv${fullVersion}`); } else { throw new Error( - `Python 2.7 is required to build Atom. ${pythonExecutable} returns version ${fullVersion}.\n` + - `Set the PYTHON env var to '/path/to/Python27/python.exe' if your python is installed in a non-default location.` + 'Python 2.7 or 3.5+ is required to build Atom.\n' + + 'verify-machine-requirements.js was unable to find such a version of Python.\n' + + "Set the PYTHON env var to e.g. 'C:/path/to/Python27/python.exe'\n" + + 'if your Python is installed in a non-default location.\n' ); } } From b383e0a0db889d94f7d3c5f3172b278ca134037c Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Fri, 29 May 2020 23:40:09 -0400 Subject: [PATCH 04/14] :fire: .python-version .python-version specifies which version(s) of Python are in the PATH, and which version runs when you run the python, python2, or python3 commands. That said, it is overly specific for this repository's needs. In order to specify any version, you must enter it down to the patch level, e.g. 3.8.2; Major-minor versions aren't allowed, e.g. 2.7 If users want to add such a file on their own machines, they may... But it's unneccesary for this repository to ship this file as if there were specific "correct" versions of Python to use. Any Python 2.7.x or 3.5.0+ will work at the moment. There are other checks elsewhere in the project, such as in script/bootstrap. These should be sufficient to inform users which Python versions they can use. node-gyp will also tell you. --- .gitignore | 1 + .python-version | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 .python-version diff --git a/.gitignore b/.gitignore index 5457617c5..cd95b89a0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ Thumbs.db .svn .nvm-version .vscode +.python-version node_modules npm-debug.log debug.log diff --git a/.python-version b/.python-version deleted file mode 100644 index ecc17b8e9..000000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -2.7.13 From 2c6c14d1977b9f92dbeb702e3b89a652f9fadbe6 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Sat, 30 May 2020 15:30:05 -0400 Subject: [PATCH 05/14] script: Add attempt logging for verifyPython() Log which Python commands were tried, and the results, if no usable Python was found. Useful for debugging failures. --- script/lib/verify-machine-requirements.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index d3f0009ce..27eb73bf4 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -64,6 +64,7 @@ function verifyPython() { var stdout; var fullVersion; var usablePythonWasFound; + var triedLog = ''; function verifyBinary(binary, prependFlag) { if (binary && !usablePythonWasFound) { @@ -102,6 +103,14 @@ function verifyPython() { stdout = ''; } } + + // Prepare to log which commands were tried, and the results, in case no usable Python can be found. + if (prependFlag) { + var binaryPlusFlag = binary.concat(' ' + prependFlag); + } else { + var binaryPlusFlag = binary; + } + triedLog = triedLog.concat('log message: tried to check version of "' + binaryPlusFlag + '", got: ' + fullVersion + '\n'); } } @@ -136,10 +145,11 @@ function verifyPython() { console.log(`Python:\tv${fullVersion}`); } else { throw new Error( - 'Python 2.7 or 3.5+ is required to build Atom.\n' + - 'verify-machine-requirements.js was unable to find such a version of Python.\n' + - "Set the PYTHON env var to e.g. 'C:/path/to/Python27/python.exe'\n" + - 'if your Python is installed in a non-default location.\n' + `\n${triedLog}\n` + + 'Python 2.7 or 3.5+ is required to build Atom.\n' + + 'verify-machine-requirements.js was unable to find such a version of Python.\n' + + "Set the PYTHON env var to e.g. 'C:/path/to/Python27/python.exe'\n" + + 'if your Python is installed in a non-default location.\n' ); } } From 2656d197144fc6be3b7c1869e4c6a04074800004 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Sat, 30 May 2020 17:41:59 -0400 Subject: [PATCH 06/14] ci: Update Windows build from Python 2.7 to 3.8 Python 2 is officially end-of-life. We can use Python 3 now. --- script/vsts/platforms/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/vsts/platforms/windows.yml b/script/vsts/platforms/windows.yml index 23782335a..d1035135d 100644 --- a/script/vsts/platforms/windows.yml +++ b/script/vsts/platforms/windows.yml @@ -22,7 +22,7 @@ jobs: steps: - task: UsePythonVersion@0 inputs: - versionSpec: '2.7' + versionSpec: '3.8' - task: NodeTool@0 inputs: From 4d9d6fa1714ba08d26efd3c5b7522047c76d7e91 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Sat, 30 May 2020 18:40:27 -0400 Subject: [PATCH 07/14] :shirt: Fix lints (verify-machine-requirements.js) --- script/lib/verify-machine-requirements.js | 60 ++++++++++++++--------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 27eb73bf4..24b0ccf9f 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -1,7 +1,6 @@ 'use strict'; const childProcess = require('child_process'); -const fs = require('fs'); const path = require('path'); const CONFIG = require('../config'); @@ -65,10 +64,14 @@ function verifyPython() { var fullVersion; var usablePythonWasFound; var triedLog = ''; + var binaryPlusFlag; function verifyBinary(binary, prependFlag) { if (binary && !usablePythonWasFound) { - let allFlags = ['-c', 'import platform\nprint(platform.python_version())']; + let allFlags = [ + '-c', + 'import platform\nprint(platform.python_version())' + ]; if (prependFlag) { // prependFlag is an optional argument, // used to prepend "-2" for the "py.exe" launcher. @@ -79,17 +82,17 @@ function verifyPython() { } try { - stdout = childProcess.execFileSync( - binary, - allFlags, - { env: process.env, stdio: ['ignore', 'pipe', 'ignore'] } - ); - } catch { - } + stdout = childProcess.execFileSync(binary, allFlags, { + env: process.env, + stdio: ['ignore', 'pipe', 'ignore'] + }); + } catch {} if (stdout) { - if (stdout.indexOf('+') !== -1) stdout = stdout.toString().replace(/\+/g, ''); - if (stdout.indexOf('rc') !== -1) stdout = stdout.toString().replace(/rc(.*)$/gi, ''); + if (stdout.indexOf('+') !== -1) + stdout = stdout.toString().replace(/\+/g, ''); + if (stdout.indexOf('rc') !== -1) + stdout = stdout.toString().replace(/rc(.*)$/gi, ''); fullVersion = stdout.toString().trim(); } @@ -97,7 +100,10 @@ function verifyPython() { var versionComponents = fullVersion.split('.'); var majorVersion = Number(versionComponents[0]); var minorVersion = Number(versionComponents[1]); - if (majorVersion === 2 && minorVersion === 7 || majorVersion === 3 && minorVersion >= 5) { + if ( + (majorVersion === 2 && minorVersion === 7) || + (majorVersion === 3 && minorVersion >= 5) + ) { usablePythonWasFound = true; } else { stdout = ''; @@ -106,22 +112,28 @@ function verifyPython() { // Prepare to log which commands were tried, and the results, in case no usable Python can be found. if (prependFlag) { - var binaryPlusFlag = binary.concat(' ' + prependFlag); + binaryPlusFlag = binary.concat(' ' + prependFlag); } else { - var binaryPlusFlag = binary; + binaryPlusFlag = binary; } - triedLog = triedLog.concat('log message: tried to check version of "' + binaryPlusFlag + '", got: ' + fullVersion + '\n'); + triedLog = triedLog.concat( + 'log message: tried to check version of "' + + binaryPlusFlag + + '", got: ' + + fullVersion + + '\n' + ); } } function verifyForcedBinary(binary) { if (typeof binary !== 'undefined' && binary.length > 0) { verifyBinary(binary); - if (!usablePythonWasFound){ + if (!usablePythonWasFound) { throw new Error( `NODE_GYP_FORCE_PYTHON is set to: "${binary}", but this is not a valid Python.\n` + 'Please set NODE_GYP_FORCE_PYTHON to something valid, or unset it entirely.\n' + - '(Python 2.7 or 3.5+ is required to build Atom.)\n' + '(Python 2.7 or 3.5+ is required to build Atom.)\n' ); } } @@ -137,8 +149,12 @@ function verifyPython() { verifyBinary('python3'); if (process.platform === 'win32') { verifyBinary('py.exe', '-2'); - verifyBinary(path.join(process.env.SystemDrive || 'C:', 'Python27', 'python.exe')); - verifyBinary(path.join(process.env.SystemDrive || 'C:', 'Python37', 'python.exe')); + verifyBinary( + path.join(process.env.SystemDrive || 'C:', 'Python27', 'python.exe') + ); + verifyBinary( + path.join(process.env.SystemDrive || 'C:', 'Python37', 'python.exe') + ); } if (usablePythonWasFound) { @@ -147,9 +163,9 @@ function verifyPython() { throw new Error( `\n${triedLog}\n` + 'Python 2.7 or 3.5+ is required to build Atom.\n' + - 'verify-machine-requirements.js was unable to find such a version of Python.\n' + - "Set the PYTHON env var to e.g. 'C:/path/to/Python27/python.exe'\n" + - 'if your Python is installed in a non-default location.\n' + 'verify-machine-requirements.js was unable to find such a version of Python.\n' + + "Set the PYTHON env var to e.g. 'C:/path/to/Python27/python.exe'\n" + + 'if your Python is installed in a non-default location.\n' ); } } From 893f84cb5a4ac217fe616e497f3a3d2536deeb6d Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Sat, 30 May 2020 21:50:03 -0400 Subject: [PATCH 08/14] script: Refactor log strings for readability in script/lib/verify-machine-requirements.js --- script/lib/verify-machine-requirements.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 24b0ccf9f..26975ee7a 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -112,16 +112,12 @@ function verifyPython() { // Prepare to log which commands were tried, and the results, in case no usable Python can be found. if (prependFlag) { - binaryPlusFlag = binary.concat(' ' + prependFlag); + binaryPlusFlag = binary + ' ' + prependFlag; } else { binaryPlusFlag = binary; } triedLog = triedLog.concat( - 'log message: tried to check version of "' + - binaryPlusFlag + - '", got: ' + - fullVersion + - '\n' + `log message: tried to check version of "${binaryPlusFlag}", got: ${fullVersion}\n` ); } } From b1288ca7bb37a08952a35e37deaa2475c75d047c Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 3 Jun 2020 16:14:35 -0400 Subject: [PATCH 09/14] script: correct failure logging in verifyPython() Make sure a previously found version isn't erroneously logged, by clearing the "fullVersion" variable before each new check. --- script/lib/verify-machine-requirements.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 26975ee7a..376a0cc85 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -68,6 +68,8 @@ function verifyPython() { function verifyBinary(binary, prependFlag) { if (binary && !usablePythonWasFound) { + fullVersion = ''; + let allFlags = [ '-c', 'import platform\nprint(platform.python_version())' @@ -117,7 +119,7 @@ function verifyPython() { binaryPlusFlag = binary; } triedLog = triedLog.concat( - `log message: tried to check version of "${binaryPlusFlag}", got: ${fullVersion}\n` + `log message: tried to check version of "${binaryPlusFlag}", got: "${fullVersion}"\n` ); } } From 8965d32bcbdd65128c013fe83ff9a533ac3c1393 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 3 Jun 2020 17:03:40 -0400 Subject: [PATCH 10/14] script: Use "let" not "var" in verifyPython() --- script/lib/verify-machine-requirements.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 376a0cc85..1829f6ca4 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -60,11 +60,11 @@ function verifyPython() { // so as to allow finding Python 3 as well, not just Python 2. // https://github.com/nodejs/node-gyp/pull/2124#issuecomment-633812957 - var stdout; - var fullVersion; - var usablePythonWasFound; - var triedLog = ''; - var binaryPlusFlag; + let stdout; + let fullVersion; + let usablePythonWasFound; + let triedLog = ''; + let binaryPlusFlag; function verifyBinary(binary, prependFlag) { if (binary && !usablePythonWasFound) { @@ -99,9 +99,9 @@ function verifyPython() { } if (fullVersion) { - var versionComponents = fullVersion.split('.'); - var majorVersion = Number(versionComponents[0]); - var minorVersion = Number(versionComponents[1]); + let versionComponents = fullVersion.split('.'); + let majorVersion = Number(versionComponents[0]); + let minorVersion = Number(versionComponents[1]); if ( (majorVersion === 2 && minorVersion === 7) || (majorVersion === 3 && minorVersion >= 5) From bb2cfa95553d312d1d094a862bffd290e22964b6 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 3 Jun 2020 20:54:50 -0400 Subject: [PATCH 11/14] script: Update comments for node-gyp 7.0 release --- script/lib/verify-machine-requirements.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 1829f6ca4..00c22ee66 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -56,9 +56,9 @@ function verifyPython() { // TODO: If apm ships a newer version of node-gyp (v6.x or later), please update this script. // Particularly, node-gyp v6.x looks for python3 first, then python, then python2. // (In contrast: node-gyp v5.x looks for python first, then python2, then python3.) - // Also, node-gyp v7.x or later will probably drop the "-2" flag from "py.exe", + // Also, node-gyp v7.x stopped using the "-2" flag for "py.exe", // so as to allow finding Python 3 as well, not just Python 2. - // https://github.com/nodejs/node-gyp/pull/2124#issuecomment-633812957 + // https://github.com/nodejs/node-gyp/blob/master/CHANGELOG.md#v700-2020-06-03 let stdout; let fullVersion; @@ -78,8 +78,8 @@ function verifyPython() { // prependFlag is an optional argument, // used to prepend "-2" for the "py.exe" launcher. // TODO: Refactor by eliminating prependFlag - // once apm updates to node-gyp v7.x+, when it is anticipated - // that the "-2" flag will be dropped for invoking the py launcher. + // once apm updates to node-gyp v7.x or newer, in which + // the "-2" flag has been dropped for invoking the py launcher. allFlags.unshift(prependFlag); } From dc44ad2d1692b042c809d3fb4ac0718069866251 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 17 Jun 2020 16:33:58 -0400 Subject: [PATCH 12/14] script: Update comment in verifyPython() --- script/lib/verify-machine-requirements.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 00c22ee66..6b6a2e962 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -53,9 +53,10 @@ function verifyPython() { // https://github.com/nodejs/node-gyp/blob/v5.1.1/lib/find-python.js // This node-gyp is the version in use by current npm (in mid 2020). // - // TODO: If apm ships a newer version of node-gyp (v6.x or later), please update this script. - // Particularly, node-gyp v6.x looks for python3 first, then python, then python2. - // (In contrast: node-gyp v5.x looks for python first, then python2, then python3.) + // TODO: If this repo ships a newer version of node-gyp (v6.x or later), please update this script. + // (Currently, the build scripts and apm each depend on npm v6.14, which depends on node-gyp v5.) + // node-gyp v5.x looks for python first, then python2, then python3. + // node-gyp v6.x looks for python3 first, then python, then python2.) // Also, node-gyp v7.x stopped using the "-2" flag for "py.exe", // so as to allow finding Python 3 as well, not just Python 2. // https://github.com/nodejs/node-gyp/blob/master/CHANGELOG.md#v700-2020-06-03 From f8fecadcbb45d92a6d4fd56c7c9b2e7cbcc4ed9f Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Wed, 17 Jun 2020 16:43:38 -0400 Subject: [PATCH 13/14] script: Refactor variable use in verifyPython() --- script/lib/verify-machine-requirements.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 6b6a2e962..5181c4039 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -69,6 +69,8 @@ function verifyPython() { function verifyBinary(binary, prependFlag) { if (binary && !usablePythonWasFound) { + // clear re-used "result" variables now that we're checking another python binary. + stdout = ''; fullVersion = ''; let allFlags = [ @@ -108,8 +110,6 @@ function verifyPython() { (majorVersion === 3 && minorVersion >= 5) ) { usablePythonWasFound = true; - } else { - stdout = ''; } } From fef2de59a48438fd0a24e52c9f2c51fa45ef3949 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Fri, 10 Jul 2020 11:58:17 -0400 Subject: [PATCH 14/14] node-gyp 5.x still accepts Python 2.6 --- README.md | 2 +- script/lib/verify-machine-requirements.js | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b8b9ff9da..6d2ae4f8c 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ This version enables you to install multiple Atom versions in parallel. It has b but should be compatible with other Linux distributions. 1. Install dependencies (on Ubuntu): `sudo apt install git gconf2 gconf-service libgtk2.0-0 libudev1 libgcrypt20 libnotify4 libxtst6 libnss3 python3 gvfs-bin xdg-utils libcap2` - 1. (If the `python3` package isn't available, or is too old (Python 3 should be >= 3.5), either `python2` or `python` will work in its place.) + 1. (If the `python3` package isn't available, or is too old (Python 3 should be >= 3.5), either `python2` or `python` (2.6 or 2.7) will work in its place.) 2. Download `atom-amd64.tar.gz` from the [Atom releases page](https://github.com/atom/atom/releases/latest). 3. Run `tar xf atom-amd64.tar.gz` in the directory where you want to extract the Atom folder. 4. Launch Atom using the installed `atom` command from the newly extracted directory. diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 5181c4039..ccc4a6841 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -55,9 +55,11 @@ function verifyPython() { // // TODO: If this repo ships a newer version of node-gyp (v6.x or later), please update this script. // (Currently, the build scripts and apm each depend on npm v6.14, which depends on node-gyp v5.) - // node-gyp v5.x looks for python first, then python2, then python3. - // node-gyp v6.x looks for python3 first, then python, then python2.) - // Also, node-gyp v7.x stopped using the "-2" flag for "py.exe", + // Differences between major versions of node-gyp: + // node-gyp 5.x looks for python, then python2, then python3. + // node-gyp 6.x looks for python3, then python, then python2.) + // node-gyp 5.x accepts Python ^2.6 || >= 3.5, node-gyp 6+ only accepts Python == 2.7 || >= 3.5. + // node-gyp 7.x stopped using the "-2" flag for "py.exe", // so as to allow finding Python 3 as well, not just Python 2. // https://github.com/nodejs/node-gyp/blob/master/CHANGELOG.md#v700-2020-06-03 @@ -80,9 +82,10 @@ function verifyPython() { if (prependFlag) { // prependFlag is an optional argument, // used to prepend "-2" for the "py.exe" launcher. - // TODO: Refactor by eliminating prependFlag - // once apm updates to node-gyp v7.x or newer, in which - // the "-2" flag has been dropped for invoking the py launcher. + // + // TODO: Refactor this script by eliminating "prependFlag" + // once we update to node-gyp v7.x or newer; + // the "-2" flag is not used in node-gyp v7.x. allFlags.unshift(prependFlag); } @@ -106,7 +109,7 @@ function verifyPython() { let majorVersion = Number(versionComponents[0]); let minorVersion = Number(versionComponents[1]); if ( - (majorVersion === 2 && minorVersion === 7) || + (majorVersion === 2 && minorVersion >= 6) || (majorVersion === 3 && minorVersion >= 5) ) { usablePythonWasFound = true; @@ -132,7 +135,7 @@ function verifyPython() { throw new Error( `NODE_GYP_FORCE_PYTHON is set to: "${binary}", but this is not a valid Python.\n` + 'Please set NODE_GYP_FORCE_PYTHON to something valid, or unset it entirely.\n' + - '(Python 2.7 or 3.5+ is required to build Atom.)\n' + '(Python 2.6, 2.7 or 3.5+ is required to build Atom.)\n' ); } } @@ -161,7 +164,7 @@ function verifyPython() { } else { throw new Error( `\n${triedLog}\n` + - 'Python 2.7 or 3.5+ is required to build Atom.\n' + + 'Python 2.6, 2.7 or 3.5+ is required to build Atom.\n' + 'verify-machine-requirements.js was unable to find such a version of Python.\n' + "Set the PYTHON env var to e.g. 'C:/path/to/Python27/python.exe'\n" + 'if your Python is installed in a non-default location.\n'