Browse Source

Replace get-pip.py with compiled get-pip.pyc

pull/5/head
Ionite 2 years ago
parent
commit
533da28e3f
No known key found for this signature in database
  1. 3
      .gitignore
  2. BIN
      StabilityMatrix/Assets/Python310/get-pip.pyc
  3. 14
      StabilityMatrix/PyRunner.cs

3
.gitignore vendored

@ -325,7 +325,6 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
@ -395,4 +394,4 @@ FodyWeavers.xsd
*.msp
# JetBrains Rider
*.sln.iml
*.sln.iml

BIN
StabilityMatrix/Assets/Python310/get-pip.py → StabilityMatrix/Assets/Python310/get-pip.pyc

Binary file not shown.

14
StabilityMatrix/PyRunner.cs

@ -21,7 +21,7 @@ internal static class PyRunner
private const string RelativeDllPath = @"Assets\Python310\python310.dll";
private const string RelativeExePath = @"Assets\Python310\python.exe";
private const string RelativePipExePath = @"Assets\Python310\Scripts\pip.exe";
private const string RelativeGetPipPath = @"Assets\Python310\get-pip.py";
private const string RelativeGetPipPath = @"Assets\Python310\get-pip.pyc";
public static string DllPath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RelativeDllPath);
public static string ExePath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RelativeExePath);
public static string PipExePath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RelativePipExePath);
@ -68,7 +68,11 @@ internal static class PyRunner
/// </summary>
public static async Task SetupPip()
{
var p = ProcessRunner.StartProcess(ExePath, GetPipPath);
if (!File.Exists(GetPipPath))
{
throw new FileNotFoundException("get-pip not found", GetPipPath);
}
var p = ProcessRunner.StartProcess(ExePath, "-m get-pip");
await ProcessRunner.WaitForExitConditionAsync(p);
}
@ -77,6 +81,10 @@ internal static class PyRunner
/// </summary>
public static async Task InstallPackage(string package)
{
if (!File.Exists(PipExePath))
{
throw new FileNotFoundException("pip not found", PipExePath);
}
var p = ProcessRunner.StartProcess(PipExePath, $"install {package}");
await ProcessRunner.WaitForExitConditionAsync(p);
}
@ -187,4 +195,4 @@ internal static class PyRunner
});
return version;
}
}
}

Loading…
Cancel
Save