You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revamped setup to create proper wheel out-of-the-box
We used to generate our wheels in a very hacky way, by:
- manually downloading libzim binaries into a dedicated location
- building the extension, manipulating the LD_LIBRARY_PATH
- manipulate the build directory to place libzim binary inside
- eventually creating the wheel
It was:
- not straightforward.
- unclear what the outcome was
- often bundling libzim in sdist
- not integratable with other tools
This now builds correct wheels and source using an in-setup-only process.
Copy file name to clipboardExpand all lines: README.md
+54-3Lines changed: 54 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,10 +18,16 @@ It is primarily used in [openZIM](https://github.com/openzim/) scrapers like [`s
18
18
pip install libzim
19
19
```
20
20
21
-
The [PyPI package](https://pypi.org/project/libzim/) is available for x86_64 macOS and GNU/Linux only. It bundles a [recent release](https://download.openzim.org/release/libzim/) of the C++ libzim.
21
+
Our [PyPI wheels](https://pypi.org/project/libzim/) bundle a [recent release](https://download.openzim.org/release/libzim/) of the C++ libzim and are available for the following platforms:
22
+
23
+
- macOS for `x86_64` and `arm64`
24
+
- GNU/Linux for `x86_64`, `armhf` and `aarch64`
25
+
- Linux+musl for `x86_64` and `aarch64`
26
+
27
+
Wheels are available for both CPython and PyPy.
28
+
29
+
Users on other platforms can install the source distribution (see [Building](#Building) below).
22
30
23
-
On other platforms, you'd have to [compile C++ libzim from
24
-
source](https://github.com/openzim/libzim) first then build this one, adjusting `LD_LIBRARY_PATH`.
25
31
26
32
## Contributions
27
33
@@ -121,6 +127,51 @@ with Creator("test.zim").config_indexing(True, "eng") as creator:
121
127
creator.add_metadata(name.title(), value)
122
128
```
123
129
130
+
## Building
131
+
132
+
`libzim` package building offers different behaviors via environment variables
|`LIBZIM_DL_VERSION`|`8.1.1` or `2023-04-14`| Specify the C++ libzim binary version to download and bundle. Either a release version string or a date, in which case it downloads a nightly |
137
+
|`USE_SYSTEM_LIBZIM`|`1`| Uses `LDFLAG` and `CFLAGS` to find the libzim to link against. Resulting wheel won't bundle C++ libzim. |
138
+
|`DONT_DOWNLOAD_LIBZIM`|`1`| Disable downloading of C++ libzim. Place headers in `include/` and libzim dylib/so in `libzim/` if no using system libzim. It will be bundled in wheel. |
139
+
|`PROFILE`|`1`| Enable profile tracing in Cython extension. Required for Cython code coverage reporting. |
140
+
|`SIGN_APPLE`|`1`| Set to sign and notarize the extension for macOS. Requires following informations |
141
+
|`APPLE_SIGNING_IDENTITY`|`Developer ID Application: OrgName (ID)`| Required for signing on macOS |
142
+
|`APPLE_SIGNING_KEYCHAIN_PATH`|`/tmp/build.keychain`| Path to the Keychain containing the certificate to sign for macOS with |
143
+
|`APPLE_SIGNING_KEYCHAIN_PROFILE`|`build`| Name of the profile in the specified Keychain |
144
+
145
+
### Examples
146
+
147
+
##### Default: downloading and bundling most appropriate libzim release binary
148
+
149
+
```sh
150
+
python3 -m build
151
+
```
152
+
153
+
#### Using system libzim (brew, debian or manually installed) - not bundled
154
+
155
+
```sh
156
+
# using system-installed C++ libzim
157
+
brew install libzim # macOS
158
+
apt-get install libzim-devel # debian
159
+
dnf install libzim-dev # fedora
160
+
USE_SYSTEM_LIBZIM=1 python3 -m build --wheel
161
+
162
+
# using a specific C++ libzim
163
+
USE_SYSTEM_LIBZIM=1 \
164
+
CFLAGS="-I/usr/local/include" \
165
+
LDFLAGS="-L/usr/local/lib"
166
+
DYLD_LIBRARY_PATH="/usr/local/lib" \
167
+
LD_LIBRARY_PATH="/usr/local/lib" \
168
+
python3 -m build --wheel
169
+
```
170
+
171
+
#### Other platforms
172
+
173
+
On platforms for which there is no [official binary](https://download.openzim.org/release/libzim/) available, you'd have to [compile C++ libzim from source](https://github.com/openzim/libzim) first then either use `DONT_DOWNLOAD_LIBZIM` or `USE_SYSTEM_LIBZIM`.
0 commit comments