From fdd88cdab112e0b0e9ee16527226cf537e32e111 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:11:11 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Build=20wheels=20for=20`linux/s3?= =?UTF-8?q?90x`=20target=20(#89)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🤖 Build for s390x * 🚧 Add `CIBW_SKIP` environment variable * 🖥️ Set up s390x wheels for publishing * ✅ Use `pipx` to run the linter * 🙏 Add notes about `s390x` support * 🚧 Run wheel builder on schedule --- .github/workflows/cd.yml | 80 +++++++++++++++++++++++----------------- .github/workflows/ci.yml | 5 ++- README.md | 3 +- hugo/cli.py | 1 + setup.py | 1 + 5 files changed, 54 insertions(+), 36 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f3c6ca4..846bd5c 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,6 +5,8 @@ on: release: types: - published + schedule: + - cron: '0 0 * * 1' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -25,8 +27,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - name: Set up Python 3.12 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: 3.12 @@ -46,12 +47,7 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: 3.12 - - - name: Set up Go toolchain - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: '1.22.2' cache: false @@ -77,14 +73,10 @@ jobs: if-no-files-found: error linux_amd64_wheels: - name: amd64-linux + name: amd64-manylinux runs-on: ubuntu-latest steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: 3.12 - - uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0 with: package-dir: . @@ -105,16 +97,11 @@ jobs: if-no-files-found: error linux_arm64_wheels: - name: arm64-linux + name: arm64-manylinux runs-on: ubuntu-latest steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: 3.12 - - - name: Set up QEMU for emulation - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 + - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 with: platforms: all @@ -137,17 +124,48 @@ jobs: path: ./wheelhouse/*.whl if-no-files-found: error + linux_s390x_wheels: + name: s390x-manylinux + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 + with: + platforms: all + + - name: Build binary distribution (wheel) on Linux (s390x) + uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0 + with: + package-dir: . + output-dir: wheelhouse + env: + CIBW_ARCHS_LINUX: s390x + CIBW_BEFORE_ALL_LINUX: | + tarball="go1.22.2.linux-s390x.tar.gz" + curl -LJO https://golang.org/dl/$tarball + mkdir $HOME/go_installed/ + tar -C $HOME/go_installed/ -xzf $tarball + export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bashrc + export PATH=$PATH:$HOME/go_installed/go/bin >> ~/.bash_profile + go version + CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/go_installed/go/bin + CIBW_TEST_COMMAND: > + hugo version + hugo env --logLevel debug + + - name: Upload wheels + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + with: + name: wheels_linux_s390x + path: ./wheelhouse/*.whl + if-no-files-found: error + macos_amd64_wheels: name: amd64-macos runs-on: macos-13 steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: 3.12 - - - name: Set up Go toolchain - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: '1.22.2' cache: false @@ -176,12 +194,7 @@ jobs: runs-on: macos-14 steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: 3.12 - - - name: Set up Go toolchain - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: '1.22.2' cache: false @@ -212,7 +225,8 @@ jobs: macos_amd64_wheels, macos_arm64_wheels, linux_amd64_wheels, - linux_arm64_wheels + linux_arm64_wheels, + linux_s390x_wheels ] name: Publish to PyPI or TestPyPI diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2aaef08..28bc9aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ concurrency: env: FORCE_COLOR: 3 CIBW_BUILD_VERBOSITY: 2 + CIBW_SKIP: "pp* *musllinux*" CIBW_BUILD_FRONTEND: "pip" # use pip for now, not build – missing buildDate otherwise jobs: @@ -27,7 +28,7 @@ jobs: python-version: 3.12 - name: Run style checks - run: pipx run nox -s lint + run: pipx run pre-commit run --all-files check_commit_message: needs: [style] @@ -117,7 +118,7 @@ jobs: experimental: needs: [style] - name: ${{ matrix.runs-on }}-${{ matrix.architecture }}-python-${{ matrix.python-version }} + name: zig-${{ matrix.runs-on }}-${{ matrix.architecture }}-python-${{ matrix.python-version }} env: CIBW_BUILD_VERBOSITY: 2 runs-on: ${{ matrix.runs-on }} diff --git a/README.md b/README.md index edb1e74..6d7e801 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ This project provides wheels for [Hugo](https://gohugo.io/) so that it can be us This project, `hugo` is versioned alongside the Hugo releases and is aligned with the versioning of Hugo itself, which uses `SemVer` – but is likely versioned according to [0ver](https://0ver.org/) software standards based on their [versioning history](https://github.com/gohugoio/hugo/releases). -Binaries for `hugo` through these wheels are available for Hugo versions **0.121.2** and above, through PyPI or through releases on GitHubr. If you need an older version of `hugo` that is not available through this package, please consider using the [official Hugo binaries](https://github.com/gohugoio/hugo/releases). +Binaries for `hugo` through these wheels are available for Hugo versions **0.121.2** and above, through PyPI or through releases on GitHub. If you need an older version of `hugo` that is not available through this package, please consider using the [official Hugo binaries](https://github.com/gohugoio/hugo/releases). Please refer to the section on [Supported platforms](#supported-platforms) for a list of wheels available for supported platforms and architectures. If it does, jump to the [Quickstart](#quickstart) section to get started. @@ -120,6 +120,7 @@ A subset of the platforms supported by Hugo itself are supported by these wheels | macOS | arm64 (Silicon) | ✅ | | Linux | amd64 | ✅ | | Linux | arm64 | ✅ | +| Linux | s390x | ✅ | | Windows | x86_64 | ✅ | | Windows | arm64 | 💡 Experimental support [^1] | | Windows | x86 | 💡 Experimental support [^1] | diff --git a/hugo/cli.py b/hugo/cli.py index cebd2a9..80c0ecd 100644 --- a/hugo/cli.py +++ b/hugo/cli.py @@ -31,6 +31,7 @@ "AMD64": "amd64", "aarch64": "arm64", "x86": "386", + "s390x": "s390x", }[machine()] # platform.machine returns AMD64 on Windows because the architecture is diff --git a/setup.py b/setup.py index 39ffb76..3983c12 100644 --- a/setup.py +++ b/setup.py @@ -37,6 +37,7 @@ "AMD64": "amd64", "aarch64": "arm64", "x86": "386", + "s390x": "s390x", }[platform.machine()] # Name of the Hugo binary that will be built