1
+ import platform
1
2
import sys
2
3
from pathlib import Path
3
4
@@ -20,21 +21,21 @@ def install_file(
20
21
Path (destination , "bin" , "python3" ).touch ()
21
22
22
23
def get_version (self ):
23
- if sys .platform == "win32" :
24
- return Version ( self . executable . parent . name . split ( "@" , 1 )[ 1 ])
25
- else :
26
- return Version (self . executable . parent . parent . name .split ("@" , 1 )[1 ])
24
+ name = self . executable . parent . name if sys .platform == "win32" else self . executable . parent . parent . name
25
+ if "@" not in name :
26
+ return Version ( platform . python_version ())
27
+ return Version (name .split ("@" , 1 )[1 ])
27
28
28
29
@property
29
30
def interpreter (self ):
30
31
return self .executable
31
32
32
33
@property
33
34
def implementation (self ):
34
- if sys .platform == "win32" :
35
- return self . executable . parent . name . split ( "@" , 1 )[ 0 ]
36
- else :
37
- return self . executable . parent . parent . name .split ("@" , 1 )[0 ]
35
+ name = self . executable . parent . name if sys .platform == "win32" else self . executable . parent . parent . name
36
+ if "@" not in name :
37
+ return "cpython"
38
+ return name .split ("@" , 1 )[0 ]
38
39
39
40
mocker .patch ("pbs_installer.download" , return_value = "python-3.10.8.tar.gz" )
40
41
installer = mocker .patch ("pbs_installer.install_file" , side_effect = install_file )
@@ -48,7 +49,7 @@ def implementation(self):
48
49
def test_install_python (project , pdm , mock_install ):
49
50
root = Path (project .config ["python.install_root" ])
50
51
51
- pdm ([
"py" ,
"install" ,
"[email protected] " ],
obj = project ,
strict = True )
52
+ pdm ([
"py" ,
"install" ,
"[email protected] " , "-v" ],
obj = project ,
strict = True )
52
53
mock_install .assert_called_once ()
53
54
assert (
root / "[email protected] " ).
exists ()
54
55
0 commit comments