Skip to content

Commit

Permalink
Fix compilation issues in build_wheel workflow (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
tfuxu committed Aug 27, 2023
1 parent 6a9b782 commit 927cc22
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 18 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
run: ./tools/macos_build_wheels.sh
env:
CIBW_ARCHS: ${{ matrix.arch_cibw_go[0] }}
CIBW_BUILD_FRONTEND: "build"
PYTHON_BINARY_PATH: /usr/local/bin/python_for_build
CIBW_ENVIRONMENT: >
PATH=$PATH:/usr/local/go/bin
Expand Down Expand Up @@ -65,6 +66,7 @@ jobs:
package-dir: .
env:
CIBW_BUILD: "cp3*_x86_64"
CIBW_BUILD_FRONTEND: "build"
CIBW_SKIP: "cp36-* cp37-* *-musllinux_x86_64"
CIBW_ARCHS: "native"
CIBW_ENVIRONMENT: >
Expand All @@ -75,6 +77,7 @@ jobs:
tar -C /usr/local -xzf go.tar.gz
go install github.com/go-python/gopy@v0.4.7
go install golang.org/x/tools/cmd/goimports@latest
./tools/linux_compile_libwebp.sh
- name: Upload Artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -103,6 +106,7 @@ jobs:
package-dir: .
env:
CIBW_BUILD: "cp3${{ matrix.python3_version }}*_aarch64"
CIBW_BUILD_FRONTEND: "build"
CIBW_SKIP: "cp36-* cp37-* *-musllinux_aarch64"
CIBW_ARCHS: "aarch64"
CIBW_ENVIRONMENT: >
Expand All @@ -113,6 +117,7 @@ jobs:
tar -C /usr/local -xzf go.tar.gz
go install github.com/go-python/gopy@v0.4.7
go install golang.org/x/tools/cmd/goimports@latest
./tools/linux_compile_libwebp.sh
- name: Upload Artifacts
uses: actions/upload-artifact@v3
Expand All @@ -121,7 +126,7 @@ jobs:
path: ./wheelhouse/*.whl

build_linux_armv7l:
#if: false
if: false # Disable for now; It can't find source files for some reason
name: Linux armv7l
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -163,12 +168,13 @@ jobs:
path: /tmp/output/*.whl

build_windows:
if: false # Disable for now
if: false # TODO: Modify to use MinGW instead
name: Windows x86_64
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- uses: ilammy/msvc-dev-cmd@v1

- name: Set up Go
uses: actions/setup-go@v4
Expand All @@ -188,12 +194,20 @@ jobs:
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest

- name: Compile Libwebp
run: |
curl -o libwebp.tar.gz https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.3.1.tar.gz
tar -xzf libwebp.tar.gz
cd libwebp-1.3.1
nmake /f Makefile.vc CFG=release-dynamic RTLIBCFG=dynamic OBJDIR=output
- name: Build wheels
uses: pypa/cibuildwheel@v2.15.0
with:
package-dir: .
env:
CIBW_BUILD: "cp3*"
CIBW_BUILD_FRONTEND: "build"
CIBW_SKIP: "cp36-* cp37-*"
CIBW_ARCHS: "native"
CIBW_ENVIRONMENT: >
Expand All @@ -211,7 +225,7 @@ jobs:
- build_macos
- build_linux_x86_64
- build_linux_arm64
- build_linux_armv7l
#- build_linux_armv7l
#- build_windows
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,8 @@ pyrightconfig.json

# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,go

### Cibuildwheel ###
wheelhouse

### Dither Go! Specific ###
tests/dither_go.png
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
requires = ["setuptools>=61.0", "wheel", "pybindgen"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -18,3 +18,6 @@ classifiers = [
[project.urls]
"Homepage" = "https://github.com/tfuxu/dither-go"
"Bug Tracker" = "https://github.com/tfuxu/dither-go/issues"

[tool.setuptools]
packages = ["dither_go", "dither_go.bindings"]
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext


if sys.platform == 'darwin':
# PYTHON_BINARY_PATH is setting explicitly for 310 and 311, see build_wheel.yml
# on macos PYTHON_BINARY_PATH must be python bin installed from python.org
PYTHON_BINARY = os.getenv("PYTHON_BINARY_PATH", sys.executable)
if PYTHON_BINARY == sys.executable:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'pybindgen'])
else:
# linux & windows
# windown & linux
PYTHON_BINARY = sys.executable
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'pybindgen'])


def _generate_path_with_gopath() -> str:
Expand Down
1 change: 1 addition & 0 deletions tools/Dockerfile.armv7l
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN mkdir build
WORKDIR build
COPY . .

#RUN ./tools/linux_compile_libwebp.sh
RUN ./tools/armv7l_build_wheels.sh ${PYTHON3_VERSION}

RUN mkdir /export && \
Expand Down
9 changes: 4 additions & 5 deletions tools/armv7l_build_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@ set -e

build_wheel() (
PY_VER=$1
mkdir build$PY_VER
cd build$PY_VER
pip$PY_VER wheel ..
pip$PY_VER install build
python$PY_VER -m build
)

test_wheel() (
PY_VER=$1
cd build$PY_VER
cd dist
pip$PY_VER install *armv7l.whl
python$PY_VER -c "import dither_go; print(dither_go)"
)

repair_wheel() (
PY_VER=$1
cd build$PY_VER
cd dist
auditwheel repair *armv7l.whl
)

Expand Down
14 changes: 14 additions & 0 deletions tools/linux_compile_libwebp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

compile_libwebp() (
curl -o libwebp.tar.gz https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.3.1.tar.gz
tar -xzf libwebp.tar.gz
cd libwebp-1.3.1
./configure
make
make install
)

compile_libwebp
8 changes: 4 additions & 4 deletions tools/macos_build_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ test_wheel() (
_start_group "Python 3.8"
install_python 8
build_wheel 8
test_wheel 8
#test_wheel 8

_start_group "Python 3.9"
install_python 9
build_wheel 9
test_wheel 9
#test_wheel 9

_start_group "Python 3.10"
install_python 10
build_wheel 10
test_wheel 10
#test_wheel 10

_start_group "Python 3.11"
install_python 11
build_wheel 11
test_wheel 11
#test_wheel 11

0 comments on commit 927cc22

Please sign in to comment.