update_manager: handle app entry points

If the exectuable in the virtualenv is not "python" attempt to
detect the python executable.  Use the pip entry point for the
pip command.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-02-10 06:18:14 -05:00
parent 5d54a10177
commit b2d84bc733
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 14 additions and 4 deletions

View File

@ -78,6 +78,7 @@ class AppDeploy(BaseDeploy):
f"section [{config.get_name()}], type: {self.type}") f"section [{config.get_name()}], type: {self.type}")
self._verify_path(config, 'path', self.path, check_file=False) self._verify_path(config, 'path', self.path, check_file=False)
self.executable: Optional[pathlib.Path] = None self.executable: Optional[pathlib.Path] = None
self.py_exec: Optional[pathlib.Path] = None
self.pip_cmd: Optional[str] = None self.pip_cmd: Optional[str] = None
self.pip_version: Tuple[int, ...] = tuple() self.pip_version: Tuple[int, ...] = tuple()
self.venv_args: Optional[str] = None self.venv_args: Optional[str] = None
@ -94,11 +95,20 @@ class AppDeploy(BaseDeploy):
else: else:
break break
if act_path.is_file(): if act_path.is_file():
if self.executable.name != "python":
py_exec = self.executable.parent.joinpath("python")
if py_exec.is_file():
self.py_exec = py_exec
else:
self.py_exec = self.executable
venv_dir = self.executable.parent.parent venv_dir = self.executable.parent.parent
self.log_info(f"Detected virtualenv: {venv_dir}") self.log_info(f"Detected virtualenv: {venv_dir}")
pip_exe = self.executable.parent.joinpath("pip") pip_exe = self.executable.parent.joinpath("pip")
if pip_exe.is_file(): if pip_exe.is_file():
self.pip_cmd = f"{self.executable} -m pip" if self.py_exec is not None:
self.pip_cmd = f"{self.py_exec} -m pip"
else:
self.pip_cmd = str(pip_exe)
else: else:
self.log_info("Unable to locate pip executable") self.log_info("Unable to locate pip executable")
else: else:
@ -382,9 +392,9 @@ class AppDeploy(BaseDeploy):
return None return None
async def _build_virtualenv(self) -> None: async def _build_virtualenv(self) -> None:
if self.executable is None or self.venv_args is None: if self.py_exec is None or self.venv_args is None:
return return
bin_dir = self.executable.parent bin_dir = self.py_exec.parent
env_path = bin_dir.parent.resolve() env_path = bin_dir.parent.resolve()
self.notify_status(f"Creating virtualenv at: {env_path}...") self.notify_status(f"Creating virtualenv at: {env_path}...")
if env_path.exists(): if env_path.exists():
@ -395,5 +405,5 @@ class AppDeploy(BaseDeploy):
except Exception: except Exception:
self.log_exc(f"Error creating virtualenv") self.log_exc(f"Error creating virtualenv")
return return
if not self.executable.exists(): if not self.py_exec.exists():
raise self.log_exc("Failed to create new virtualenv", False) raise self.log_exc("Failed to create new virtualenv", False)