Skip to content

Commit 31ecb59

Browse files
author
Chris Maunder
committed
Corrected Python env location in Linux
1 parent b0aa174 commit 31ecb59

File tree

7 files changed

+117
-66
lines changed

7 files changed

+117
-66
lines changed

.vscode/settings.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
"colour",
2727
"colourised",
2828
"colours",
29+
"computecap",
2930
"Consolas",
3031
"consoleloggerparameters",
3132
"CPAI",
3233
"createallsubdirs",
3334
"Crockford",
3435
"Cuda",
36+
"cuDNN",
3537
"CUDNN",
3638
"Darkmode",
3739
"Denoising",
@@ -61,6 +63,9 @@
6163
"fouo",
6264
"generalise",
6365
"getframe",
66+
"giga",
67+
"gigaunit",
68+
"gpuname",
6469
"HKCU",
6570
"HKLM",
6671
"hostbuilder",
@@ -82,18 +87,28 @@
8287
"Jetson",
8388
"keypair",
8489
"keypoints",
90+
"kilounit",
8591
"labelledby",
8692
"Lanczos",
8793
"licence",
8894
"LOCALAPPDATA",
8995
"logicaldisk",
9096
"logvals",
97+
"lproj",
9198
"maxs",
99+
"megas",
100+
"megaunit",
92101
"membuffer",
102+
"memfree",
103+
"memsize",
104+
"memtotal",
93105
"memused",
94106
"millidegree",
107+
"moduleid",
95108
"modulesettings",
96109
"nbsp",
110+
"NETBIOS",
111+
"noheader",
97112
"norestart",
98113
"normalises",
99114
"noscroll",
@@ -109,8 +124,10 @@
109124
"paddleocr",
110125
"parsejson",
111126
"peasy",
127+
"physmem",
112128
"platenumber",
113129
"pluralise",
130+
"PMIC",
114131
"popd",
115132
"postinst",
116133
"postprocess",
@@ -139,6 +156,7 @@
139156
"reqtype",
140157
"reso",
141158
"RKNN",
159+
"Rockchip",
142160
"rocm",
143161
"rocminfo",
144162
"runhidden",
@@ -160,6 +178,9 @@
160178
"Tegra",
161179
"tegrastats",
162180
"tempstore",
181+
"tera",
182+
"teras",
183+
"teraunit",
163184
"textreader",
164185
"tflite",
165186
"topbanner",
@@ -172,7 +193,10 @@
172193
"upsampling",
173194
"usebackq",
174195
"userid",
196+
"usermem",
197+
"utilisation",
175198
"utilise",
199+
"vcgencmd",
176200
"venv",
177201
"vggish",
178202
"waitretry",

src/SDK/NET/Utils/SystemInfo.cs

Lines changed: 87 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ public class SystemInfo
251251
private static string? _dockerContainerId;
252252
private static string? _osVersion;
253253
private static string? _osName;
254+
private static string? _osFlavour;
255+
private static string? _osCodeName;
254256
private static bool _isSSH;
255257
private static Runtimes _runtimes = new Runtimes();
256258

@@ -616,7 +618,32 @@ public static string HardwareVendor
616618
}
617619

618620
/// <summary>
619-
/// Gets the current Operating System name.
621+
/// Gets a value indicating whether the current OS is Windows
622+
/// </summary>
623+
public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
624+
625+
/// <summary>
626+
/// Gets a value indicating whether the current OS is Linux
627+
/// </summary>
628+
public static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
629+
630+
/// <summary>
631+
/// Gets a value indicating whether the current OS is macOS
632+
/// </summary>
633+
public static bool IsMacOS => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
634+
635+
/// <summary>
636+
/// Gets a value indicating whether the current OS is FreeBSD
637+
/// </summary>
638+
public static bool IsFreeBSD => RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD);
639+
640+
/// <summary>
641+
/// Gets a value indicating whether we are currently running in Docker
642+
/// </summary>
643+
public static bool IsDocker => ExecutionEnvironment == ExecutionEnvironment.Docker;
644+
645+
/// <summary>
646+
/// Gets the Operating System type. Specifically: Windows, Linux, macOS or FreeBSD.
620647
/// </summary>
621648
public static string OperatingSystem
622649
{
@@ -641,29 +668,20 @@ public static string OperatingSystem
641668
}
642669

