Skip to content

Commit 80095ac

Browse files
authored
Merge pull request #1745 from mayeut/nopipx
chore(action): do not use pipx
2 parents df2e35a + a6ecded commit 80095ac

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

action.yml

+39-9
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,48 @@ runs:
3131
python-version: "3.8 - 3.12"
3232
update-environment: false
3333

34-
# macos-14 (M1) may be missing pipx (due to it not having CPython)
35-
- run: |
36-
"${{ steps.python.outputs.python-path }}" -m pip install pipx
34+
- id: cibw
35+
run: |
36+
# Install cibuildwheel
37+
"${{ steps.python.outputs.python-path }}" -u << "EOF"
38+
import os
39+
import shutil
40+
import sys
41+
import venv
42+
43+
from pathlib import Path
44+
from subprocess import run
45+
46+
47+
class EnvBuilder(venv.EnvBuilder):
48+
def __init__(self):
49+
super().__init__()
50+
51+
def setup_scripts(self, context):
52+
pass
53+
54+
def post_setup(self, context):
55+
super().post_setup(context)
56+
self.bin_path = Path(context.env_exe).parent
57+
run([sys.executable, "-m", "pip", "--python", context.env_exe, "install", r"${{ github.action_path }}"], check=True)
58+
59+
60+
print("::group::Install cibuildwheel")
61+
venv_path = Path(r"${{ runner.temp }}") / "cibw"
62+
if venv_path.exists():
63+
shutil.rmtree(venv_path)
64+
builder = EnvBuilder()
65+
builder.create(venv_path)
66+
cibw_path = [path for path in builder.bin_path.glob("cibuildwheel*") if path.stem == "cibuildwheel"][0]
67+
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
68+
f.write(f"cibw-path={cibw_path}\n")
69+
print("::endgroup::")
70+
EOF
3771
shell: bash
3872

3973
# Redirecting stderr to stdout to fix interleaving issue in Actions.
4074
- run: >
41-
"${{ steps.python.outputs.python-path }}" -m pipx run
42-
--spec '${{ github.action_path }}'
43-
cibuildwheel
75+
"${{ steps.cibw.outputs.cibw-path }}"
4476
"${{ inputs.package-dir }}"
4577
${{ inputs.output-dir != '' && format('--output-dir "{0}"', inputs.output-dir) || ''}}
4678
${{ inputs.config-file != '' && format('--config-file "{0}"', inputs.config-file) || ''}}
@@ -51,9 +83,7 @@ runs:
5183
5284
# Windows needs powershell to interact nicely with Meson
5385
- run: >
54-
& "${{ steps.python.outputs.python-path }}" -m pipx run
55-
--spec "${{ github.action_path }}"
56-
cibuildwheel
86+
& "${{ steps.cibw.outputs.cibw-path }}"
5787
"${{ inputs.package-dir }}"
5888
${{ inputs.output-dir != '' && format('--output-dir "{0}"', inputs.output-dir) || ''}}
5989
${{ inputs.config-file != '' && format('--config-file "{0}"', inputs.config-file) || ''}}

0 commit comments

Comments
 (0)