Skip to content

Commit 0492b82

Browse files
author
Mitchell Hentges
committed
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
1 parent a37e781 commit 0492b82

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

mach.cmd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
@ECHO OFF
22
SET topsrcdir=%~dp0
3-
python %topsrcdir%mach %*
3+
4+
WHERE /q py
5+
IF %ERRORLEVEL% EQU 0 (
6+
py %topsrcdir%mach %*
7+
) ELSE (
8+
python %topsrcdir%mach %*
9+
)

mach.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
$mypath = $MyInvocation.MyCommand.Path
2-
$machpath = ($mypath -replace '\\', '/').substring(0, $mypath.length - 4)
2+
$machpath = $mypath.substring(0, $mypath.length - 4)
3+
4+
if (Get-Command py) {
5+
$python_executable = "py"
6+
} else {
7+
$python_executable = "python"
8+
}
39

410
if (-not (test-path env:MACH_PS1_USE_MOZILLABUILD)) {
5-
python $machpath $args
11+
&$python_executable $machpath $args
612
exit $lastexitcode
713
}
814

@@ -11,6 +17,8 @@ if (-not (test-path env:MOZILLABUILD)) {
1117
exit 1
1218
}
1319

20+
$machpath = ($machpath -replace '\\', '/')
21+
1422
if ($machpath.contains(' ')) {
1523
echo @'
1624
The repository path contains whitespace which currently isn't supported in mach.ps1.

python/mach/docs/windows-usage-outside-mozillabuild.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ Download Python from the `the official website <https://www.python.org/downloads
5555
version is 3.10.1, so a safe version to install would be the most recent 3.9 release.
5656

5757
You'll want to download the "Windows installer (64-bit)" associated with the release you've chosen.
58-
During installation, ensure that you check the "Add Python 3.x to PATH" option.
58+
During installation, ensure that you check the "Add Python 3.x to PATH" option, otherwise you might
59+
`encounter issues running Mercurial <https://bz.mercurial-scm.org/show_bug.cgi?id=6635>`__.
5960

6061
.. note::
6162

0 commit comments

Comments
 (0)