Bug 1750874: Support launching Mach with py instead of python r=glandium

When installing from Python.org, the `python` command isn't available by
default (in favour of `py`). Support using `py` instead.

There were issues running `hg` when `python` isn't added to the `PATH`,
so the docs are being updated accordingly.
Of course, it's still worth supporting `py`-instead-of-`python`
workflows for `git` users who won't be impacted by that bug.

Differential Revision: https://phabricator.services.mozilla.com/D136286
This commit is contained in:
Mitchell Hentges
2022-01-21 18:22:58 +00:00
parent bd4c5503dd
commit d7f6252622
3 changed files with 19 additions and 4 deletions

View File

@@ -1,3 +1,9 @@
@ECHO OFF @ECHO OFF
SET topsrcdir=%~dp0 SET topsrcdir=%~dp0
python %topsrcdir%mach %*
WHERE /q py
IF %ERRORLEVEL% EQU 0 (
py %topsrcdir%mach %*
) ELSE (
python %topsrcdir%mach %*
)

View File

@@ -1,8 +1,14 @@
$mypath = $MyInvocation.MyCommand.Path $mypath = $MyInvocation.MyCommand.Path
$machpath = ($mypath -replace '\\', '/').substring(0, $mypath.length - 4) $machpath = $mypath.substring(0, $mypath.length - 4)
if (Get-Command py) {
$python_executable = "py"
} else {
$python_executable = "python"
}
if (-not (test-path env:MACH_PS1_USE_MOZILLABUILD)) { if (-not (test-path env:MACH_PS1_USE_MOZILLABUILD)) {
python $machpath $args &$python_executable $machpath $args
exit $lastexitcode exit $lastexitcode
} }
@@ -11,6 +17,8 @@ if (-not (test-path env:MOZILLABUILD)) {
exit 1 exit 1
} }
$machpath = ($machpath -replace '\\', '/')
if ($machpath.contains(' ')) { if ($machpath.contains(' ')) {
echo @' echo @'
The repository path contains whitespace which currently isn't supported in mach.ps1. The repository path contains whitespace which currently isn't supported in mach.ps1.

View File

@@ -55,7 +55,8 @@ Download Python from the `the official website <https://www.python.org/downloads
version is 3.10.1, so a safe version to install would be the most recent 3.9 release. version is 3.10.1, so a safe version to install would be the most recent 3.9 release.
You'll want to download the "Windows installer (64-bit)" associated with the release you've chosen. You'll want to download the "Windows installer (64-bit)" associated with the release you've chosen.
During installation, ensure that you check the "Add Python 3.x to PATH" option. During installation, ensure that you check the "Add Python 3.x to PATH" option, otherwise you might
`encounter issues running Mercurial <https://bz.mercurial-scm.org/show_bug.cgi?id=6635>`__.
.. note:: .. note::