Skip to content

Commit

Permalink
Merge pull request pyrevitlabs#2535 from reformstudios/dev/2527
Browse files Browse the repository at this point in the history
fix: incorrect handling of PYTHONPATH in SetupSearchPaths()
  • Loading branch information
jmcouffin authored Jan 25, 2025
2 parents 7ee88d8 + 1d26630 commit a00956d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions dev/pyRevitLabs.PyRevit.Runtime/CPythonEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,18 @@ private void SetupSearchPaths(ref ScriptRuntime runtime) {
// set sys paths
PyList sysPaths = RestoreSearchPaths();

// manually add PYTHONPATH since we are overwriting the sys paths
// manually add each path in PYTHONPATH since we are overwriting the sys paths
var pythonPath = Environment.GetEnvironmentVariable("PYTHONPATH");
if (!string.IsNullOrEmpty(pythonPath))
{
sysPaths.Append(new PyString(pythonPath));
var paths = pythonPath.Split(Path.PathSeparator);
foreach (var path in paths)
{
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path))
{
sysPaths.Append(new PyString(path));
}
}
}

// now add the search paths for the script bundle
Expand Down

0 comments on commit a00956d

Please sign in to comment.