mirror of
https://github.com/chatmail/relay.git
synced 2026-06-11 14:11:08 +00:00
fix(cmdeploy): check venv python versions and purge if mismatched
`cmdeploy run` failed after upgrade system upgrade to Debian 13 with "Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding" indicating a Python version missmatch. Check for both versions and remove old `remote_venv_dir` on mismatch to allow clean reinitialization by subsequent pip.virtualenv().
This commit is contained in:
@@ -98,6 +98,19 @@ def _install_remote_venv_with_chatmaild(deployer) -> None:
|
|||||||
dest=remote_dist_file,
|
dest=remote_dist_file,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Remove venv if its Python major.minor doesn't match the system Python
|
||||||
|
server.shell(
|
||||||
|
name="remove stale chatmaild venv if python version changed",
|
||||||
|
commands=["\n".join([
|
||||||
|
f"if [ -d {remote_venv_dir} ]; then",
|
||||||
|
r" re='[0-9]+\.[0-9]+'", # match major.minor from 'Python X.Y.Z'"
|
||||||
|
' SYS_VERSION=$(python3 --version | grep -oE "$re")',
|
||||||
|
f' VENV_VERSION=$({remote_venv_dir}/bin/python --version 2>/dev/null | grep -oE "$re")',
|
||||||
|
f' [ "$SYS_VERSION" = "$VENV_VERSION" ] || rm -rf {remote_venv_dir}',
|
||||||
|
"fi",
|
||||||
|
])],
|
||||||
|
)
|
||||||
|
|
||||||
pip.virtualenv(
|
pip.virtualenv(
|
||||||
name=f"chatmaild virtualenv {remote_venv_dir}",
|
name=f"chatmaild virtualenv {remote_venv_dir}",
|
||||||
path=remote_venv_dir,
|
path=remote_venv_dir,
|
||||||
|
|||||||
Reference in New Issue
Block a user