Skip to content

Commit

Permalink
Bug 1844838 - Use default python3 outside MozillaBuild on Windows r=m…
Browse files Browse the repository at this point in the history
…_kato,geckoview-reviewers

The current method fails when Mach is called outside MozillaBuild (https://firefox-source-docs.mozilla.org/mach/windows-usage-outside-mozillabuild.html), as `./mach environment` called inside gradle uses different Python and causes conflict in `~/.mozbuild`.

Differential Revision: https://phabricator.services.mozilla.com/D184255
  • Loading branch information
saschanaz committed Jul 24, 2023
1 parent 7a807d1 commit d2a61d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 3 additions & 0 deletions mobile/android/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import argparse
import logging
import os
import sys

import mozpack.path as mozpath
from mach.decorators import Command, CommandArgument, SubCommand
Expand Down Expand Up @@ -492,6 +493,8 @@ def gradle(command_context, args, verbose=False):
"GRADLE_OPTS": "-Dfile.encoding=utf-8",
"JAVA_HOME": java_home,
"JAVA_TOOL_OPTIONS": "-Dfile.encoding=utf-8",
# Let Gradle get the right Python path on Windows
"GRADLE_MACH_PYTHON": sys.executable,
}
)
# Set ANDROID_SDK_ROOT if --with-android-sdk was set.
Expand Down
11 changes: 2 additions & 9 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@ def topsrcdir = rootProject.projectDir.absolutePath
apply from: "${topsrcdir}/mobile/android/gradle/mach_env.gradle"

def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
if (System.properties['os.name'].toLowerCase().contains('windows')) {
// gradle is called before parsing config.status, we cannot use PYTHON
// value.
if (System.env.MOZILLABUILD) {
def mozillabuild = System.env.MOZILLABUILD.toLowerCase()
if (mozillabuild) {
commandLine.addAll(0, ["${mozillabuild}/python3/python3.exe"])
}
}
if (System.env.GRADLE_MACH_PYTHON) {
commandLine.addAll(0, [System.env.GRADLE_MACH_PYTHON])
}

def proc = commandLine.execute(machEnv(topsrcdir), new File(topsrcdir))
Expand Down

0 comments on commit d2a61d9

Please sign in to comment.