iOS: fail build wth error if Python six missing (#9135)
Xcode builds depend on the Python 'six' module. If not present, exit immediately with a useful error message. The six module is included in the system default Python installation. We perform this check in case a custom Python install has higher priority on $PATH; e.g., due to a Homebrew or MacPorts installation. This extracts an existing doctor check to use it during the build step as well.
This commit is contained in:
@@ -41,7 +41,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
|
||||
|
||||
bool get hasHomebrew => os.which('brew') != null;
|
||||
|
||||
bool get hasPythonSixModule => exitsHappy(<String>['python', '-c', 'import six']);
|
||||
bool get hasPythonSixModule => kPythonSix.isInstalled;
|
||||
|
||||
bool get hasCocoaPods => exitsHappy(<String>['pod', '--version']);
|
||||
|
||||
@@ -124,10 +124,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
|
||||
pythonStatus = ValidationType.installed;
|
||||
} else {
|
||||
pythonStatus = ValidationType.missing;
|
||||
messages.add(new ValidationMessage.error(
|
||||
'Python installation missing module "six".\n'
|
||||
'Install via \'pip install six\' or \'sudo easy_install six\'.'
|
||||
));
|
||||
messages.add(new ValidationMessage.error(kPythonSix.errorMessage));
|
||||
}
|
||||
|
||||
// brew installed
|
||||
|
||||
@@ -27,6 +27,23 @@ import 'xcodeproj.dart';
|
||||
const int kXcodeRequiredVersionMajor = 7;
|
||||
const int kXcodeRequiredVersionMinor = 0;
|
||||
|
||||
// The Python `six` module is a dependency for Xcode builds, and installed by
|
||||
// default, but may not be present in custom Python installs; e.g., via
|
||||
// Homebrew.
|
||||
const PythonModule kPythonSix = const PythonModule('six');
|
||||
|
||||
class PythonModule {
|
||||
const PythonModule(this.name);
|
||||
|
||||
final String name;
|
||||
|
||||
bool get isInstalled => exitsHappy(<String>['python', '-c', 'import $name']);
|
||||
|
||||
String get errorMessage =>
|
||||
'Missing Xcode dependency: Python module "$name".\n'
|
||||
'Install via \'pip install $name\' or \'sudo easy_install $name\'.';
|
||||
}
|
||||
|
||||
class Xcode {
|
||||
Xcode() {
|
||||
_eulaSigned = false;
|
||||
@@ -125,6 +142,11 @@ Future<XcodeBuildResult> buildXcodeProject({
|
||||
if (!_checkXcodeVersion())
|
||||
return new XcodeBuildResult(success: false);
|
||||
|
||||
if (!kPythonSix.isInstalled) {
|
||||
printError(kPythonSix.errorMessage);
|
||||
return new XcodeBuildResult(success: false);
|
||||
}
|
||||
|
||||
// Before the build, all service definitions must be updated and the dylibs
|
||||
// copied over to a location that is suitable for Xcodebuild to find them.
|
||||
final Directory appDirectory = fs.directory(app.appDirectory);
|
||||
|
||||
Reference in New Issue
Block a user