Skip to content

Commit 586684b

Browse files
authored
ci: Use cibuildwheel to build wheels (#309)
* pandoc_download: Improve error for unsupported architecture Show which arch was detected in the error message * ci: Use cibuildwheel to build binary wheels - pypandoc-1.9.tar.gz Same as earlier, uses setup.py command to create file - pypandoc-1.9-py3-none-any.whl Same as earlier, uses setup.py command to create file - pypandoc_binary-1.9-py3-none-win32.whl Identical to earlier file - generated using cibuildwheel now. I don't have a win32 machine and so unable to test it. But it is identical to the older wheel for win32 - pypandoc_binary-1.9-py3-none-win_amd64.whl New file - similar to win32. Tetsted with my local windows - works fine. - pypandoc_binary-1.9-py3-none-macosx_10_15_x86_64.whl Not generated anymore (see next line) - pypandoc_binary-1.9-py3-none-macosx_10_9_x86_64.whl New file - similar to 10_15 but now supports older MacOS versions ^_^/ I don't have a max and so unable to test it. But identical to the older wheel for macos - pypandoc_binary-1.9-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl New file. Tested with my local ubuntu 18.04 works fine and can support older linux versions also - pypandoc_binary-1.9-py3-none-musllinux_1_1_x86_64.whl New file - I haven't been able to test this yet
1 parent e970b5f commit 586684b

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

.github/workflows/ci.yaml

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,44 +48,61 @@ jobs:
4848
- name: run tests
4949
run: poetry run python tests.py
5050

51-
builder:
51+
builder_pypandoc:
5252
needs: [test]
5353
if: github.ref == 'refs/heads/master'
54-
strategy:
55-
matrix:
56-
os: [macos-11, windows-2019]
57-
runs-on: ${{ matrix.os }}
54+
runs-on: ubuntu-20.04 # Any OS is fine as this wheel is not OS dependent
5855
steps:
5956
- name: Check out repository
60-
uses: actions/checkout@v2
61-
- name: Discover python architecture
62-
run: |
63-
if [ "$RUNNER_OS" == "Windows" ]; then
64-
echo "PYTHON_ARCHITECTURE=x86" >> $GITHUB_ENV
65-
else
66-
echo "PYTHON_ARCHITECTURE=x64" >> $GITHUB_ENV
67-
fi
57+
uses: actions/checkout@v3
6858
- name: Set up python
59+
id: setup-python
6960
uses: actions/setup-python@v4
7061
with:
71-
python-version: "3.9.x"
72-
architecture: "${{ env.PYTHON_ARCHITECTURE }}"
73-
- name: Print Python Information
74-
run: python -VV
62+
python-version: 3.9 # Build any 1 python version as this wheel is not version dependent
7563
- name: Update dependencies
76-
run: python -m pip install -U pip wheel setuptools twine
77-
- name: Build universal source Archive and wheel
64+
run: python -m pip install -U pip wheel setuptools
65+
- name: Build wheel
7866
run: python setup.py sdist bdist_wheel
79-
- name: Build binary Archive
80-
run: python setup_binary.py download_pandoc bdist_wheel
8167
- name: Upload artifacts
8268
uses: actions/upload-artifact@v3
8369
with:
8470
name: python-package-distributions
8571
path: dist/
8672

73+
builder_pypandoc_binary:
74+
needs: [test]
75+
if: github.ref == 'refs/heads/master'
76+
strategy:
77+
matrix:
78+
# Ref: https://cibuildwheel.readthedocs.io/en/stable/options/#archs
79+
# macos-11 - Creates macosx_x86_64
80+
# windows-2019 - Creates {win_amd64,win32}
81+
# ubuntu-20.04 - Creates {manylinux,musllinux}_{x86_64,i686}
82+
# In CIBW_SKIP we skip 32bit linux
83+
os: [macos-11, windows-2019, ubuntu-20.04]
84+
runs-on: ${{ matrix.os }}
85+
steps:
86+
- name: Check out repository
87+
uses: actions/checkout@v3
88+
- name: Remove pyproject and use setuptools
89+
run: rm pyproject.toml
90+
- name: Build binary Archive
91+
uses: pypa/cibuildwheel@v2.9.0
92+
env:
93+
CIBW_BEFORE_ALL: "mv setup_binary.py setup.py && python3 setup.py download_pandoc"
94+
CIBW_BUILD: cp39-* # Build any 1 python version as this wheel is not version dependent
95+
# We skip some variants because:
96+
# - pandoc does not publish binaries for Linux 32bit
97+
CIBW_SKIP: "*-{manylinux_i686,musllinux_i686}"
98+
- name: Upload artifacts
99+
uses: actions/upload-artifact@v3
100+
with:
101+
name: python-package-distributions
102+
path: wheelhouse/
103+
87104
publisher_release:
88-
needs: [builder]
105+
needs: [builder_pypandoc, builder_pypandoc_binary]
89106
if: startsWith(github.event.ref, 'refs/tags/v') && github.ref == 'refs/heads/master'
90107
runs-on: ubuntu-latest
91108
steps:
@@ -104,7 +121,7 @@ jobs:
104121
password: ${{ secrets.PYPI_API_TOKEN }}
105122

106123
publisher_latest:
107-
needs: [builder]
124+
needs: [builder_pypandoc, builder_pypandoc_binary]
108125
if: github.ref == 'refs/heads/master'
109126
runs-on: ubuntu-latest
110127
steps:

pypandoc/pandoc_download.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ def download_pandoc(url:Union[str, None]=None,
231231
# compatibility with py3
232232
if pf.startswith("linux"):
233233
pf = "linux"
234-
if platform.architecture()[0] != "64bit":
235-
raise RuntimeError("Linux pandoc is only compiled for 64bit.")
234+
arch = platform.architecture()[0]
235+
if arch != "64bit":
236+
raise RuntimeError(f"Linux pandoc is only compiled for 64bit. Got arch={arch}.")
236237

237238
# get pandoc_urls
238239
pandoc_urls, _ = _get_pandoc_urls(version)

0 commit comments

Comments
 (0)