@@ -38,6 +38,8 @@ TPythonVersion = record
38
38
InstallPath: string;
39
39
PythonPath: string;
40
40
function Is_venv : Boolean;
41
+ function Is_virtualenv : Boolean;
42
+ function Is_conda : Boolean;
41
43
procedure AssignTo (PythonEngine: TPersistent);
42
44
property PythonExecutable: string read GetPythonExecutable;
43
45
property DLLName: string read GetDLLName;
@@ -132,10 +134,23 @@ function TPythonVersion.GetApiVersion: integer;
132
134
end ;
133
135
134
136
function TPythonVersion.GetDisplayName : string;
137
+ Var
138
+ FormatStr: string;
135
139
begin
140
+ if FDisplayName = ' ' then
141
+ begin
142
+ if Is_conda then
143
+ FormatStr := ' Conda %s (%s)'
144
+ else
145
+ FormatStr := ' Python %s (%s)' ;
146
+ if Is_venv then
147
+ FormatStr := FormatStr + ' -venv'
148
+ else if Is_virtualenv then
149
+ FormatStr := FormatStr + ' -virtualenv' ;
150
+
151
+ FDisplayName := Format(FormatStr, [SysVersion, SysArchitecture]);
152
+ end ;
136
153
Result := FDisplayName;
137
- if Result = ' ' then
138
- Result := Format(' Python %s (%s)' , [SysVersion, SysArchitecture]);
139
154
end ;
140
155
141
156
function TPythonVersion.GetHelpFile : string;
@@ -178,7 +193,12 @@ function TPythonVersion.GetSysArchitecture: string;
178
193
begin
179
194
Result := fSysArchitecture;
180
195
if Result = ' ' then
181
- Result := ' Unknown' ;
196
+ Result := ' Unknown platform' ;
197
+ end ;
198
+
199
+ function TPythonVersion.Is_conda : Boolean;
200
+ begin
201
+ Result := FileExists(IncludeTrailingPathDelimiter(InstallPath) + ' scripts\conda.exe' );
182
202
end ;
183
203
184
204
function TPythonVersion.Is_venv : Boolean;
@@ -191,6 +211,12 @@ function TPythonVersion.Is_venv: Boolean;
191
211
FileExists(IncludeTrailingPathDelimiter(InstallPath) + ' pyvenv.cfg' );
192
212
end ;
193
213
214
+ function TPythonVersion.Is_virtualenv : Boolean;
215
+ begin
216
+ Result := not IsRegistered and (InstallPath <> DLLPath) and
217
+ not FileExists(IncludeTrailingPathDelimiter(InstallPath) + ' pyvenv.cfg' );
218
+ end ;
219
+
194
220
function CompareVersions (A, B : String) : Integer;
195
221
196
222
function GetNextNumber (var Version: string): Integer;
0 commit comments