Skip to content

Commit

Permalink
Merge pull request #196 from openzim/windows
Browse files Browse the repository at this point in the history
Add Windows Support
  • Loading branch information
rgaudin committed Sep 3, 2024
2 parents 0f77346 + 9dea887 commit a4ea3c2
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 81 deletions.
37 changes: 25 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- published

env:
LIBZIM_DL_VERSION: "9.1.0"
LIBZIM_DL_VERSION: "9.2.3-2"
MACOSX_DEPLOYMENT_TARGET: "12.0"
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
# APPLE_SIGNING_KEYCHAIN_PATH set in prepare keychain step
Expand All @@ -22,10 +22,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-13] # windows-2019
os: [ubuntu-20.04, macos-13, windows-2022]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
- name: Build wheels
uses: pypa/cibuildwheel@v2.16
uses: pypa/cibuildwheel@v2.20

- name: Cleanup Apple Keychain
if: matrix.os == 'macos-13'
Expand All @@ -78,36 +78,49 @@ jobs:
security delete-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
rm -f ${APPLE_SIGNING_KEYCHAIN_PATH}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/download-artifact@v3
# retrieve all artifacts
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
name: sdist
path: dist
- uses: actions/download-artifact@v4
with:
name: wheels-ubuntu-20.04
path: dist
- uses: actions/download-artifact@v4
with:
name: wheels-macos-13
path: dist
- uses: actions/download-artifact@v4
with:
name: wheels-windows-2022
path: dist

- uses: pypa/gh-action-pypi-publish@v1.8.10
- uses: pypa/gh-action-pypi-publish@v1.9.0
with:
user: __token__
# password: ${{ secrets.PYPI_TEST_API_TOKEN }}
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ name: test
on: [push]

env:
LIBZIM_DL_VERSION: "9.1.0"
LIBZIM_DL_VERSION: "9.2.3-2"
MACOSX_DEPLOYMENT_TARGET: "12.0"

jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.12"
architecture: x64
Expand All @@ -27,14 +27,14 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13]
os: [macos-13, windows-2022, ubuntu-22.04]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand All @@ -47,13 +47,17 @@ jobs:
PROFILE: 1
run: pip install -e .

- name: move DLLs next to wrapper
if: matrix.os == 'windows-2022'
run: Move-Item -Force -Path .\libzim\*.dll -Destination .\

- name: Testing
run: |
pip install pytest pytest-cov cython
py.test --cov=libzim --cov-report=term --cov-report term-missing .
- name: Upload coverage report to codecov
if: matrix.os == 'ubuntu-22.04' && matrix.python == '3.11'
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
17 changes: 10 additions & 7 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ on:
push:
branches:
- main
- windows

env:
LIBZIM_DL_VERSION: "9.1.0"
LIBZIM_DL_VERSION: "9.2.3-2"
MACOSX_DEPLOYMENT_TARGET: "12.0"
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
CIBW_BUILD_VERBOSITY: "3"
Expand All @@ -19,33 +20,35 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-13] # windows-2019
os: [macos-13, windows-2022, ubuntu-20.04]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.16

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleazed

### Added

- Windows (x64) support (#91)

## [3.4.0] - 2023-12-16

### Added
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ exclude *.egg-info/*
exclude libzim/*.dylib
exclude libzim/*.so
exclude libzim/*.so.*
exclude libzim/*.dll
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,25 @@ with Creator("test.zim") as creator:
| `APPLE_SIGNING_KEYCHAIN_PATH` | `/tmp/build.keychain` | Path to the Keychain containing the certificate to sign for macOS with |
| `APPLE_SIGNING_KEYCHAIN_PROFILE` | `build` | Name of the profile in the specified Keychain |


### Building on Windows

On Windows, built wheels needs to be fixed post-build to move the bundled DLLs (libzim and libicu)
next to the wrapper (Windows does not support runtime path).

After building you wheel, run

```ps
python setup.py repair_win_wheel --wheel=dist/xxx.whl --destdir wheels\
```

Similarily, if you install as editable (`pip install -e .`), you need to place those DLLs at the root
of the repo.

```ps
Move-Item -Force -Path .\libzim\*.dll -Destination .\
```

### Examples

##### Default: downloading and bundling most appropriate libzim release binary
Expand Down
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = [ "setuptools == 68.2.2", "wheel == 0.41.3", "cython == 3.0.5" ]
requires = [ "setuptools == 68.2.2", "wheel == 0.41.3", "cython == 3.0.5", "delocate==0.12.0" ]
build-backend = "setuptools.build_meta"

[tool.black]
Expand All @@ -12,9 +12,8 @@ pythonpath = ["."]

[tool.cibuildwheel]
build = "*"
# disabling windows until hhttps://github.com/kiwix/kiwix-build/issues/466
# disabling PyPy due to 2 failing tests
skip = "pp* *-win*"
skip = "pp* *win32*"

test-requires = ["pytest"]
test-command = "py.test {project}/tests/"
Expand All @@ -24,6 +23,10 @@ manylinux-aarch64-image = "manylinux_2_28"
manylinux-pypy_x86_64-image = "manylinux_2_28"
manylinux-pypy_aarch64-image = "manylinux_2_28"

[tool.cibuildwheel.windows]
before-build = "pip install setuptools cython delocate"
repair-wheel-command = "python.exe setup.py repair_win_wheel --destdir={dest_dir} --wheel={wheel}"

[tool.cibuildwheel.linux]
archs = ["x86_64", "aarch64"]

Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ test_requires =
libzim =
libzim.9.dylib
libzim.so.9
zim-9.dll
icuuc74.dll
icutu74.dll
icuio74.dll
icuin74.dll
icudt74.dll

[isort]
profile = black
Expand Down
Loading

0 comments on commit a4ea3c2

Please sign in to comment.