-
Notifications
You must be signed in to change notification settings - Fork 4
Extract wheels directly from resource #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
0d2db1b
338896c
0176117
2675af4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ | |
| internal class DynamoCPythonHandleComparer : IEqualityComparer<DynamoCPythonHandle> | ||
| { | ||
|
|
||
| public bool Equals(DynamoCPythonHandle x, DynamoCPythonHandle y) | ||
|
Check warning on line 23 in DSPythonNet3/DSPythonNet3Evaluator.cs
|
||
| { | ||
| return x.PythonObjectID.Equals(y.PythonObjectID); | ||
| } | ||
|
|
@@ -74,7 +74,7 @@ | |
| try | ||
| { | ||
| var pyobj = DSPythonNet3Evaluator.globalScope.Get(PythonObjectID.ToString()); | ||
| return pyobj.ToString(); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
|
|
@@ -143,8 +143,8 @@ | |
| { // Session is null when running unit tests. | ||
| if (ExecutionEvents.ActiveSession != null) | ||
| { | ||
| dynamoLogger = ExecutionEvents.ActiveSession.GetParameterValue(ParameterKeys.Logger) as DynamoLogger; | ||
| return dynamoLogger; | ||
| } | ||
| return dynamoLogger; | ||
| } | ||
|
|
@@ -370,21 +370,55 @@ | |
|
|
||
| Assembly wheelsAssembly = context.LoadFromAssemblyPath(Path.Join(Path.GetDirectoryName(assembly.Location), "DSPythonNet3Wheels.dll")); | ||
|
|
||
| string sitePkgsPath = Path.Combine(Python.Included.Installer.EmbeddedPythonHome, "Lib", "site-packages"); | ||
| Directory.CreateDirectory(sitePkgsPath); | ||
|
|
||
| List<string> pipWheelInstall = new List<string>(); | ||
| await Task.WhenAll(wheelsAssembly.GetManifestResourceNames().Where(x => | ||
|
|
||
| // Extract noo-pip wheels directly from the resource stream | ||
| foreach (var resName in wheelsAssembly.GetManifestResourceNames()) | ||
| { | ||
| bool isWheel = x.Contains(".whl"); | ||
| if (isWheel && x.Contains("pywin32-")) | ||
| bool isWheel = resName.EndsWith(".whl"); | ||
| if (!isWheel) continue; | ||
|
|
||
| if (resName.Contains("pywin32-")) | ||
| { | ||
| pipWheelInstall.Add(x); | ||
| return false; | ||
| pipWheelInstall.Add(resName); | ||
| continue; | ||
| } | ||
|
|
||
| return isWheel; | ||
| }).Select(wheel => Python.Included.Installer.InstallWheel(wheelsAssembly, wheel))).ConfigureAwait(false); | ||
| using (var stream = wheelsAssembly.GetManifestResourceStream(resName)) | ||
| { | ||
| if (stream == null || stream.Length == 0) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| using (var zip = new System.IO.Compression.ZipArchive(stream, System.IO.Compression.ZipArchiveMode.Read, false)) | ||
| { | ||
| foreach (var entry in zip.Entries) | ||
| { | ||
| if (string.IsNullOrEmpty(entry.Name)) continue; | ||
|
|
||
| var destPath = Path.Combine(sitePkgsPath, entry.FullName.Replace('/', Path.DirectorySeparatorChar)); | ||
ivaylo-matov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var destDir = Path.GetDirectoryName(destPath); | ||
| if (!string.IsNullOrEmpty(destDir)) | ||
| { | ||
| Directory.CreateDirectory(destDir); | ||
| } | ||
|
|
||
| using (var inStream = entry.Open()) | ||
| using (var outStream = new FileStream(destPath, FileMode.Create, FileAccess.Write, FileShare.None)) | ||
| { | ||
| await inStream.CopyToAsync(outStream).ConfigureAwait(false); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
383
to
431
|
||
|
|
||
| foreach (var pipWheelResource in pipWheelInstall) | ||
| { | ||
| { | ||
| var pipWheelName = pipWheelResource.Remove(0, "DSPythonNet3Wheels.Resources.".Count()); | ||
| string wheelPath = Path.Combine(Python.Included.Installer.EmbeddedPythonHome, "Lib", pipWheelName); | ||
| using (Stream? stream = wheelsAssembly.GetManifestResourceStream(pipWheelResource)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.