@@ -1147,6 +1147,9 @@ def run_pip(self, *args, **kwargs):
1147
1147
cmd = pip + list (args )
1148
1148
return self ._run (cmd , ** kwargs )
1149
1149
1150
+ def run_python_script (self , content , ** kwargs ): # type: (str, Any) -> str
1151
+ return self .run (self ._executable , "-W" , "ignore" , "-" , input_ = content , ** kwargs )
1152
+
1150
1153
def _run (self , cmd , ** kwargs ):
1151
1154
"""
1152
1155
Run a command inside the Python environment.
@@ -1357,18 +1360,16 @@ def __init__(self, path, base=None): # type: (Path, Optional[Path]) -> None
1357
1360
# In this case we need to get sys.base_prefix
1358
1361
# from inside the virtualenv.
1359
1362
if base is None :
1360
- self ._base = Path (
1361
- self .run (self ._executable , "-" , input_ = GET_BASE_PREFIX ).strip ()
1362
- )
1363
+ self ._base = Path (self .run_python_script (GET_BASE_PREFIX ).strip ())
1363
1364
1364
1365
@property
1365
1366
def sys_path (self ): # type: () -> List[str]
1366
- output = self .run ( self . _executable , "-" , input_ = GET_SYS_PATH )
1367
+ output = self .run_python_script ( GET_SYS_PATH )
1367
1368
1368
1369
return json .loads (output )
1369
1370
1370
1371
def get_version_info (self ): # type: () -> Tuple[int]
1371
- output = self .run ( self . _executable , "-" , input_ = GET_PYTHON_VERSION )
1372
+ output = self .run_python_script ( GET_PYTHON_VERSION )
1372
1373
1373
1374
return tuple ([int (s ) for s in output .strip ().split ("." )])
1374
1375
@@ -1406,7 +1407,7 @@ def get_supported_tags(self): # type: () -> List[Tag]
1406
1407
"""
1407
1408
)
1408
1409
1409
- output = self .run ( self . _executable , "-" , input_ = script )
1410
+ output = self .run_python_script ( script )
1410
1411
1411
1412
return [Tag (* t ) for t in json .loads (output )]
1412
1413
@@ -1424,7 +1425,7 @@ def get_pip_version(self): # type: () -> Version
1424
1425
return Version .parse (m .group (1 ))
1425
1426
1426
1427
def get_paths (self ): # type: () -> Dict[str, str]
1427
- output = self .run ( self . _executable , "-" , input_ = GET_PATHS )
1428
+ output = self .run_python_script ( GET_PATHS )
1428
1429
1429
1430
return json .loads (output )
1430
1431
@@ -1542,7 +1543,7 @@ def find_executables(self): # type: () -> None
1542
1543
self ._pip_executable = pip_executable
1543
1544
1544
1545
def get_paths (self ): # type: () -> Dict[str, str]
1545
- output = self .run ( self . _executable , "-" , input_ = GET_PATHS_FOR_GENERIC_ENVS )
1546
+ output = self .run_python_script ( GET_PATHS_FOR_GENERIC_ENVS )
1546
1547
1547
1548
return json .loads (output )
1548
1549
0 commit comments