From 6389107e19e7807f28de4020f8ad3cc2a1f11bfc Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Fri, 8 Jul 2016 17:10:58 +1000 Subject: [PATCH 1/3] Detect python2.7.exe on windows Latest python2 package on msys2 installs the executable file to python2.7.exe rather than python27.exe. --- components/style/build.rs | 7 ++++++- ports/geckolib/build.rs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/style/build.rs b/components/style/build.rs index 0f824c498c8..23ee9d55e07 100644 --- a/components/style/build.rs +++ b/components/style/build.rs @@ -11,6 +11,10 @@ use walkdir::WalkDir; #[cfg(windows)] fn find_python() -> String { + if Command::new("python2.7.exe").arg("--version").output().is_ok() { + return "python2.7.exe".to_owned(); + } + if Command::new("python27.exe").arg("--version").output().is_ok() { return "python27.exe".to_owned(); } @@ -19,7 +23,8 @@ fn find_python() -> String { return "python.exe".to_owned(); } - panic!("Can't find python (tried python27.exe and python.exe)! Try fixing PATH or setting the PYTHON env var"); + panic!(concat!("Can't find python (tried python2.7.exe, python27.exe, and python.exe)! ", + "Try fixing PATH or setting the PYTHON env var")); } #[cfg(not(windows))] diff --git a/ports/geckolib/build.rs b/ports/geckolib/build.rs index 17da2b459e4..fbcedacde80 100644 --- a/ports/geckolib/build.rs +++ b/ports/geckolib/build.rs @@ -8,6 +8,10 @@ use std::process::{Command, exit}; #[cfg(windows)] fn find_python() -> String { + if Command::new("python2.7.exe").arg("--version").output().is_ok() { + return "python2.7.exe".to_owned(); + } + if Command::new("python27.exe").arg("--version").output().is_ok() { return "python27.exe".to_owned(); } @@ -16,7 +20,8 @@ fn find_python() -> String { return "python.exe".to_owned(); } - panic!("Can't find python (tried python27.exe and python.exe)! Try fixing PATH or setting the PYTHON env var"); + panic!(concat!("Can't find python (tried python2.7.exe, python27.exe, and python.exe)! ", + "Try fixing PATH or setting the PYTHON env var")); } #[cfg(not(windows))] From 064f1adb78dc4967809ffc232837a823253780fa Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Fri, 8 Jul 2016 17:14:33 +1000 Subject: [PATCH 2/3] Get the build env before change dir Otherwise, build_env may fail to find git information. --- python/servo/build_commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index f43f234a3a2..7a4dba41cfa 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -368,9 +368,10 @@ class MachCommands(CommandBase): opts += ["--release"] build_start = time() + env = self.build_env() with cd(path.join("ports", "geckolib")): ret = call(["cargo", "build"] + opts, - env=self.build_env(), verbose=verbose) + env=env, verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value From 6519d06b235858376c16807cee579171b77e3535 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Fri, 8 Jul 2016 17:15:54 +1000 Subject: [PATCH 3/3] Replace windows path sep with unix sep It seems python in msys2 has some weird behavior. For __file__, it returns a string which uses windows-style separator '\', however, os.path.dirname only recognizes the unix-style separator '/', and consequently, the path of Mako is not added properly. --- components/style/properties/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/style/properties/build.py b/components/style/properties/build.py index 28a9b59019f..eeb78817f3f 100644 --- a/components/style/properties/build.py +++ b/components/style/properties/build.py @@ -6,7 +6,7 @@ import json import os.path import sys -BASE = os.path.dirname(__file__) +BASE = os.path.dirname(__file__.replace('\\', '/')) sys.path.insert(0, os.path.join(BASE, "Mako-0.9.1.zip")) sys.path.insert(0, BASE) # For importing `data.py`