app_deploy: add support for pip environment vars
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
f7d5f11cf8
commit
19422819da
@ -169,6 +169,7 @@ class AppDeploy(BaseDeploy):
|
|||||||
else:
|
else:
|
||||||
self.log_info("Unable to locate pip executable")
|
self.log_info("Unable to locate pip executable")
|
||||||
self.venv_args = config.get('venv_args', None)
|
self.venv_args = config.get('venv_args', None)
|
||||||
|
self.pip_env_vars = config.getdict("pip_environment_variables", None)
|
||||||
|
|
||||||
def _configure_dependencies(
|
def _configure_dependencies(
|
||||||
self, config: ConfigHelper, node_only: bool = False
|
self, config: ConfigHelper, node_only: bool = False
|
||||||
@ -411,11 +412,18 @@ class AppDeploy(BaseDeploy):
|
|||||||
else:
|
else:
|
||||||
reqs = [req.replace("\"", "'") for req in requirements]
|
reqs = [req.replace("\"", "'") for req in requirements]
|
||||||
args = " ".join([f"\"{req}\"" for req in reqs])
|
args = " ".join([f"\"{req}\"" for req in reqs])
|
||||||
|
env: Optional[Dict[str, str]] = None
|
||||||
|
if self.pip_env_vars is not None:
|
||||||
|
self.log_info(
|
||||||
|
f"Running Pip with environment variables: {self.pip_env_vars}"
|
||||||
|
)
|
||||||
|
env = dict(os.environ)
|
||||||
|
env.update(self.pip_env_vars)
|
||||||
self.notify_status("Updating python packages...")
|
self.notify_status("Updating python packages...")
|
||||||
try:
|
try:
|
||||||
await self.cmd_helper.run_cmd(
|
await self.cmd_helper.run_cmd(
|
||||||
f"{self.pip_cmd} install {args}", timeout=1200., notify=True,
|
f"{self.pip_cmd} install {args}", timeout=1200., notify=True,
|
||||||
retries=3
|
retries=3, env=env, log_stderr=True
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log_exc("Error updating python requirements")
|
self.log_exc("Error updating python requirements")
|
||||||
|
@ -32,6 +32,7 @@ BASE_CONFIG: Dict[str, Dict[str, str]] = {
|
|||||||
"system_dependencies": "scripts/system-dependencies.json",
|
"system_dependencies": "scripts/system-dependencies.json",
|
||||||
"host_repo": "arksine/moonraker",
|
"host_repo": "arksine/moonraker",
|
||||||
"virtualenv": sys.exec_prefix,
|
"virtualenv": sys.exec_prefix,
|
||||||
|
"pip_environment_variables": "SKIP_CYTHON=Y",
|
||||||
"path": str(source_info.source_path()),
|
"path": str(source_info.source_path()),
|
||||||
"managed_services": "moonraker"
|
"managed_services": "moonraker"
|
||||||
},
|
},
|
||||||
|
@ -582,10 +582,14 @@ class CommandHelper:
|
|||||||
retries: int = 1,
|
retries: int = 1,
|
||||||
env: Optional[Dict[str, str]] = None,
|
env: Optional[Dict[str, str]] = None,
|
||||||
cwd: Optional[str] = None,
|
cwd: Optional[str] = None,
|
||||||
sig_idx: int = 1
|
sig_idx: int = 1,
|
||||||
|
log_stderr: bool = False
|
||||||
) -> None:
|
) -> None:
|
||||||
cb = self.notify_update_response if notify else None
|
cb = self.notify_update_response if notify else None
|
||||||
scmd = self.build_shell_command(cmd, callback=cb, env=env, cwd=cwd)
|
log_stderr |= self.server.is_verbose_enabled()
|
||||||
|
scmd = self.build_shell_command(
|
||||||
|
cmd, callback=cb, env=env, cwd=cwd, log_stderr=log_stderr
|
||||||
|
)
|
||||||
for _ in range(retries):
|
for _ in range(retries):
|
||||||
if await scmd.run(timeout=timeout, sig_idx=sig_idx):
|
if await scmd.run(timeout=timeout, sig_idx=sig_idx):
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user