@@ -30,6 +30,7 @@ class VirtualPythonEnvironment(BaseEnvironment[Path]):
3030 BACKEND_NAME : ClassVar [str ] = "virtualenv"
3131
3232 requirements : list [str ] = field (default_factory = list )
33+ install_requirements : list [str ] = field (default_factory = list )
3334 constraints_file : os .PathLike | None = None
3435 python_version : str | None = None
3536 extra_index_urls : list [str ] = field (default_factory = list )
@@ -65,6 +66,7 @@ def key(self) -> str:
6566 active_python_version = self .python_version or active_python ()
6667 return sha256_digest_of (
6768 active_python_version ,
69+ * self .install_requirements ,
6870 * self .requirements ,
6971 * constraints ,
7072 * self .extra_index_urls ,
@@ -74,17 +76,17 @@ def key(self) -> str:
7476 * extras ,
7577 )
7678
77- def install_requirements (self , path : Path ) -> None :
79+ def _install_packages (self , path : Path , requirements : list [ str ] ) -> None :
7880 """Install the requirements of this environment using 'pip' to the
7981 given virtualenv path.
8082
8183 If there are any constraint files specified, they will be also passed to
8284 the package resolver.
8385 """
84- if not self . requirements :
86+ if not requirements :
8587 return None
8688
87- self .log (f"Installing requirements: { ', ' .join (self . requirements )} " )
89+ self .log (f"Installing requirements: { ', ' .join (requirements )} " )
8890 environ = os .environ .copy ()
8991
9092 if self .resolver == "uv" :
@@ -102,7 +104,7 @@ def install_requirements(self, path: Path) -> None:
102104 pip_cmd : list [str | os .PathLike ] = [
103105 * base_pip_cmd , # type: ignore
104106 "install" ,
105- * self . requirements ,
107+ * requirements ,
106108 ]
107109 if self .constraints_file :
108110 pip_cmd .extend (["-c" , self .constraints_file ])
@@ -125,8 +127,8 @@ def _install_python_through_pyenv(self) -> str:
125127 from isolate .backends .pyenv import PyenvEnvironment
126128
127129 self .log (
128- f"Requested Python version of { self .python_version } is not available "
129- "in the system, attempting to install it through pyenv."
130+ f"Requested Python version of { self .python_version } is not available, "
131+ "attempting to install it through pyenv."
130132 )
131133
132134 pyenv = PyenvEnvironment .from_config (
@@ -147,8 +149,10 @@ def _decide_python(self) -> str:
147149 _get_pyenv_executable ()
148150 except Exception :
149151 raise EnvironmentCreationError (
150- f"Python { self .python_version } is not available in your "
151- "system. Please install it first."
152+ f"Your local Python version { self .python_version } is not "
153+ "available in the app environment. "
154+ "Please either downgrade your local version of Python or use a Docker "
155+ f"image with Python { self .python_version } ."
152156 ) from None
153157 else :
154158 return self ._install_python_through_pyenv ()
@@ -181,7 +185,8 @@ def create(self, *, force: bool = False) -> Path:
181185 f"Failed to create the environment at '{ venv_path } ': { exc } "
182186 )
183187
184- self .install_requirements (venv_path )
188+ self ._install_packages (venv_path , self .install_requirements )
189+ self ._install_packages (venv_path , self .requirements )
185190 completion_marker .touch ()
186191
187192 self .log (f"New environment cached at '{ venv_path } '" )
0 commit comments