Skip to content
This repository has been archived by the owner on Sep 11, 2021. It is now read-only.

Upgrade from Python 2.7.17 --> 3.8.1 #205

Merged
merged 7 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ yarn global add windows-build-tools

After installation, npm will automatically execute this module, which downloads and installs Visual
C++ Build Tools, provided free of charge for most users by Microsoft (as part of Visual Studio Community, please consult the license to determine whether or not you're eligible). These tools are [required to compile popular native modules](https://github.com/nodejs/node-gyp).
If not already installed, it will also install Python 2.7, configuring your machine and npm appropriately.
If not already installed, it will also install Python 3.8, configuring your machine and npm appropriately.

> :bulb: [Windows Vista / 7 only] requires [.NET Framework 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40773) (Currently not installed automatically by this package)

Expand Down Expand Up @@ -100,7 +100,7 @@ it's installed. Alternatively, you can prepare a folder that contains installers
have their original names:

* Visual Studio Build Tools: `vs_BuildTools.exe` or `BuildTools_Full.exe`
* Python: `python-2.7.15.amd64.msi` or `python-2.7.15.msi`
* Python: `python-3.8.1.amd64.msi` or `python-3.8.1.msi`

Then, run `windows-build-tools` with the `--offline-installers` argument:

Expand All @@ -120,7 +120,7 @@ This package currently only handles the most common use case, none of the edge c

#### Where is Python installed?

It's saved under `%USERPROFILE%\.windows-build-tools\python27`.
It's saved under `%USERPROFILE%\.windows-build-tools\python38`.

#### Installing as a Non-Administrator
`windows-build-tools` works best if installed from an account with administrative rights. However,
Expand Down Expand Up @@ -154,7 +154,7 @@ ensure that the most popular native Node addons compile from source. Those are:

## License & Credits

The Python installation was made possible by [Ali Hajimirza](https://github.com/ali92hm), who kindly wrestled with Python's MSIs until they surrendered. For details regarding the license agreements applicable to Python, see *History and License* [2.x](https://docs.python.org/2/license.html) and [3.x](https://docs.python.org/3/license.html).
The Python installation was made possible by [Ali Hajimirza](https://github.com/ali92hm), who kindly wrestled with Python's MSIs until they surrendered. For details regarding the license agreements applicable to Python, see *History and License* [3.x](https://docs.python.org/3/license.html).

Use of Microsoft software is subject to the terms of the corresponding license agreements. For details regarding the license agreements applicable to Visual Studio products, refer to their [*License Directory* page](https://visualstudio.microsoft.com/license-terms/). (See also [this discussion](https://social.msdn.microsoft.com/Forums/en-US/08d62115-0b51-484f-afda-229989be9263/license-for-visual-c-2017-build-tools?forum=visualstudiogeneral) for the gist of it.)

Expand Down
4 changes: 2 additions & 2 deletions __tests__/utils/get-is-python-installed-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ describe('get-is-python-installed', () => {
});

it('correctly returns the Python version if installed', async () => {
(spawnSync as any).mockReturnValue({ output: '\nPython 2.7.17\n' });
(spawnSync as any).mockReturnValue({ output: '\nPython 3.8.1\n' });

expect(getIsPythonInstalled()).toBe('Python 2.7.17');
expect(getIsPythonInstalled()).toBe('Python 3.8.1');
});

it('correctly returns the Python version if installed', async () => {
Expand Down
8 changes: 4 additions & 4 deletions __tests__/utils/get-python-installer-path-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe('getPythonInstallerPath', () => {

expect(getPythonInstallerPath()).toEqual({
directory: 'C:\\workDir',
fileName: `python-2.7.17.${amd64}msi`,
fileName: `python-3.8.1.${amd64}msi`,
logPath: 'C:\\workDir\\python-log.txt',
path: `C:\\workDir\\python-2.7.17.${amd64}msi`,
targetPath: 'C:\\workDir\\python27',
url: `https://www.python.org/ftp/python/2.7.17/python-2.7.17.${amd64}msi`,
path: `C:\\workDir\\python-3.8.1.${amd64}msi`,
targetPath: 'C:\\workDir\\python38',
url: `https://www.python.org/ftp/python/3.8.1/python-3.8.1.${amd64}msi`,
});
});
});
2 changes: 1 addition & 1 deletion ps1/launch-installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function runInstaller {
function runPythonInstaller {
if (Test-Path $BuildToolsInstallerPath) {
cd $BuildToolsInstallerPath
$pyParams = "/i", $PythonInstaller, "TARGETDIR=```"$BuildToolsInstallerPath\python27```"", "ALLUSERS=0", "/qn", "/L*P", "`"$BuildToolsInstallerPath\python-log.txt`""
$pyParams = "/i", $PythonInstaller, "TARGETDIR=```"$BuildToolsInstallerPath\python38```"", "ALLUSERS=0", "/qn", "/L*P", "`"$BuildToolsInstallerPath\python-log.txt`""
Invoke-Expression "msiexec.exe $pyParams"
} else {
Write-Output "Tried to start Python installer, but couldn't find $BuildToolsInstallerPath."
Expand Down
12 changes: 6 additions & 6 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export const IS_PYTHON_INSTALLED = !!INSTALLED_PYTHON_VERSION;

export const PYTHON = process.arch === 'x64'
? {
installerName: 'python-2.7.17.amd64.msi',
installerUrl: pythonMirror.replace(/\/*$/, '/2.7.17/python-2.7.17.amd64.msi'),
targetName: 'python27',
installerName: 'python-3.8.1.amd64.msi',
installerUrl: pythonMirror.replace(/\/*$/, '/3.8.1/python-3.8.1.amd64.msi'),
targetName: 'python38',
logName: 'python-log.txt'
} : {
installerName: 'python-2.7.17.msi',
installerUrl: pythonMirror.replace(/\/*$/, '/2.7.17/python-2.7.17.msi'),
targetName: 'python27',
installerName: 'python-3.8.1.msi',
installerUrl: pythonMirror.replace(/\/*$/, '/3.8.1/python-3.8.1.msi'),
targetName: 'python38',
logName: 'python-log.txt'
};

Expand Down
2 changes: 1 addition & 1 deletion src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const debug = require('debug')('windows-build-tools');

/**
* Uses PowerShell to configure the environment for
* msvs_version 2015 and npm python 2.7
* msvs_version 2015 and npm python 3.8
*
* @params variables an object with paths for different environmental variables
*/
Expand Down
8 changes: 4 additions & 4 deletions src/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ function tailPythonInstallation(): Promise<InstallationReport> {
}

if (result === 'success') {
pythonLastLines = [ chalk.bold.green('Successfully installed Python 2.7') ];
pythonLastLines = [ chalk.bold.green('Successfully installed Python 3.8') ];

debug('Installer: Successfully installed Python 2.7 according to tailer');
debug('Installer: Successfully installed Python 3.8 according to tailer');
resolve({
installPath: details || getPythonInstallerPath().targetPath,
toConfigure: true,
Expand All @@ -155,11 +155,11 @@ function tailPythonInstallation(): Promise<InstallationReport> {
}

if (result === 'failure') {
log(chalk.bold.red('\nCould not install Python 2.7.'));
log(chalk.bold.red('\nCould not install Python 3.8.'));
log('Please find more details in the log files, which can be found at');
log(getWorkDirectory() + '\n');

debug('Installer: Failed to install Python 2.7 according to tailer');
debug('Installer: Failed to install Python 3.8 according to tailer');
resolve({
success: false
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/get-is-python-installed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function getIsPythonInstalled() {
const { output } = spawnSync('python', [ '-V' ], options as any);
const version = output.toString().trim().replace(/,/g, '');

if (version && version.includes(' 2.')) {
if (version && version.includes(' 3.')) {
return _isPythonInstalled = version;
} else {
return _isPythonInstalled = null;
Expand Down