Skip to content

Commit

Permalink
Onedir virtualenvs break with --copies. Fix it and still allow relo…
Browse files Browse the repository at this point in the history
…cation.

Signed-off-by: Pedro Algarvio <[email protected]>
  • Loading branch information
s0undt3ch authored and Thomas Phipps committed Mar 29, 2023
1 parent 61f785f commit 3296c01
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
import pathlib
import shutil
import sqlite3
import stat
import subprocess
import sys
import tarfile
import tempfile
import textwrap

import nox.command

Expand Down Expand Up @@ -1151,7 +1153,7 @@ def ci_test_tcp(session):
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="ci-test-onedir",
venv_params=["--system-site-packages", "--copies"],
venv_params=["--system-site-packages"],
)
def ci_test_onedir(session):
if not ONEDIR_ARTIFACT_PATH.exists():
Expand All @@ -1167,7 +1169,7 @@ def ci_test_onedir(session):
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="ci-test-onedir-tcp",
venv_params=["--system-site-packages", "--copies"],
venv_params=["--system-site-packages"],
)
def ci_test_onedir_tcp(session):
if not ONEDIR_ARTIFACT_PATH.exists():
Expand Down Expand Up @@ -1227,6 +1229,26 @@ def compress_dependencies(session):
)
nox_dependencies_tarball_path.unlink()

if not IS_WINDOWS:
session.log(f"Finding 'python' symlinks under '{REPO_ROOT / '.nox'}' ...")
script = """\
#!/bin/sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PYTHON_EXECUTABLE=$(realpath $SCRIPT_DIR/../../../artifacts/salt/bin/python3)
exec "$PYTHON_EXECUTABLE" "$@"
"""
for path in REPO_ROOT.joinpath(".nox").rglob("**/bin/python"):
if not path.is_symlink():
continue
if path.resolve() != ONEDIR_PYTHON_PATH.resolve():
continue
session.log(
f"Replacing {path} with a script which allows the nox virualenv to be relocatable..."
)
path.unlink()
path.write_text(textwrap.dedent(script).strip() + "\n")
path.chmod(path.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)

session_run_always(
session,
"tar",
Expand Down Expand Up @@ -1695,7 +1717,7 @@ def build(session):
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="test-pkgs-onedir",
venv_params=["--system-site-packages", "--copies"],
venv_params=["--system-site-packages"],
)
def test_pkgs_onedir(session):
if not ONEDIR_ARTIFACT_PATH.exists():
Expand Down

0 comments on commit 3296c01

Please sign in to comment.