File tree Expand file tree Collapse file tree 6 files changed +131
-1
lines changed Expand file tree Collapse file tree 6 files changed +131
-1
lines changed Original file line number Diff line number Diff line change 25
25
26
26
## Unreleased
27
27
28
+ ### Changed
29
+
30
+ * Publish python wheels with cp39-abi3 (https://github.com/rust-nostr/nostr-sdk-ffi/pull/7 )
31
+
28
32
### Added
29
33
30
- * Add support for event streaming (https://github.com/rust-nostr/nostr-sdk-ffi/pull/6 )
34
+ * Add support for event streaming (https://github.com/rust-nostr/nostr-sdk-ffi/pull/6 )
31
35
32
36
## v0.41.0 - 2025/04/15
33
37
Original file line number Diff line number Diff line change 47
47
jar :
48
48
@ cd jvm && bash assemble.sh
49
49
50
+ # Assemble the python wheels
51
+ py :
52
+ @ cd python && bash assemble.sh
53
+
50
54
# Assemble the C# package
51
55
csharp :
52
56
@ cd csharp && bash assemble.sh
@@ -61,6 +65,11 @@ publish-aar: aar
61
65
publish-jar : jar
62
66
cd jvm && ./ gradlew publishAndReleaseToMavenCentral --no-configuration-cache
63
67
68
+ # Publish Wheels
69
+ [confirm ]
70
+ publish-py : py
71
+ cd python && twine upload dist/ *
72
+
64
73
# Compile and build Swift Package
65
74
[macos ]
66
75
swift :
Original file line number Diff line number Diff line change
1
+ FROM python:3.9-slim
2
+
3
+ # Set up working directory
4
+ WORKDIR /build
5
+
6
+ # Create directories for mounting volumes
7
+ RUN mkdir -p python binding binaries dist
8
+
9
+ # Copy source
10
+ COPY src/nostr-sdk/__init__.py python/src/nostr-sdk/
11
+ COPY LICENSE python/
12
+ COPY MANIFEST.in python/
13
+ COPY pyproject.toml python/
14
+ COPY README.md python/
15
+ COPY requirements.txt python/
16
+ COPY setup.py python/
17
+
18
+ # Copy the build script
19
+ COPY --chown=1000:1000 buildwheel.sh .
20
+ RUN chmod +x buildwheel.sh
21
+
22
+ # Install Python build tools
23
+ RUN pip install -r python/requirements.txt
24
+
25
+ # Update permissions
26
+ RUN chown -R 1000:1000 /build
27
+ RUN chmod -R 777 /build
28
+
29
+ # Change user
30
+ USER 1000
31
+
32
+ # Set the entrypoint to our build script
33
+ ENTRYPOINT ["/build/buildwheel.sh" ]
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ set -exuo pipefail
4
+
5
+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
6
+ DIST_DIR=" ${SCRIPT_DIR} /dist"
7
+ SRC_DIR=" ${SCRIPT_DIR} /src/nostr-sdk"
8
+ FFI_DIR=" ${SCRIPT_DIR} /../ffi"
9
+
10
+ # Clean
11
+ rm -rf " ${DIST_DIR} "
12
+ rm -rf " ${SRC_DIR} /*.so"
13
+ rm -rf " ${SRC_DIR} /nostr_sdk.py"
14
+
15
+ # Make dir
16
+ mkdir -p " ${DIST_DIR} "
17
+
18
+ # Build docker image
19
+ docker build -t wheel-builder " ${SCRIPT_DIR} "
20
+
21
+ # Generate bindings
22
+ cargo run -p nostr-sdk-ffi --features uniffi-cli --bin uniffi-bindgen generate --library " ${FFI_DIR} /apple/macos/x86_64/libnostr_sdk_ffi.dylib" --language python --no-format -o " ${SRC_DIR} "
23
+
24
+ # Build linux wheels
25
+ docker run --rm -v " ${FFI_DIR} /linux/x86/:/build/binaries" -v " ${SRC_DIR} :/build/binding" -v " $( pwd) /dist:/build/dist" -e PLAT_NAME=" manylinux_2_17_i686" wheel-builder
26
+ docker run --rm -v " ${FFI_DIR} /linux/x86_64/:/build/binaries" -v " ${SRC_DIR} :/build/binding" -v " $( pwd) /dist:/build/dist" -e PLAT_NAME=" manylinux_2_17_x86_64" wheel-builder
27
+ docker run --rm -v " ${FFI_DIR} /linux/aarch64/:/build/binaries" -v " ${SRC_DIR} :/build/binding" -v " $( pwd) /dist:/build/dist" -e PLAT_NAME=" manylinux_2_17_aarch64" wheel-builder
28
+
29
+ # Build macos wheels
30
+ docker run --rm -v " ${FFI_DIR} /apple/macos/x86_64/:/build/binaries" -v " ${SRC_DIR} :/build/binding" -v " $( pwd) /dist:/build/dist" -e PLAT_NAME=" macosx_11_0_x86_64" wheel-builder
31
+ docker run --rm -v " ${FFI_DIR} /apple/macos/aarch64/:/build/binaries" -v " ${SRC_DIR} :/build/binding" -v " $( pwd) /dist:/build/dist" -e PLAT_NAME=" macosx_11_0_arm64" wheel-builder
32
+
33
+ # Build win wheels
34
+ docker run --rm -v " ${FFI_DIR} /win/x86/:/build/binaries" -v " ${SRC_DIR} :/build/binding" -v " $( pwd) /dist:/build/dist" -e PLAT_NAME=" win32" wheel-builder
35
+ docker run --rm -v " ${FFI_DIR} /win/x86_64/:/build/binaries" -v " ${SRC_DIR} :/build/binding" -v " $( pwd) /dist:/build/dist" -e PLAT_NAME=" win_amd64" wheel-builder
36
+ docker run --rm -v " ${FFI_DIR} /win/aarch64/:/build/binaries" -v " ${SRC_DIR} :/build/binding" -v " $( pwd) /dist:/build/dist" -e PLAT_NAME=" win_arm64" wheel-builder
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Build a wheel. This script is used from the Dockerfile!
4
+
5
+ set -exuo pipefail
6
+
7
+ # Check if required arguments are provided
8
+ if [ -z " $PLAT_NAME " ]; then
9
+ echo " ERROR: PLAT_NAME environment variable is required"
10
+ exit 1
11
+ fi
12
+
13
+ echo " Building wheel for platform: $PLAT_NAME "
14
+
15
+ # Copy binaries to python directory if they exist
16
+ if [ " $( ls -A /build/binaries) " ]; then
17
+ cp -r /build/binaries/* /build/python/src/nostr-sdk/
18
+ echo " Copied binaries to Python package directory"
19
+ else
20
+ echo " No binaries found in /build/binaries"
21
+ exit 1
22
+ fi
23
+
24
+ # Copy generated binding file to the correct location if it exists
25
+ if [ -f " /build/binding/nostr_sdk.py" ]; then
26
+ # Make sure the target directory exists
27
+ cp /build/binding/nostr_sdk.py /build/python/src/nostr-sdk/
28
+ echo " Copied binding file (nostr_sdk.py) to src/nostr-sdk/ directory"
29
+ else
30
+ echo " WARNING: Binding file (nostr_sdk.py) not found in /build/binding"
31
+ exit 1
32
+ fi
33
+
34
+
35
+ # Enter Python package directory
36
+ cd /build/python
37
+
38
+ # Build the wheel with Python 3.9 ABI3 compatibility
39
+ python setup.py bdist_wheel --plat-name " $PLAT_NAME " --python-tag cp39.abi3
40
+
41
+ # Copy wheel to the output directory
42
+ cp dist/* .whl /build/dist/
Original file line number Diff line number Diff line change 22
22
# This is required to ensure the library name includes the python version, abi, and platform tags
23
23
# See issue #350 for more information
24
24
has_ext_modules = lambda : True ,
25
+ # This enables abi3 compatibility
26
+ options = {
27
+ "bdist_wheel" : {
28
+ "py_limited_api" : "cp39" , # Support Python 3.9+
29
+ }
30
+ },
25
31
)
You can’t perform that action at this time.
0 commit comments