643670
/// <summary>
644-
/// Gets a value indicating whether the current OS is Windows
645-
/// </summary>
646-
public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
647-
648-
/// <summary>
649-
/// Gets a value indicating whether the current OS is Linux
650-
/// </summary>
651-
public static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
652-
653-
/// <summary>
654-
/// Gets a value indicating whether the current OS is macOS
655-
/// </summary>
656-
public static bool IsMacOS => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
657-
658-
/// <summary>
659-
/// Gets a value indicating whether the current OS is FreeBSD
671+
/// Gets the actual name of the current Operating System name. eg Windows, Ubuntu, Debian.
660672
/// </summary>
661-
public static bool IsFreeBSD => RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD);
673+
public static string OperatingSystemName
674+
{
675+
get { return _osFlavour ?? string.Empty; }
676+
}
662677

663678
/// <summary>
664-
/// Gets a value indicating whether we are currently running in Docker
679+
/// Gets the current Operating System code name. eg Redstone, Jammy, Big Sur
665680
/// </summary>
666-
public static bool IsDocker => ExecutionEnvironment == ExecutionEnvironment.Docker;
681+
public static string OperatingSystemCodeName
682+
{
683+
get { return _osCodeName ?? string.Empty; }
684+
}
667685

668686
/// <summary>
669687
/// Returns the Operating System description, with corrections for Windows 11
@@ -672,26 +690,18 @@ public static string OperatingSystemDescription
672690
{
673691
get
674692
{
675-
// WSL is Linux, so this isn't needed since the line below will handle it and do the
676-
// same thing. However, it's here because we may want to report this differently.
677-
if (IsWSL)
678-
return $"{_osName} {_osVersion}";
679-
680-
if (IsLinux)
681-
return $"{_osName} {_osVersion}";
693+
string description;
694+
if (OperatingSystemName.StartsWith(OperatingSystem))
695+
description = $"{OperatingSystem} ({OperatingSystem} {OperatingSystemVersion}";
696+
else
697+
description = $"{OperatingSystem} ({OperatingSystemName} {OperatingSystemVersion}";
682698

683-
if (IsMacOS)
684-
return $"{_osName} {_osVersion}";
699+
if (!OperatingSystemCodeName.StartsWith(OperatingSystem))
700+
description += $" \"{OperatingSystemCodeName}\"";
685701

686-
// See https://github.com/getsentry/sentry-dotnet/issues/1484.
687-
// C'mon guys: technically the version may be 10.x, but stick to the branding that
688-
// the rest of the world understands.
689-
if (IsWindows &&
690-
Environment.OSVersion.Version.Major >= 10 &&
691-
Environment.OSVersion.Version.Build >= 22000)
692-
return RuntimeInformation.OSDescription.Replace("Windows 10.", "Windows 11 version 10.");
702+
description += ")";
693703

694-
return RuntimeInformation.OSDescription;
704+
return description;
695705
}
696706
}
697707

@@ -736,7 +746,7 @@ public static async Task InitializeAsync()
736746

737747
await CheckForWslAsync().ConfigureAwait(false);
738748
await GetDockerContainerIdAsync().ConfigureAwait(false);
739-
await CheckOSVersionNameAsync().ConfigureAwait(false);
749+
await GetOsDetailsAsync().ConfigureAwait(false);
740750
await CheckForSshAsync().ConfigureAwait(false);
741751
await GetcuDNNVersionAsync().ConfigureAwait(false);
742752

@@ -765,34 +775,34 @@ public static string GetSystemInfo()
765775
else
766776
info.AppendLine($"System: {SystemName}");
767777

768-
info.AppendLine($"Operating System: {OperatingSystem} ({OperatingSystemDescription})");
778+
info.AppendLine($"Operating System: {OperatingSystemDescription}");
769779

