Skip to content

Commit 1fd0c75

Browse files
committed
Install wheel package. Fixes Azure/azure-functions-python-worker#176
1 parent 37f4f9a commit 1fd0c75

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

src/Azure.Functions.Cli/Helpers/PythonHelpers.cs

+10-29
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static async Task InstallPackage()
2121
{
2222
VerifyVirtualEnvironment();
2323
await VerifyVersion();
24-
// await InstallPipWheel();
24+
await InstallPipWheel();
2525
await InstallPythonAzureFunctionPackage();
2626
await PipFreeze();
2727
}
@@ -34,21 +34,6 @@ public static void VerifyVirtualEnvironment()
3434
}
3535
}
3636

37-
private static async Task InstallPythonAzureFunctionPackage()
38-
{
39-
foreach (var package in _workerPackages)
40-
{
41-
ColoredConsole.WriteLine("Installing azure-functions package");
42-
var exe = new Executable("pip", $"install \"{package}\"");
43-
var sb = new StringBuilder();
44-
var exitCode = await exe.RunAsync(l => sb.AppendLine(l), e => sb.AppendLine(e));
45-
if (exitCode != 0)
46-
{
47-
throw new CliException($"Error installing azure package \n{sb.ToString()}");
48-
}
49-
}
50-
}
51-
5237
private static async Task PipFreeze(string path = null)
5338
{
5439
var sb = new StringBuilder();
@@ -68,27 +53,23 @@ private static async Task PipFreeze(string path = null)
6853
}
6954
}
7055

71-
public static async Task InstallPipWheel()
56+
private static Task InstallPythonAzureFunctionPackage() => PipInstallPackages(_workerPackages);
57+
58+
private static Task InstallPipWheel() => PipInstallPackage("wheel");
59+
60+
private static Task PipInstallPackages(IEnumerable<string> packageNames) => Task.WhenAll(packageNames.Select(PipInstallPackage));
61+
62+
private static async Task PipInstallPackage(string packageName)
7263
{
73-
ColoredConsole.WriteLine("Installing wheel package");
74-
var exe = new Executable("pip", "install wheel");
64+
ColoredConsole.WriteLine($"Installing {packageName} package");
65+
var exe = new Executable("pip", $"install {packageName}");
7566
var sb = new StringBuilder();
7667
var exitCode = await exe.RunAsync(l => sb.AppendLine(l), e => sb.AppendLine(e));
7768
if (exitCode != 0)
7869
{
7970
throw new CliException($"Error running '{exe.Command}'. {sb.ToString()}");
8071
}
81-
}
8272

83-
public static async Task DownloadWheels()
84-
{
85-
ColoredConsole.WriteLine("Downloading wheels from requirements.txt to .wheels dir");
86-
var exe = new Executable("pip", "wheel --wheel-dir=.wheels -r requirements.txt");
87-
var exitCode = await exe.RunAsync(l => ColoredConsole.WriteLine(l), e => ColoredConsole.Error.WriteLine(ErrorColor(e)));
88-
if (exitCode != 0)
89-
{
90-
throw new CliException($"Error running '{exe.Command}'.");
91-
}
9273
}
9374

9475
private static async Task VerifyVersion()

0 commit comments

Comments
 (0)