Skip to content

Commit

Permalink
Bug 1750874: Support launching Mach with py instead of python r=g…
Browse files Browse the repository at this point in the history
…landium

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
  • Loading branch information
Mitchell Hentges committed Jan 21, 2022
1 parent a37e781 commit 0492b82
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion mach.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
@ECHO OFF
SET topsrcdir=%~dp0
python %topsrcdir%mach %*

WHERE /q py
IF %ERRORLEVEL% EQU 0 (
py %topsrcdir%mach %*
) ELSE (
python %topsrcdir%mach %*
)
12 changes: 10 additions & 2 deletions mach.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
$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)) {
python $machpath $args
&$python_executable $machpath $args
exit $lastexitcode
}

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

$machpath = ($machpath -replace '\\', '/')

if ($machpath.contains(' ')) {
echo @'
The repository path contains whitespace which currently isn't supported in mach.ps1.
Expand Down
3 changes: 2 additions & 1 deletion python/mach/docs/windows-usage-outside-mozillabuild.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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::

Expand Down

0 comments on commit 0492b82

Please sign in to comment.