Skip to content

Conversation

arminsabouri
Copy link
Contributor

@arminsabouri arminsabouri commented Mar 22, 2025

closes #3
closes #57

@arminsabouri arminsabouri force-pushed the py-bindings-ci branch 2 times, most recently from 140fecb to 20bfbb0 Compare March 22, 2025 02:21
arminsabouri and others added 3 commits March 24, 2025 13:31
These files should have never been commited to source. By removing these
shared libraries we encourage developers to build from source instead of
using this repo as a quasi package.
It's not compatible with venv.
The version should, at least for now, without python-specific breaks, match
payjoin-ffi/Cargo.toml
@DanGould
Copy link
Contributor

We should follow bdk-ffi's test-python GitHub workflow as an example

@DanGould DanGould force-pushed the py-bindings-ci branch 2 times, most recently from 907c629 to d8a23f5 Compare March 24, 2025 17:50
@arminsabouri arminsabouri force-pushed the py-bindings-ci branch 6 times, most recently from 1095192 to b12d171 Compare March 24, 2025 20:18
@DanGould
Copy link
Contributor

I see BDK's generate scripts, at least the linux one for python do build the lib before running uniffi-bindgen. That's probably why CI is still failing.

@arminsabouri arminsabouri force-pushed the py-bindings-ci branch 12 times, most recently from 05ab71e to 1e7b834 Compare March 25, 2025 14:25
@arminsabouri arminsabouri force-pushed the py-bindings-ci branch 5 times, most recently from fcd0baf to ad80cee Compare March 25, 2025 16:45
@arminsabouri arminsabouri marked this pull request as ready for review March 25, 2025 17:00
@arminsabouri
Copy link
Contributor Author

Finally done wrestling CI. Major changes include:

  • Removing support for window bindings
  • Skipping broken Python tests (all execept one) and the int. tests. Running the tests are still useful b/c they show there are no build time errors.
  • Missing features flags when building FAT Macos binary

cc @DanGould @spacebear21

@DanGould
Copy link
Contributor

The one thing I would hope for here is that the CI changes are squashed together so that intermediate commits won't fail the CI checks they implement

@arminsabouri
Copy link
Contributor Author

CI changes are squashed together so that intermediate commits won't fail the CI checks they implement

Do you mean the changes needed to make CI pass?
There are a couple duplicated change across linux and MacOS scripts that can be squashed. And I think it makes sense to move the CI commit it self as the last commit

We depend on bitcoin-ffi now.
@DanGould
Copy link
Contributor

yes

@arminsabouri
Copy link
Contributor Author

yes

Moved the commit which adds the CI jobs as the last commit and squashed relevant commits.

The other commits atomically fix different things, not neccecarily for CI. For example removing windows support and fixing the x86 MacOS binary. Even without the last commit we would want these and they achieve independently useful things. I could make a monster commit that fixes the various problems that exist in main and then a CI commit but I do think there is an added benefit to having seperate atomic commits. For instance we could revert just the commit that removes window support in the future. Let me know how you would proceed

Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the windows script entirely seems not to be done.

Otherwise this is looking pretty darn good


#!/bin/bash
chmod +x ./scripts/generate_linux.sh
chmod +x ./scripts/generate_windows.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you wish not also to remove the generate_windows script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agh Yeah this was done in a seperate commit. I will move that change to this commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +91 to +94
- name: "Build wheel"
# Specifying the plat-name argument is necessary to build a wheel with the correct name,
# see issue BDK#350 for more information
run: python3 setup.py bdist_wheel --plat-name macosx_11_0_x86_64 --verbose
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention, as bdk does, the rationale for testing only the x86 wheel? https://github.com/bitcoindevkit/bdk-ffi/blob/master/.github/workflows/test-python.yaml#L97

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it could be worth having this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good comment. I actually realized that we are not building the arm64 wheel on CI. Will add this step.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

cd ../
cargo run --features uniffi --bin uniffi-bindgen generate src/payjoin_ffi.udl --language python --out-dir python/src/payjoin/

cargo run --features uniffi --bin uniffi-bindgen generate --library target/release/$LIBNAME --language python --out-dir python/src/payjoin/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would seem this windows script should have been removed with its support a few commits earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you are right

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

The windows binding support has gotten stale and there is no demand for
it. Supporting these bindings is not worth the overhead of maintaining
them.
We need a release built *.so and *.dylib file before running uniffi-bindgen. Without
the share object file the uniffi command will fail to find the
shared object and error out.

For example:
https://github.com/LtbLightning/payjoin-ffi/actions/runs/14045076123/job/39323956701?pr=60#step:4:474
Skipping any unit test that is currently broken due to FFI bindings.
Issue to re-enable them: LtbLightning#62
New CI job to build and run python unit tests. This gh action workflow
builds for MacOS x86 and arm archs. While only running the tests on an
x86 machine.
Copy link
Contributor

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 57aabaf

Tested on macOS, it took a bit of fiddling with python to get the incantations right but got build and test passing with:

python3 -m venv pjvenv
source pjvenv/bin/activate
bash scripts/generate_macos.sh
python3 setup.py bdist_wheel --verbose
pip3 install ./dist/*.whl
python3 -m unittest --verbose test/payjoin_unit_test.py

----------------------------------------------------------------------
Ran 6 tests in 0.000s

OK (skipped=5)

@arminsabouri
Copy link
Contributor Author

tACK 57aabaf

Tested on macOS, it took a bit of fiddling with python to get the incantations right but got build and test passing with:

python3 -m venv pjvenv
source pjvenv/bin/activate
bash scripts/generate_macos.sh
python3 setup.py bdist_wheel --verbose
pip3 install ./dist/*.whl
python3 -m unittest --verbose test/payjoin_unit_test.py

----------------------------------------------------------------------
Ran 6 tests in 0.000s

OK (skipped=5)

@spacebear21 thanks for testing! Was this on an arm or x86 mac?

@spacebear21
Copy link
Contributor

Ah yes I should've specified, this was on ARM.

Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack 76282f1

@DanGould DanGould merged commit 07eb8bf into LtbLightning:main Mar 26, 2025
13 checks passed
@arminsabouri arminsabouri deleted the py-bindings-ci branch March 26, 2025 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update uniffi bindings - establish QA process for this repo? Build script for Python

3 participants