770780
if (CPU is not null)
771781
{
772-
var cpus = new StringBuilder();
782+
var cpuList = new StringBuilder();
773783
if (!string.IsNullOrEmpty(CPU[0].Name))
774784
{
775-
cpus.Append(CPU[0].Name);
785+
cpuList.Append(CPU[0].Name);
776786
if (!string.IsNullOrWhiteSpace(CPU[0].HardwareVendor))
777-
cpus.Append($" ({CPU[0].HardwareVendor})");
778-
cpus.Append("\n ");
787+
cpuList.Append($" ({CPU[0].HardwareVendor})");
788+
cpuList.Append("\n ");
779789
}
780790

781-
cpus.Append(CPU.Count + " CPU");
791+
cpuList.Append(CPU.Count + " CPU");
782792
if (CPU.Count != 1)
783-
cpus.Append("s");
793+
cpuList.Append("s");
784794

785795
if (CPU[0].NumberOfCores > 0)
786796
{
787-
cpus.Append($" x {CPU[0].NumberOfCores} core");
797+
cpuList.Append($" x {CPU[0].NumberOfCores} core");
788798
if (CPU[0].NumberOfCores != 1)
789-
cpus.Append("s");
799+
cpuList.Append("s");
790800
}
791-
cpus.Append(".");
801+
cpuList.Append(".");
792802
if (CPU[0].LogicalProcessors > 0)
793-
cpus.Append($" {CPU[0].LogicalProcessors} logical processors");
803+
cpuList.Append($" {CPU[0].LogicalProcessors} logical processors");
794804

795-
info.AppendLine($"CPUs: {cpus} ({Architecture})");
805+
info.AppendLine($"CPUs: {cpuList} ({Architecture})");
796806
}
797807

798808
if (!string.IsNullOrWhiteSpace(gpuDesc))
@@ -1602,7 +1612,7 @@ private static async Task GetMemoryInfoAsync()
16021612

16031613
private static CpuCollection GetCpuInfo()
16041614
{
1605-
var cpus = new CpuCollection();
1615+
var cpuList = new CpuCollection();
16061616
if (_hardwareInfo != null)
16071617
{
16081618
foreach (var cpu in _hardwareInfo.CpuList)
@@ -1632,15 +1642,15 @@ private static CpuCollection GetCpuInfo()
16321642
else if (EdgeDevice == "Radxa ROCK")
16331643
cpuInfo.HardwareVendor = "Rockchip";
16341644

1635-
cpus.Add(cpuInfo);
1645+
cpuList.Add(cpuInfo);
16361646
}
16371647
}
16381648

16391649
// There's obviously at least 1.
1640-
if (cpus.Count == 0)
1641-
cpus.Add(new CpuInfo() { NumberOfCores = 1, LogicalProcessors = 1 });
1650+
if (cpuList.Count == 0)
1651+
cpuList.Add(new CpuInfo() { NumberOfCores = 1, LogicalProcessors = 1 });
16421652

1643-
return cpus;
1653+
return cpuList;
16441654
}
16451655

16461656
private async static Task CheckForWslAsync()
@@ -1688,18 +1698,19 @@ private async static Task GetDockerContainerIdAsync()
16881698
}
16891699
}
16901700

