Closed Bug 1755535 Opened 2 years ago Closed 2 years ago

js-format and clang-format attempt to call `hg.exe mach ...` on Windows

Categories

(Developer Infrastructure :: Lint and Formatting, defect, P5)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: barret, Assigned: sheehan)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Apparently, when you run hg.exe, sys.executable is actually hg.exe and not the relevant python.exe:

Barret@FOXYSHAZAM ~\W\s\h\mozilla-central $ hg amend
> c:\users\barret\.mozbuild\version-control-tools\hgext\js-format\__init__.py(38)find_python()
-> return pycompat.bytestr(sys.executable) if sys.version_info[0] >= 3 else b"python3"
(Pdb) sys.executable
'C:\\Users\\Barret\\AppData\\Roaming\\Python\\Python39\\Scripts\\hg.exe'

This makes both clang-format and js-format hooks not run

I didn't even know this was possible. :)

Chatted briefly with Mitch on Slack. I think instead of trying to find an appropriate Python in the hgext, we should instead look for an appropriate mach entrypoint depending on the environment. If we're on Windows but not MozillaBuild, we call mach.ps1. All other platforms (Windows with MozillaBuild, Linux, macOS) we can just call mach. Then mach and hg can each deal with their own Python independently of each other.

Assignee: nobody → sheehan

Previously we added a find_python function to locate an appropriate
Python install to use to run mach, however due to the way hg.exe
is produced on Windows this proved unsuccessful.

The actual goal here is to be able to run mach <formatter>
on all platforms. We were attempting to locate a suitable
Python for mach since standard, non-MozillaBuild Windows can't
directly execute the mach script. Since standard Windows installs
can execute mach as a standalone command via mach.ps1, we
switch find_python to a find_mach command which returns the
appropriate entry script depending on an inspection of the
environment and operating system.

Has Regression Range: --- → yes

The severity field is not set for this bug.
:ahal, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(ahal)

Low priority and severity, at least until MozillaBuild 4.0 lands.

Severity: -- → S3
Flags: needinfo?(ahal)
Priority: -- → P5
Attachment #9264040 - Attachment description: hgext/*-format: replace `find_python` with `find_mach` (Bug 1755535) r?mhentges → hgext/*-format: run `mach` through `python` and add more Python variants (Bug 1755535) r?mhentges

Pushed by cosheehan@mozilla.com:
https://hg.mozilla.org/hgcustom/version-control-tools/rev/9aa7f89cdea2
hgext/*-format: run mach through python and add more Python variants r=mhentges

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: