Skip to content

Commit

Permalink
Merge pull request #203 from RussKie/windows_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybaloney authored Sep 17, 2024
2 parents 895d89d + 489c1ad commit b9a6b8d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
4 changes: 0 additions & 4 deletions src/CSnakes.Runtime.Tests/CSnakes.Runtime.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,4 @@
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<Folder Include="Locators\" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/CSnakes.Runtime.Tests/RuntimeTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class RuntimeTestBase : IDisposable

public RuntimeTestBase()
{
string pythonVersionWindows = "3.12.4";
string pythonVersionWindows = Environment.GetEnvironmentVariable("PYTHON_VERSION") ?? "3.12.4";
string pythonVersionMacOS = Environment.GetEnvironmentVariable("PYTHON_VERSION") ?? "3.12";
string pythonVersionLinux = Environment.GetEnvironmentVariable("PYTHON_VERSION") ?? "3.12";

Expand Down
11 changes: 10 additions & 1 deletion src/CSnakes.Runtime/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ public static Version ParsePythonVersion(string version)
/// <returns>The modified <see cref="IPythonEnvironmentBuilder"/>.</returns>
public static IPythonEnvironmentBuilder FromNuGet(this IPythonEnvironmentBuilder builder, string version)
{
builder.Services.AddSingleton<PythonLocator>(new NuGetLocator(ParsePythonVersion(version)));
// See https://github.com/tonybaloney/CSnakes/issues/154#issuecomment-2352116849
version = version.Replace("alpha.", "a").Replace("beta.", "b").Replace("rc.", "rc");

// If a supplied version only consists of 2 tokens - e.g., 1.10 or 2.14 - then append an extra token
if (version.Count(c => c == '.') < 2)
{
version = $"{version}.0";
}

builder.Services.AddSingleton<PythonLocator>(new NuGetLocator(version, ParsePythonVersion(version)));
return builder;
}

Expand Down
3 changes: 2 additions & 1 deletion src/CSnakes.Runtime/Locators/EnvironmentVariableLocator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace CSnakes.Runtime.Locators;

internal class EnvironmentVariableLocator(string variable, Version version) : PythonLocator(version)
{
public override PythonLocationMetadata LocatePython()
Expand All @@ -11,4 +12,4 @@ public override PythonLocationMetadata LocatePython()

return LocatePythonInternal(envValue);
}
}
}
5 changes: 3 additions & 2 deletions src/CSnakes.Runtime/Locators/NuGetLocator.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Runtime.InteropServices;

namespace CSnakes.Runtime.Locators;
internal class NuGetLocator(Version version) : PythonLocator(version)

internal class NuGetLocator(string nugetVersion, Version version) : PythonLocator(version)
{
public override PythonLocationMetadata LocatePython()
{
Expand All @@ -13,7 +14,7 @@ public override PythonLocationMetadata LocatePython()
}
string? globalNugetPackagesPath = string.IsNullOrEmpty(nugetPackagesOverride) ? Path.Combine(userProfile, ".nuget", "packages") : nugetPackagesOverride;

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / publish-github-packages

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / publish-github-packages

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.13.0-rc.1, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.13.0-rc.1, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.13.0-rc.1, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.13.0-rc.1, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.13.0-rc.1, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.13.0-rc.1, 8.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12, 6.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12, 6.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12, 7.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12, 7.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12, 9.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check warning on line 15 in src/CSnakes.Runtime/Locators/NuGetLocator.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12, 9.0.x)

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.
// TODO : Load optional path from nuget settings. https://learn.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders
string nugetPath = Path.Combine(globalNugetPackagesPath!, "python", $"{Version.Major}.{Version.Minor}.{Version.Build}", "tools");
string nugetPath = Path.Combine(globalNugetPackagesPath!, "python", nugetVersion, "tools");
return LocatePythonInternal(nugetPath);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Integration.Tests/IntegrationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class IntegrationTestBase : IDisposable

public IntegrationTestBase()
{
string pythonVersionWindows = "3.12.4";
string pythonVersionWindows = Environment.GetEnvironmentVariable("PYTHON_VERSION") ?? "3.12.4";
string pythonVersionMacOS = Environment.GetEnvironmentVariable("PYTHON_VERSION") ?? "3.12";
string pythonVersionLinux = Environment.GetEnvironmentVariable("PYTHON_VERSION") ?? "3.12";
string venvPath = Path.Join(Environment.CurrentDirectory, "python", ".venv");
Expand Down
2 changes: 1 addition & 1 deletion src/Profile/BaseBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class BaseBenchmark

public BaseBenchmark()
{
string pythonVersionWindows = "3.12.4";
string pythonVersionWindows = Environment.GetEnvironmentVariable("PYTHON_VERSION") ?? "3.12.4";
string pythonVersionMacOS = Environment.GetEnvironmentVariable("PYTHON_VERSION") ?? "3.12";
string pythonVersionLinux = Environment.GetEnvironmentVariable("PYTHON_VERSION") ?? "3.12";

Expand Down

0 comments on commit b9a6b8d

Please sign in to comment.