Browse Source

Fix PyVenvRunner binary paths for unix

pull/55/head
Ionite 1 year ago
parent
commit
519d222619
No known key found for this signature in database
  1. 4
      StabilityMatrix.Core/Models/FileInterfaces/FileSystemPath.cs
  2. 10
      StabilityMatrix.Core/Python/PyVenvRunner.cs

4
StabilityMatrix.Core/Models/FileInterfaces/FileSystemPath.cs

@ -48,4 +48,8 @@ public class FileSystemPath : IEquatable<FileSystemPath>, IEquatable<string>
{
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);
}

10
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;
/// <summary>
/// Python runner using a subprocess, mainly for venv support.
/// </summary>
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public class PyVenvRunner : IDisposable
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
@ -34,12 +36,16 @@ public class PyVenvRunner : IDisposable
/// <summary>
/// The path to the python executable.
/// </summary>
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")));
/// <summary>
/// The path to the pip executable.
/// </summary>
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")));
/// <summary>
/// List of substrings to suppress from the output.

Loading…
Cancel
Save