Files
cibuildwheel/action.yml
T

93 lines
3.1 KiB
YAML
Raw Normal View History

2020-12-21 11:49:31 -05:00
name: cibuildwheel
description: 'Installs and runs cibuildwheel on the current runner'
inputs:
package-dir:
description: 'Input directory, defaults to "."'
required: false
default: .
output-dir:
description: 'Folder to place the outputs in, defaults to "wheelhouse"'
required: false
default: wheelhouse
config-file:
description: 'File containing the config, defaults to {package}/pyproject.toml'
required: false
default: ''
2022-09-09 08:34:47 -04:00
only:
description: 'Build a specific wheel only. No need for arch/platform if this is set'
required: false
default: ''
2020-12-21 11:49:31 -05:00
branding:
icon: package
color: yellow
runs:
using: composite
steps:
# Set up a non-EOL, cibuildwheel & pipx supported Python version
- uses: actions/setup-python@v5
id: python
with:
2023-10-27 01:21:59 -04:00
python-version: "3.8 - 3.12"
update-environment: false
2020-12-21 11:49:31 -05:00
2024-01-31 01:23:39 +01:00
- id: cibw
run: |
# Install cibuildwheel
"${{ steps.python.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 cibuildwheel")
venv_path = Path(r"${{ runner.temp }}") / "cibw"
if venv_path.exists():
shutil.rmtree(venv_path)
builder = EnvBuilder()
builder.create(venv_path)
cibw_path = [path for path in builder.bin_path.glob("cibuildwheel*") if path.stem == "cibuildwheel"][0]
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
f.write(f"cibw-path={cibw_path}\n")
print("::endgroup::")
EOF
shell: bash
2021-06-30 18:10:01 -04:00
# Redirecting stderr to stdout to fix interleaving issue in Actions.
- run: >
2024-01-31 01:23:39 +01:00
"${{ steps.cibw.outputs.cibw-path }}"
"${{ 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) || ''}}
2021-06-30 18:10:01 -04:00
2>&1
2021-07-09 16:06:16 -04:00
shell: bash
if: runner.os != 'Windows'
# Windows needs powershell to interact nicely with Meson
- run: >
2024-01-31 01:23:39 +01:00
& "${{ steps.cibw.outputs.cibw-path }}"
"${{ 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) || ''}}
shell: pwsh
if: runner.os == 'Windows'