Skip to content

Commit

Permalink
ci: Use cibuildwheel to build wheels (#309)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AbdealiLoKo authored Oct 28, 2022
1 parent e970b5f commit 586684b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
63 changes: 40 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,44 +48,61 @@ jobs:
- name: run tests
run: poetry run python tests.py

builder:
builder_pypandoc:
needs: [test]
if: github.ref == 'refs/heads/master'
strategy:
matrix:
os: [macos-11, windows-2019]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04 # Any OS is fine as this wheel is not OS dependent
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Discover python architecture
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
echo "PYTHON_ARCHITECTURE=x86" >> $GITHUB_ENV
else
echo "PYTHON_ARCHITECTURE=x64" >> $GITHUB_ENV
fi
uses: actions/checkout@v3
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: "3.9.x"
architecture: "${{ env.PYTHON_ARCHITECTURE }}"
- name: Print Python Information
run: python -VV
python-version: 3.9 # Build any 1 python version as this wheel is not version dependent
- name: Update dependencies
run: python -m pip install -U pip wheel setuptools twine
- name: Build universal source Archive and wheel
run: python -m pip install -U pip wheel setuptools
- name: Build wheel
run: python setup.py sdist bdist_wheel
- name: Build binary Archive
run: python setup_binary.py download_pandoc bdist_wheel
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

builder_pypandoc_binary:
needs: [test]
if: github.ref == 'refs/heads/master'
strategy:
matrix:
# Ref: https://cibuildwheel.readthedocs.io/en/stable/options/#archs
# macos-11 - Creates macosx_x86_64
# windows-2019 - Creates {win_amd64,win32}
# ubuntu-20.04 - Creates {manylinux,musllinux}_{x86_64,i686}
# In CIBW_SKIP we skip 32bit linux
os: [macos-11, windows-2019, ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Remove pyproject and use setuptools
run: rm pyproject.toml
- name: Build binary Archive
uses: pypa/[email protected]
env:
CIBW_BEFORE_ALL: "mv setup_binary.py setup.py && python3 setup.py download_pandoc"
CIBW_BUILD: cp39-* # Build any 1 python version as this wheel is not version dependent
# We skip some variants because:
# - pandoc does not publish binaries for Linux 32bit
CIBW_SKIP: "*-{manylinux_i686,musllinux_i686}"
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: wheelhouse/

publisher_release:
needs: [builder]
needs: [builder_pypandoc, builder_pypandoc_binary]
if: startsWith(github.event.ref, 'refs/tags/v') && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
Expand All @@ -104,7 +121,7 @@ jobs:
password: ${{ secrets.PYPI_API_TOKEN }}

publisher_latest:
needs: [builder]
needs: [builder_pypandoc, builder_pypandoc_binary]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 3 additions & 2 deletions pypandoc/pandoc_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ def download_pandoc(url:Union[str, None]=None,
# compatibility with py3
if pf.startswith("linux"):
pf = "linux"
if platform.architecture()[0] != "64bit":
raise RuntimeError("Linux pandoc is only compiled for 64bit.")
arch = platform.architecture()[0]
if arch != "64bit":
raise RuntimeError(f"Linux pandoc is only compiled for 64bit. Got arch={arch}.")

# get pandoc_urls
pandoc_urls, _ = _get_pandoc_urls(version)
Expand Down

0 comments on commit 586684b

Please sign in to comment.