Make work for both debug and live

This commit is contained in:
2026-02-16 09:57:52 -08:00
parent 179ffb0fbf
commit e26fd7a3fc
2 changed files with 10 additions and 9 deletions
+4 -7
View File
@@ -4,18 +4,15 @@ namespace PythonInterop {
public class AIModule { public class AIModule {
public AIModule(string PythonPath = "/usr/local/lib/libpython3.11.so") { public AIModule(string PythonPathBase = "/usr/local/", string PythonVersion = "python3.11") {
// Use the user provided python runner // Use the user provided python runner
Runtime.PythonDLL = PythonPath; Runtime.PythonDLL = PythonPathBase + $"lib/lib{PythonVersion}.so";
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
string pythonFiles = Path.Combine(baseDir, "AIPython");
// Use our local environment for the python libraries // Use our local environment for the python libraries
PythonEngine.PythonHome = "/usr/local"; PythonEngine.PythonHome = PythonPathBase;
// Include all the paths for python packages most importantly our venv // Include all the paths for python packages most importantly our venv
PythonEngine.PythonPath = $"/usr/local/lib/python3.11:/usr/local/lib/python3.11/lib-dynload:/usr/local/lib/python3.11/site-packages:{pythonFiles}"; PythonEngine.PythonPath = $"{PythonPathBase}lib/{PythonVersion}:{PythonPathBase}lib/{PythonVersion}/lib-dynload:{PythonPathBase}lib/{PythonVersion}/site-packages:{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AIPython")}";
// Initiilize python // Initiilize python
PythonEngine.Initialize(); PythonEngine.Initialize();
+6 -2
View File
@@ -16,8 +16,12 @@ if (!app.Environment.IsDevelopment()) {
app.UseHsts(); app.UseHsts();
} }
// Load the module in globally // Load the module in globally and use correct path for local or docker runners
AIModule interopModule = new AIModule(); #if DEBUG
AIModule interopModule = new AIModule(PythonPathBase: "/usr/", PythonVersion: "python3.11");
#else
AIModule interopModule = new AIModule();
#endif
// Run this for testing purposes // Run this for testing purposes
interopModule.TestAI(); interopModule.TestAI();