From b38bbcea47df7fe1e184ea2558000202e6bea7c4 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 17 Feb 2024 12:39:55 +0100 Subject: [PATCH] temp: don't use pipx --- action.yml | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index f0392ba0..f0837713 100644 --- a/action.yml +++ b/action.yml @@ -31,5 +31,48 @@ runs: allow-prereleases: true - name: "Install nox" - run: pipx install --python "${{ steps.allpython.outputs.python-path }}" '${{ github.action_path }}' + run: | + # Install nox + "${{ steps.allpython.outputs.python-path }}" -u << "EOF" + import os + import shutil + import sys + import venv + + from pathlib import Path + from subprocess import run + + + class EnvBuilder(venv.EnvBuilder): + def __init__(self): + super().__init__() + + def setup_scripts(self, context): + pass + + def post_setup(self, context): + super().post_setup(context) + self.bin_path = Path(context.env_exe).parent + run([sys.executable, "-m", "pip", "--python", context.env_exe, "install", r"${{ github.action_path }}"], check=True) + + + print("::group::Install nox") + nox_bin_path = Path(r"${{ runner.temp }}") / "nox" + if nox_bin_path.exists(): + shutil.rmtree(nox_bin_path) + venv_path = Path(r"${{ runner.temp }}") / "nox-venv" + if venv_path.exists(): + shutil.rmtree(venv_path) + builder = EnvBuilder() + builder.create(venv_path) + nox_path = [path for path in builder.bin_path.glob("nox*") if path.stem == "nox"][0] + nox_bin_path.mkdir() + try: + os.symlink(nox_path, nox_bin_path / nox_path.name) + except OSError: + shutil.copyfile(nox_path, nox_bin_path / nox_path.name) + with open(os.environ["GITHUB_PATH"], "at") as f: + f.write(f"{nox_bin_path}\n") + print("::endgroup::") + EOF shell: bash