mirror of
				https://github.com/clearml/clearml-agent
				synced 2025-06-26 18:16:15 +00:00 
			
		
		
		
	Fix installing venv from the agent's python binary when the selected python failed - this could be the cause of missing pip or venv in the selected python
This commit is contained in:
		
							parent
							
								
									afe69c822f
								
							
						
					
					
						commit
						3585786348
					
				| @ -1,3 +1,4 @@ | |||||||
|  | import sys | ||||||
| from typing import Any | from typing import Any | ||||||
| 
 | 
 | ||||||
| from ...._vendor.pathlib2 import Path | from ...._vendor.pathlib2 import Path | ||||||
| @ -72,11 +73,21 @@ class VirtualenvPip(SystemPip, PackageManager): | |||||||
|                 self.python, "-m", "virtualenv", self.path, *self.create_flags() |                 self.python, "-m", "virtualenv", self.path, *self.create_flags() | ||||||
|             ).check_call() |             ).check_call() | ||||||
|         except Exception as ex: |         except Exception as ex: | ||||||
|             # let's try with std library instead |             try: | ||||||
|             print("WARNING: virtualenv call failed: {}\n INFO: Creating virtual environment with venv".format(ex)) |                 # let's try with std library instead | ||||||
|             self.session.command( |                 print("WARNING: virtualenv call failed: {}\n INFO: Creating virtual environment with venv".format(ex)) | ||||||
|                 self.python, "-m", "venv", self.path, *self.create_flags() |                 self.session.command( | ||||||
|             ).check_call() |                     self.python, "-m", "venv", self.path, *self.create_flags() | ||||||
|  |                 ).check_call() | ||||||
|  |             except Exception as ex: | ||||||
|  |                 # let's try with std library instead | ||||||
|  |                 print("WARNING: virtualenv and venv failed with [{}] trying virtualenv with python [{}]".format( | ||||||
|  |                     self.python, sys.executable)) | ||||||
|  |                 self.python = str(sys.executable) | ||||||
|  |                 self._bin = Path(self.python) | ||||||
|  |                 self.session.command( | ||||||
|  |                     self.python, "-m", "virtualenv", self.path, *self.create_flags() | ||||||
|  |                 ).check_call() | ||||||
| 
 | 
 | ||||||
|         return self |         return self | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 clearml
						clearml