diff --git a/Python_Engine/Python_Engine.csproj b/Python_Engine/Python_Engine.csproj
index af1c467..045acaa 100644
--- a/Python_Engine/Python_Engine.csproj
+++ b/Python_Engine/Python_Engine.csproj
@@ -40,11 +40,11 @@
-
+
-
+
diff --git a/Python_Engine/Query/Directory.cs b/Python_Engine/Query/Directory.cs
index df18193..59b7c12 100644
--- a/Python_Engine/Query/Directory.cs
+++ b/Python_Engine/Query/Directory.cs
@@ -33,28 +33,38 @@ public static partial class Query
[Output("The location where BHoM extensions reside.")]
public static string DirectoryExtensions()
{
- return @"C:\ProgramData\BHoM\Extensions";
+ return Path.Combine(System.IO.Directory.GetParent(BH.Engine.Base.Query.BHoMFolder()).FullName, "Extensions");
}
[Description("The location where any BHoM-related Python kernels reside.")]
[Output("The location where any BHoM-related Python kernels reside.")]
public static string DirectoryKernels()
{
- return @"C:\ProgramData\jupyter\kernels";
+
+ string dir = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData), "jupyter", "kernels");
+ if (!Directory.Exists(dir))
+ Directory.CreateDirectory(dir);
+ return dir;
}
[Description("The location where any BHoM-related Python code resides.")]
[Output("The location where any BHoM-related Python code resides.")]
public static string DirectoryCode()
{
- return Path.Combine(Query.DirectoryExtensions(), "PythonCode");
+ string dir = Path.Combine(Query.DirectoryExtensions(), "PythonCode");
+ if (!Directory.Exists(dir))
+ Directory.CreateDirectory(dir);
+ return dir;
}
[Description("The location where any BHoM-related Python environment (or virtualenv) resides.")]
[Output("The location where any BHoM-related Python environment (or virtualenv) resides.")]
public static string DirectoryEnvironments()
{
- return Path.Combine(Query.DirectoryExtensions(), "PythonEnvironments");
+ string dir = Path.Combine(Query.DirectoryExtensions(), "PythonEnvironments");
+ if (!Directory.Exists(dir))
+ Directory.CreateDirectory(dir);
+ return dir;
}
[Description("The location where the base Python environment exists.")]
diff --git a/Python_Engine/Query/VirtualEnvironment.cs b/Python_Engine/Query/VirtualEnvironment.cs
index 2a740ea..1ba4839 100644
--- a/Python_Engine/Query/VirtualEnvironment.cs
+++ b/Python_Engine/Query/VirtualEnvironment.cs
@@ -36,10 +36,20 @@ public static partial class Query
{
[Description("Check whether a named BHoM Python virtual environment exists.")]
[Input("envName", "The name given to the BHoM Python Environment.")]
+ [Input("pythonVersion", "The version to check against.")]
[Output("exists", "True if exists, False if not.")]
- public static bool VirtualEnvironmentExists(string envName)
+ [PreviousVersion("7.0", "BH.Engine.Python.Query.VirtualEnvironmentExists(System.String)")]
+ public static bool VirtualEnvironmentExists(string envName, PythonVersion pythonVersion = PythonVersion.Undefined)
{
- return Directory.Exists(VirtualEnvironmentDirectory(envName)) && File.Exists(VirtualEnvironmentExecutable(envName)) && Directory.Exists(VirtualEnvironmentKernel(envName));
+ bool directoryExists = Directory.Exists(VirtualEnvironmentDirectory(envName));
+ bool executableExists = File.Exists(VirtualEnvironmentExecutable(envName));
+ bool kernelExists = Directory.Exists(VirtualEnvironmentKernel(envName));
+ bool versionMatches = Version(VirtualEnvironmentExecutable(envName)) == pythonVersion;
+
+ if (pythonVersion == PythonVersion.Undefined)
+ return directoryExists && executableExists && kernelExists;
+
+ return directoryExists && executableExists && kernelExists && versionMatches;
}
[Description("Get the path to the named BHoM Python virtual environment kernel.")]
diff --git a/Python_oM/Python_oM.csproj b/Python_oM/Python_oM.csproj
index 9f4de2a..742327a 100644
--- a/Python_oM/Python_oM.csproj
+++ b/Python_oM/Python_oM.csproj
@@ -21,7 +21,7 @@
-
+