Skip to content

Commit

Permalink
Merge branch 'pypi'
Browse files Browse the repository at this point in the history
  • Loading branch information
cnixbtc committed Oct 27, 2023
2 parents 8bffae0 + 778b32f commit 7efbe57
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/publish-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Publish Python Bindings
on:
workflow_dispatch:
inputs:
ref:
description: 'commit/tag/branch reference'
required: true
type: string
package-version:
description: 'version for the python package (MAJOR.MINOR.BUILD)'
required: true
type: string
publish:
description: 'value indicating whether to publish to nuget.'
required: true
type: boolean
default: false
secrets:
PYPI_API_TOKEN:
description: 'api token to authenticate to pypi'
required: true

jobs:
build-darwin-wheel:
runs-on: macos-latest
steps:
- name: Checkout breez-sdk repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref || github.sha }}

- uses: actions/download-artifact@v3
with:
name: sdk-bindings-darwin-universal
path: libs/sdk-bindings/bindings-python/src/breez-sdk

- uses: actions/download-artifact@v3
with:
name: bindings-python
path: libs/sdk-bindings/bindings-python/src/breez-sdk

- name: Display structure of downloaded files
run: ls -R libs/sdk-bindings/bindings-python/src/breez-sdk

- name: Update package version
if: ${{ inputs.package-version }}
working-directory: libs/sdk-bindings/bindings-python
run: sed -i.bak -e 's/ version=".*",/ version="${{ inputs.package-version }}",/' setup.py

- name: Build wheel
working-directory: libs/sdk-bindings/bindings-python
run: python setup.py sdist bdist_wheel

- name: Archive the wheel
uses: actions/upload-artifact@v3
with:
name: python-darwin-wheel
path: libs/sdk-bindings/bindings-python/dist/*.whl

publish-package:
runs-on: macos-latest
needs: [build-darwin-wheel]
steps:
- name: Checkout breez-sdk repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref || github.sha }}

- name: Create dist directory
working-directory: libs/sdk-bindings/bindings-python
run: mkdir -p dist

- uses: actions/download-artifact@v3
with:
name: python-darwin-wheel
path: libs/sdk-bindings/bindings-python/dist

- name: "Publish on test PyPI"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/
packages_dir: dist/*
5 changes: 5 additions & 0 deletions libs/sdk-bindings/bindings-python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src/breez_sdk/breez_sdk.py
src/breez_sdk/*.dylib
*.egg-info
build
dist
13 changes: 13 additions & 0 deletions libs/sdk-bindings/bindings-python/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.PHONY: init
init:
make -C ../ init

darwin:
make -C ../ python-darwin
cp ../ffi/python/breez_sdk.py src/breez_sdk
cp ../ffi/python/libbreez_sdk_bindings.dylib src/breez_sdk

linux:
make -C ../ python-linux
cp ../ffi/python/breez_sdk.py src/breez_sdk
cp ../ffi/python/libbreez_sdk_bindings.dylib src/breez_sdk
3 changes: 3 additions & 0 deletions libs/sdk-bindings/bindings-python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
17 changes: 17 additions & 0 deletions libs/sdk-bindings/bindings-python/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python

from setuptools import setup

setup(
name="breez_sdk",
version="0.2.7.dev0",
description="Python language bindings for the Breez SDK",
packages=["breez_sdk"],
package_dir={"breez_sdk": "./src/breez_sdk"},
include_package_data=True,
package_data={"breez_sdk": ["*.dylib"]},
url="https://github.com/breez/breez-sdk",
author="Breez <[email protected]>",
license="MIT",
has_ext_modules=lambda: True,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from breez_sdk.breez_sdk import *

0 comments on commit 7efbe57

Please sign in to comment.