From 519d2226197ff201d19ca7ddf712b33fdedfce49 Mon Sep 17 00:00:00 2001 From: Ionite Date: Mon, 17 Jul 2023 17:50:13 -0400 Subject: [PATCH] Fix PyVenvRunner binary paths for unix --- .../Models/FileInterfaces/FileSystemPath.cs | 4 ++++ StabilityMatrix.Core/Python/PyVenvRunner.cs | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/StabilityMatrix.Core/Models/FileInterfaces/FileSystemPath.cs b/StabilityMatrix.Core/Models/FileInterfaces/FileSystemPath.cs index ad572e7e..e9d22fa2 100644 --- a/StabilityMatrix.Core/Models/FileInterfaces/FileSystemPath.cs +++ b/StabilityMatrix.Core/Models/FileInterfaces/FileSystemPath.cs @@ -48,4 +48,8 @@ public class FileSystemPath : IEquatable, IEquatable { return FullPath.GetHashCode(); } + + // Implicit conversions to and from string + public static implicit operator string(FileSystemPath path) => path.FullPath; + public static implicit operator FileSystemPath(string path) => new(path); } diff --git a/StabilityMatrix.Core/Python/PyVenvRunner.cs b/StabilityMatrix.Core/Python/PyVenvRunner.cs index 69bb6210..09ddc640 100644 --- a/StabilityMatrix.Core/Python/PyVenvRunner.cs +++ b/StabilityMatrix.Core/Python/PyVenvRunner.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using NLog; using Salaros.Configuration; using StabilityMatrix.Core.Helper; @@ -10,6 +11,7 @@ namespace StabilityMatrix.Core.Python; /// /// Python runner using a subprocess, mainly for venv support. /// +[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class PyVenvRunner : IDisposable { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -34,12 +36,16 @@ public class PyVenvRunner : IDisposable /// /// The path to the python executable. /// - public FilePath PythonPath => RootPath + @"Scripts\python.exe"; + public FilePath PythonPath => Compat.Switch( + (PlatformKind.Windows, RootPath.JoinFile("Scripts", "python.exe")), + (PlatformKind.Unix, RootPath.JoinFile("bin", "python3.10"))); /// /// The path to the pip executable. /// - public FilePath PipPath => RootPath + @"Scripts\pip.exe"; + public FilePath PipPath => Compat.Switch( + (PlatformKind.Windows, RootPath.JoinFile("Scripts", "pip.exe")), + (PlatformKind.Unix, RootPath.JoinFile("bin", "pip3.10"))); /// /// List of substrings to suppress from the output.