@@ -24,6 +24,8 @@ def __init__(self, python_path, app_data_path):
2424 base_dir = Path (app_data_path )
2525 if sys .platform == "win32" :
2626 self .env_path = base_dir / "superset_env/Scripts/python.exe"
27+ elif sys .platform == "linux" :
28+ self .env_path = python_path .replace ("bin" , "bin/superset_env/bin" )
2729 else :
2830 self .env_path = base_dir / "superset_env/bin/python"
2931
@@ -45,11 +47,11 @@ def create_env(self):
4547 print (f"Creating virtual environment at: { env_name } " )
4648
4749 try :
48- # Create venv without pip first to avoid crash due to missing lib on macOS standalone builds
49- venv .create (env_name , with_pip = False , clear = True )
50-
5150 # Fix for macOS standalone python: symlink libpython
5251 if sys .platform == "darwin" :
52+ # Create venv without pip first to avoid crash due to missing lib on macOS standalone builds
53+ venv .create (env_name , with_pip = False , clear = True )
54+
5355 base_python_lib = Path (self .python_path ).parent .parent / "lib"
5456 venv_lib = Path (env_name ) / "lib"
5557
@@ -65,10 +67,20 @@ def create_env(self):
6567 except Exception as e :
6668 print (f"Failed to symlink libpython: { e } " )
6769
68- # Now install pip
69- print ("Installing pip..." )
70- subprocess .run ([str (self .env_path ), "-m" , "ensurepip" ], check = True )
70+ # Now install pip
71+ print ("Installing pip..." )
72+ subprocess .run ([str (self .env_path ), "-m" , "ensurepip" ], check = True )
7173
74+ else :
75+ # Create virtual environment
76+ process = subprocess .Popen ([
77+ self .python_path , "-m" , "venv" , env_name
78+ ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True )
79+ process .wait ()
80+ if process .returncode != 0 :
81+ print (f"Error creating environment: { process .stderr } " )
82+ raise Exception (f"Failed to create virtual environment. Error: { process .stderr } " )
83+
7284 print (f"Environment created at: { self .env_path } " )
7385 return True
7486 except Exception as e :
@@ -110,11 +122,11 @@ def get_installed_packages(self):
110122 str (self .python_path ), "-m" , "pip" , "freeze"
111123 ], capture_output = True , text = True , check = False )
112124
113- packages = {}
125+ packages = []
114126 for line in result .stdout .split ('\n ' ):
115127 if '==' in line :
116128 name , version = line .split ('==' , 1 )
117- packages [ name . lower ()] = version . strip ( )
129+ packages . append ({ 'name' : name , ' version' : version } )
118130 return packages
119131
120132 def is_package_installed (self , package_name , installed_packages = None ):
0 commit comments