Skip to content

Commit ea8a717

Browse files
committed
Install wheels.
1 parent f63105c commit ea8a717

23 files changed

+50
-7
lines changed

DSPythonNet3/DSPythonNet3.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
<LastGenOutput>Resources.en-US.Designer.cs</LastGenOutput>
3939
</EmbeddedResource>
4040
</ItemGroup>
41+
<ItemGroup>
42+
<ProjectReference Include="..\DSPythonNet3Wheels\DSPythonNet3Wheels.csproj" />
43+
</ItemGroup>
4144
<ItemGroup>
4245
<None Update="pkg.json">
4346
<TargetPath>..\%(Filename)%(Extension)</TargetPath>

DSPythonNet3/DSPythonNet3CodeCompletionProviderCore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import clr
7171

7272
private object ExecutePythonScriptCode(string code)
7373
{
74-
DSPythonNet3Evaluator.InstallPython();
74+
DSPythonNet3Evaluator.InstallPythonAsync().Wait();
7575

7676
if (!PythonEngine.IsInitialized)
7777
{
@@ -375,7 +375,7 @@ public DSPythonNet3CodeCompletionProviderCore()
375375
BasicVariableTypes.Add(Tuple.Create(LIST_VARIABLE, typeof(PyList)));
376376
BasicVariableTypes.Add(Tuple.Create(DICT_VARIABLE, typeof(PyDict)));
377377

378-
DSPythonNet3Evaluator.InstallPython();
378+
DSPythonNet3Evaluator.InstallPythonAsync().Wait();
379379

380380
if (!PythonEngine.IsInitialized)
381381
{

DSPythonNet3/DSPythonNet3Evaluator.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public override object Evaluate(
247247
return null;
248248
}
249249

250-
InstallPython();
250+
InstallPythonAsync().Wait();
251251
if (!PythonEngine.IsInitialized)
252252
{
253253
PythonEngine.Initialize();
@@ -322,7 +322,7 @@ public static object EvaluatePythonScript(
322322
/// NOTE: Calling SetupPython multiple times will add the install location to the path many times,
323323
/// potentially causing the environment variable to overflow.
324324
/// </summary>
325-
internal static void InstallPython()
325+
internal static async Task InstallPythonAsync()
326326
{
327327
if (!isPythonInstalled)
328328
{
@@ -340,7 +340,11 @@ internal static void InstallPython()
340340
Python.Included.PythonEnv.DeployEmbeddedPython = false;
341341
}
342342

343-
Python.Included.Installer.SetupPython().Wait();
343+
await Python.Included.Installer.SetupPython();
344+
345+
Assembly wheelsAssembly = Assembly.LoadFile(Path.Join(Path.GetDirectoryName(Assembly.GetAssembly(typeof(DSPythonNet3Evaluator)).Location), "DSPythonNet3Wheels.dll") );
346+
await Task.WhenAll(wheelsAssembly.GetManifestResourceNames().Where(x => x.Contains(".whl")).Select(wheel => Python.Included.Installer.InstallWheel(wheelsAssembly, wheel)));
347+
344348
isPythonInstalled = true;
345349
}
346350
catch (Exception e)
@@ -438,7 +442,7 @@ private static void InitializeEncoders()
438442
/// </summary>
439443
/// <param name="e">Exception to inspect</param>
440444
/// <returns>Trace back message</returns>
441-
private static string GetTraceBack(Exception e)
445+
private static string? GetTraceBack(Exception e)
442446
{
443447
if (e is not PythonException pythonExc || pythonExc.Traceback == null)
444448
{
@@ -452,7 +456,7 @@ private static string GetTraceBack(Exception e)
452456
throw new NotSupportedException(Properties.Resources.InternalErrorTraceBackInfo);
453457
}
454458

455-
return (string)field.Invoke(pythonExc, [pythonExc.Traceback]);
459+
return (string?)field.Invoke(pythonExc, [pythonExc.Traceback]);
456460
}
457461

458462
#region Marshalling
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputPath>$(BuildOutput)extra\</OutputPath>
4+
</PropertyGroup>
5+
6+
<ItemGroup>
7+
<None Remove="Resources\*.whl" />
8+
<EmbeddedResource Include="Resources\*.whl" />
9+
</ItemGroup>
10+
11+
<Target Name="UpdateWheels">
12+
<RemoveDir Directories="Resources" />
13+
<MakeDir Directories="Resources" />
14+
<Exec Command="pip download --only-binary :all: --platform win_amd64 --implementation cp --python-version 3.11 --dest Resources --no-cache -r requirements.txt" />
15+
</Target>
16+
</Project>
Binary file not shown.
8.13 KB
Binary file not shown.
17.6 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)