Another approach to the uv installation question

Don't get clever about it at all, instead make uv on PATH a hard
requirement.
This commit is contained in:
Joe Rickerby
2025-12-19 17:20:39 +00:00
parent 90422f1824
commit bc79c16a71
8 changed files with 59 additions and 67 deletions
+7 -20
View File
@@ -47,8 +47,6 @@ runs:
from subprocess import run
EXTRAS = set(e.strip() for e in "${{ inputs.extras }}".split(",") if e.strip())
if sys.platform == "linux":
EXTRAS.discard("uv")
class EnvBuilder(venv.EnvBuilder):
@@ -73,47 +71,36 @@ runs:
shutil.rmtree(venv_path)
builder = EnvBuilder()
builder.create(venv_path)
exposed_binaries = {"cibuildwheel"}
if "uv" in EXTRAS:
exposed_binaries.add("uv")
clean_bin_path = builder.bin_path.parent / f"{builder.bin_path.name}.clean"
clean_bin_path.mkdir()
for path in list(builder.bin_path.iterdir()):
if path.stem in exposed_binaries:
try:
os.symlink(path, clean_bin_path / path.name)
except OSError:
import shutil
cibw_bin = [p for p in builder.bin_path.glob("cibuildwheel*") if p.stem == "cibuildwheel"][0]
shutil.copy2(path, clean_bin_path / path.name)
full_path = f"{clean_bin_path}{os.pathsep}{os.environ['PATH']}"
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
f.write(f"updated-path={full_path}\n")
f.write(f"cibw-bin={cibw_bin}\n")
f.write(f"bin-path={builder.bin_path}\n")
print("::endgroup::")
EOF
shell: bash
# Redirecting stderr to stdout to fix interleaving issue in Actions.
- run: >
cibuildwheel
"${{ steps.cibw.outputs.cibw-bin }}"
"${{ inputs.package-dir }}"
${{ inputs.output-dir != '' && format('--output-dir "{0}"', inputs.output-dir) || ''}}
${{ inputs.config-file != '' && format('--config-file "{0}"', inputs.config-file) || ''}}
${{ inputs.only != '' && format('--only "{0}"', inputs.only) || ''}}
2>&1
env:
PATH: "${{ steps.cibw.outputs.updated-path }}"
PATH: ${{ contains(inputs.extras, 'uv') && format('{0}:{1}', steps.cibw.outputs.bin-path, env.PATH) || env.PATH }}
shell: bash
if: runner.os != 'Windows'
# Windows needs powershell to interact nicely with Meson
- run: >
cibuildwheel
& "${{ steps.cibw.outputs.cibw-bin }}"
"${{ inputs.package-dir }}"
${{ inputs.output-dir != '' && format('--output-dir "{0}"', inputs.output-dir) || ''}}
${{ inputs.config-file != '' && format('--config-file "{0}"', inputs.config-file) || ''}}
${{ inputs.only != '' && format('--only "{0}"', inputs.only) || ''}}
env:
PATH: "${{ steps.cibw.outputs.updated-path }}"
PATH: ${{ contains(inputs.extras, 'uv') && format('{0};{1}', steps.cibw.outputs.bin-path, env.PATH) || env.PATH }}
shell: pwsh
if: runner.os == 'Windows'