Skip to content

Commit a4ea3c2

Browse files
authored
Merge pull request #196 from openzim/windows
Add Windows Support
2 parents 0f77346 + 9dea887 commit a4ea3c2

10 files changed

Lines changed: 244 additions & 81 deletions

File tree

.github/workflows/release.yaml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- published
77

88
env:
9-
LIBZIM_DL_VERSION: "9.1.0"
9+
LIBZIM_DL_VERSION: "9.2.3-2"
1010
MACOSX_DEPLOYMENT_TARGET: "12.0"
1111
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
1212
# APPLE_SIGNING_KEYCHAIN_PATH set in prepare keychain step
@@ -22,10 +22,10 @@ jobs:
2222
runs-on: ${{ matrix.os }}
2323
strategy:
2424
matrix:
25-
os: [ubuntu-20.04, macos-13] # windows-2019
25+
os: [ubuntu-20.04, macos-13, windows-2022]
2626

2727
steps:
28-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
2929

3030
- name: Set up QEMU
3131
if: runner.os == 'Linux'
@@ -68,7 +68,7 @@ jobs:
6868
security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
6969
7070
- name: Build wheels
71-
uses: pypa/cibuildwheel@v2.16
71+
uses: pypa/cibuildwheel@v2.20
7272

7373
- name: Cleanup Apple Keychain
7474
if: matrix.os == 'macos-13'
@@ -78,36 +78,49 @@ jobs:
7878
security delete-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
7979
rm -f ${APPLE_SIGNING_KEYCHAIN_PATH}
8080
81-
- uses: actions/upload-artifact@v3
81+
- uses: actions/upload-artifact@v4
8282
with:
83+
name: wheels-${{ matrix.os }}
8384
path: ./wheelhouse/*.whl
8485

8586
build_sdist:
8687
name: Build source distribution
8788
runs-on: ubuntu-latest
8889
steps:
89-
- uses: actions/checkout@v3
90+
- uses: actions/checkout@v4
9091

9192
- name: Build sdist
9293
run: pipx run build --sdist
9394

94-
- uses: actions/upload-artifact@v3
95+
- uses: actions/upload-artifact@v4
9596
with:
97+
name: sdist
9698
path: dist/*.tar.gz
9799

98100
upload_pypi:
99101
needs: [build_wheels, build_sdist]
100102
runs-on: ubuntu-latest
101103
environment: release
102104
steps:
103-
- uses: actions/download-artifact@v3
105+
# retrieve all artifacts
106+
- uses: actions/download-artifact@v4
104107
with:
105-
# unpacks default artifact into dist/
106-
# if `name: artifact` is omitted, the action will create extra parent dir
107-
name: artifact
108+
name: sdist
109+
path: dist
110+
- uses: actions/download-artifact@v4
111+
with:
112+
name: wheels-ubuntu-20.04
113+
path: dist
114+
- uses: actions/download-artifact@v4
115+
with:
116+
name: wheels-macos-13
117+
path: dist
118+
- uses: actions/download-artifact@v4
119+
with:
120+
name: wheels-windows-2022
108121
path: dist
109122

110-
- uses: pypa/gh-action-pypi-publish@v1.8.10
123+
- uses: pypa/gh-action-pypi-publish@v1.9.0
111124
with:
112125
user: __token__
113126
# password: ${{ secrets.PYPI_TEST_API_TOKEN }}

.github/workflows/test.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ name: test
22
on: [push]
33

44
env:
5-
LIBZIM_DL_VERSION: "9.1.0"
5+
LIBZIM_DL_VERSION: "9.2.3-2"
66
MACOSX_DEPLOYMENT_TARGET: "12.0"
77

88
jobs:
99
lint:
1010
runs-on: ubuntu-22.04
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313

1414
- name: Set up Python ${{ matrix.python }}
15-
uses: actions/setup-python@v4
15+
uses: actions/setup-python@v5
1616
with:
1717
python-version: "3.12"
1818
architecture: x64
@@ -27,14 +27,14 @@ jobs:
2727
runs-on: ${{ matrix.os }}
2828
strategy:
2929
matrix:
30-
os: [ubuntu-22.04, macos-13]
30+
os: [macos-13, windows-2022, ubuntu-22.04]
3131
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
3232

3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
3535

3636
- name: Set up Python ${{ matrix.python }}
37-
uses: actions/setup-python@v4
37+
uses: actions/setup-python@v5
3838
with:
3939
python-version: ${{ matrix.python }}
4040
architecture: x64
@@ -47,13 +47,17 @@ jobs:
4747
PROFILE: 1
4848
run: pip install -e .
4949

50+
- name: move DLLs next to wrapper
51+
if: matrix.os == 'windows-2022'
52+
run: Move-Item -Force -Path .\libzim\*.dll -Destination .\
53+
5054
- name: Testing
5155
run: |
5256
pip install pytest pytest-cov cython
5357
py.test --cov=libzim --cov-report=term --cov-report term-missing .
5458
5559
- name: Upload coverage report to codecov
5660
if: matrix.os == 'ubuntu-22.04' && matrix.python == '3.11'
57-
uses: codecov/codecov-action@v3
61+
uses: codecov/codecov-action@v4
5862
with:
5963
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/wheels.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ on:
55
push:
66
branches:
77
- main
8+
- windows
89

910
env:
10-
LIBZIM_DL_VERSION: "9.1.0"
11+
LIBZIM_DL_VERSION: "9.2.3-2"
1112
MACOSX_DEPLOYMENT_TARGET: "12.0"
1213
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
1314
CIBW_BUILD_VERBOSITY: "3"
@@ -19,33 +20,35 @@ jobs:
1920
runs-on: ${{ matrix.os }}
2021
strategy:
2122
matrix:
22-
os: [ubuntu-20.04, macos-13] # windows-2019
23+
os: [macos-13, windows-2022, ubuntu-20.04]
2324

2425
steps:
25-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2627

2728
- name: Set up QEMU
2829
if: runner.os == 'Linux'
29-
uses: docker/setup-qemu-action@v2
30+
uses: docker/setup-qemu-action@v3
3031
with:
3132
platforms: all
3233

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

36-
- uses: actions/upload-artifact@v3
37+
- uses: actions/upload-artifact@v4
3738
with:
39+
name: wheels-${{ matrix.os }}
3840
path: ./wheelhouse/*.whl
3941

4042
build_sdist:
4143
name: Build source distribution
4244
runs-on: ubuntu-latest
4345
steps:
44-
- uses: actions/checkout@v3
46+
- uses: actions/checkout@v4
4547

4648
- name: Build sdist
4749
run: pipx run build --sdist
4850

49-
- uses: actions/upload-artifact@v3
51+
- uses: actions/upload-artifact@v4
5052
with:
53+
name: sdist
5154
path: dist/*.tar.gz

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleazed
9+
10+
### Added
11+
12+
- Windows (x64) support (#91)
13+
814
## [3.4.0] - 2023-12-16
915

1016
### Added

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ exclude *.egg-info/*
1515
exclude libzim/*.dylib
1616
exclude libzim/*.so
1717
exclude libzim/*.so.*
18+
exclude libzim/*.dll

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,25 @@ with Creator("test.zim") as creator:
166166
| `APPLE_SIGNING_KEYCHAIN_PATH` | `/tmp/build.keychain` | Path to the Keychain containing the certificate to sign for macOS with |
167167
| `APPLE_SIGNING_KEYCHAIN_PROFILE` | `build` | Name of the profile in the specified Keychain |
168168

169+
170+
### Building on Windows
171+
172+
On Windows, built wheels needs to be fixed post-build to move the bundled DLLs (libzim and libicu)
173+
next to the wrapper (Windows does not support runtime path).
174+
175+
After building you wheel, run
176+
177+
```ps
178+
python setup.py repair_win_wheel --wheel=dist/xxx.whl --destdir wheels\
179+
```
180+
181+
Similarily, if you install as editable (`pip install -e .`), you need to place those DLLs at the root
182+
of the repo.
183+
184+
```ps
185+
Move-Item -Force -Path .\libzim\*.dll -Destination .\
186+
```
187+
169188
### Examples
170189

171190
##### Default: downloading and bundling most appropriate libzim release binary

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = [ "setuptools == 68.2.2", "wheel == 0.41.3", "cython == 3.0.5" ]
2+
requires = [ "setuptools == 68.2.2", "wheel == 0.41.3", "cython == 3.0.5", "delocate==0.12.0" ]
33
build-backend = "setuptools.build_meta"
44

55
[tool.black]
@@ -12,9 +12,8 @@ pythonpath = ["."]
1212

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

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

26+
[tool.cibuildwheel.windows]
27+
before-build = "pip install setuptools cython delocate"
28+
repair-wheel-command = "python.exe setup.py repair_win_wheel --destdir={dest_dir} --wheel={wheel}"
29+
2730
[tool.cibuildwheel.linux]
2831
archs = ["x86_64", "aarch64"]
2932

setup.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ test_requires =
5050
libzim =
5151
libzim.9.dylib
5252
libzim.so.9
53+
zim-9.dll
54+
icuuc74.dll
55+
icutu74.dll
56+
icuio74.dll
57+
icuin74.dll
58+
icudt74.dll
5359

5460
[isort]
5561
profile = black

0 commit comments

Comments
 (0)