1691-
private async static Task CheckOSVersionNameAsync()
1701+
private async static Task GetOsDetailsAsync()
16921702
{
16931703
// Default fallback
16941704
_osName = OperatingSystem;
1705+
_osFlavour = OperatingSystem;
16951706
_osVersion = Environment.OSVersion.Version.Major.ToString();
16961707

16971708
if (IsLinux)
16981709
{
16991710
var results = await GetProcessInfoAsync("/bin/bash", "-c \". /etc/os-release;echo $NAME\"", null)
17001711
.ConfigureAwait(false);
17011712
if (results is not null)
1702-
_osName = results["output"]?.Trim(); // eg "ubuntu", "debian"
1713+
_osFlavour = results["output"]?.Trim(); // eg "ubuntu", "debian"
17031714

17041715
// VERSION_ID is in form "24.10"
17051716
results = await GetProcessInfoAsync("/bin/bash", "-c \". /etc/os-release;echo $VERSION_ID\"", null)
@@ -1716,22 +1727,36 @@ private async static Task CheckOSVersionNameAsync()
17161727
{
17171728
string? name = results["name"]?.Trim(); // eg. "Oracular Oriole" for Ubuntu 24.10
17181729
if (!string.IsNullOrWhiteSpace(name))
1719-
_osName += " (" + name + ")";
1730+
_osCodeName = name;
17201731
}
1721-
17221732
}
17231733
else if (IsWindows)
17241734
{
1725-
if (Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= 22000)
1726-
_osVersion = "11";
1735+
_osCodeName = "Windows " + Environment.OSVersion.Version.Major;
1736+
1737+
if (Environment.OSVersion.Version.Major >= 10)
1738+
{
1739+
// See https://github.com/getsentry/sentry-dotnet/issues/1484.
1740+
// C'mon guys: technically the version may be 10.x, but stick to the branding
1741+
// that the rest of the world understands.
1742+
if (Environment.OSVersion.Version.Build >= 22000)
1743+
{
1744+
_osVersion = "11";
1745+
_osCodeName = "Sun Valley";
1746+
}
1747+
else
1748+
{
1749+
_osCodeName = "Redstone";
1750+
}
1751+
}
17271752
}
17281753
else if (IsMacOS)
17291754
{
17301755
string command = "awk '/SOFTWARE LICENSE AGREEMENT FOR macOS/' '/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf' | awk -F 'macOS ' '{print $NF}' | awk '{print substr($0, 0, length($0)-1)}'";
17311756
var results = await GetProcessInfoAsync("/bin/bash", $"-c \"{command}\"", null)
17321757
.ConfigureAwait(false);
17331758
if (results is not null)
1734-
_osName = results["output"]?.Trim(); // eg. "Big Sur"
1759+
_osCodeName = results["output"]?.Trim(); // eg. "Big Sur"
17351760

17361761
results = await GetProcessInfoAsync("/bin/bash", "-c \"sw_vers -productVersion\"", null)
17371762
.ConfigureAwait(false);

src/server/Modules/ModuleSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class ModuleSettings
2525
const string CurrentModuleDirPathMarker = "%CURRENT_MODULE_PATH%";
2626
const string PlatformMarker = "%PLATFORM%";
2727
const string OSMarker = "%OS%";
28+
const string OSNameMarker = "%OS_NAME%";
2829
const string DataDirMarker = "%DATA_DIR%";
2930
const string PythonPathMarker = "%PYTHON_PATH%";
3031
const string PythonNameMarker = "%PYTHON_NAME%";
@@ -340,6 +341,7 @@ private void ExpandMacros()
340341
value = value.Replace(ExternalModulesDirPath, _moduleOptions.ExternalModulesDirPath);
341342
value = value.Replace(PlatformMarker, SystemInfo.Platform.ToLower());
342343
value = value.Replace(OSMarker, SystemInfo.OperatingSystem.ToLower());
344+
value = value.Replace(OSNameMarker, SystemInfo.OperatingSystemName.ToLower());
343345
value = value.Replace(PythonPathMarker, _moduleOptions.PythonRelativeInterpreterPath);
344346
value = value.Replace(DataDirMarker, _appDataDirectory);
345347
// Do this last in case other markers contains this marker

src/server/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
// TODO: Have 'runtime' plugins register runtimes and their launcher's paths to remove the need
139139
// for this hardcoding.
140140

141-
"PythonRelativeInterpreterPath": "/bin/%OS%/%PYTHON_NAME%/venv/Scripts/python", // ** %PYTHON_PATH% will expand to this value
141+
"PythonRelativeInterpreterPath": "/bin/%OS_NAME%/%PYTHON_NAME%/venv/Scripts/python", // ** %PYTHON_PATH% will expand to this value
142142

143143
// Whether or not to install the initial set of modules concurrently or one by one.
144144
"ConcurrentInitialInstalls": false,

src/server/appsettings.linux.arm64.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ModuleOptions": {
33

4-
"PythonRelativeInterpreterPath": "/bin/%OS%/%PYTHON_NAME%/venv/bin/python3", // ** %PYTHON_PATH% will expand to this value
4+
"PythonRelativeInterpreterPath": "/bin/%OS_NAME%/%PYTHON_NAME%/venv/bin/python3", // ** %PYTHON_PATH% will expand to this value
55

66
// The list of Modules to install on Initial run. The format for the list of initial modules is
77
// "moduleid:version; moduleid:version, ...", with the version being optional. If the version is

0 commit comments

Comments
 (0)