diff --git a/.github/workflows/publish-python.yaml b/.github/workflows/publish-python.yaml index 5c5be3f..df90a97 100644 --- a/.github/workflows/publish-python.yaml +++ b/.github/workflows/publish-python.yaml @@ -28,7 +28,7 @@ jobs: fetch-depth: 0 - name: "Configure Git safe directory" - run: git config --global --add safe.directory /__w/bdkpython/bdkpython + run: git config --global --add safe.directory /__w/bdk-python/bdk-python - name: "Install Rust 1.84.1" uses: actions-rs/toolchain@v1 @@ -38,15 +38,18 @@ jobs: - name: "Generate bdk.py and binaries" run: bash ./scripts/generate-linux.sh + - name: "Install build" + run: pip install build + - name: "Build wheel" # Specifying the plat-name argument is necessary to build a wheel with the correct name, # see issue #350 for more information - run: ${PYBIN}/python setup.py bdist_wheel --plat-name manylinux_2_28_x86_64 --verbose + run: ${PYBIN}/python -m build --wheel --config-setting=--build-option=--plat-name=manylinux_2_28_x86_64 --verbose - uses: actions/upload-artifact@v4 with: name: bdkpython-manylinux_2_28_x86_64-${{ matrix.python }} - path: /home/runner/work/bdkpython/bdkpython/dist/*.whl + path: /home/runner/work/bdk-python/bdk-python/dist/*.whl build-macos-arm64-wheels: name: "Build macOS arm64 wheel" @@ -73,17 +76,20 @@ jobs: - name: "Generate bdk.py and binaries" run: bash ./scripts/generate-macos-arm64.sh + + - name: "Install build" + run: pip3 install build - name: "Build wheel" # Specifying the plat-name argument is necessary to build a wheel with the correct name, # see issue #350 for more information - run: python3 setup.py bdist_wheel --plat-name macosx_11_0_arm64 --verbose + run: python3 -m build --wheel --config-setting=--build-option=--plat-name=macosx_11_0_arm64 --verbose - name: "Upload artifacts" uses: actions/upload-artifact@v4 with: name: bdkpython-macos-arm64-${{ matrix.python }} - path: /Users/runner/work/bdkpython/bdkpython/dist/*.whl + path: /Users/runner/work/bdk-python/bdk-python/dist/*.whl build-macos-x86_64-wheels: name: "Build macOS x86_64 wheel" @@ -111,15 +117,18 @@ jobs: - name: "Generate bdk.py and binaries" run: bash ./scripts/generate-macos-x86_64.sh + - name: "Install build" + run: pip3 install build + - name: "Build wheel" # Specifying the plat-name argument is necessary to build a wheel with the correct name, # see issue #350 for more information - run: python3 setup.py bdist_wheel --plat-name macosx_11_0_x86_64 --verbose + run: python3 -m build --wheel --config-setting=--build-option=--plat-name=macosx_11_0_x86_64 --verbose - uses: actions/upload-artifact@v4 with: name: bdkpython-macos-x86_64-${{ matrix.python }} - path: /Users/runner/work/bdkpython/bdkpython/dist/*.whl + path: /Users/runner/work/bdk-python/bdk-python/dist/*.whl build-windows-wheels: name: "Build Windows wheel" @@ -146,14 +155,17 @@ jobs: - name: "Generate bdk.py and binaries" run: bash ./scripts/generate-windows.sh + - name: "Install build" + run: pip install build + - name: "Build wheel" - run: python setup.py bdist_wheel --verbose + run: python -m build --wheel --verbose - name: "Upload artifacts" uses: actions/upload-artifact@v4 with: name: bdkpython-win-${{ matrix.python }} - path: D:\a\bdkpython\bdkpython\dist\*.whl + path: D:\a\bdk-python\bdk-python\dist\*.whl publish-pypi: name: "Publish on PyPI" diff --git a/.github/workflows/test-python.yaml b/.github/workflows/test-python.yaml index 12bb9f6..2477a7e 100644 --- a/.github/workflows/test-python.yaml +++ b/.github/workflows/test-python.yaml @@ -31,7 +31,7 @@ jobs: fetch-depth: 0 - name: "Configure Git safe directory" - run: git config --global --add safe.directory /__w/bdkpython/bdkpython + run: git config --global --add safe.directory /__w/bdk-python/bdk-python - name: "Install Rust 1.84.1" uses: actions-rs/toolchain@v1 @@ -41,10 +41,11 @@ jobs: - name: "Generate bdk.py and binaries" run: bash ./scripts/generate-linux.sh + - name: "Install build" + run: ${PYBIN}/pip install build + - name: "Build wheel" - # Specifying the plat-name argument is necessary to build a wheel with the correct name, - # see issue #350 for more information - run: ${PYBIN}/python setup.py bdist_wheel --plat-name manylinux_2_28_x86_64 --verbose + run: ${PYBIN}/python -m build --wheel --config-setting=--build-option=--plat-name=manylinux_2_28_x86_64 --verbose - name: "Install wheel" run: ${PYBIN}/pip install ./dist/*.whl @@ -56,7 +57,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: bdkpython-manylinux_2_28_x86_64-${{ matrix.python }} - path: /home/runner/work/bdkpython/bdkpython/dist/*.whl + path: /home/runner/work/bdk-python/bdk-python/dist/*.whl build-macos-arm64-wheels: name: "Build and test macOS arm64 wheels" @@ -84,10 +85,13 @@ jobs: - name: "Generate bdk.py and binaries" run: bash ./scripts/generate-macos-arm64.sh + - name: "Install build" + run: pip3 install build + - name: "Build wheel" # Specifying the plat-name argument is necessary to build a wheel with the correct name, # see issue #350 for more information - run: python3 setup.py bdist_wheel --plat-name macosx_11_0_arm64 --verbose + run: python3 -m build --wheel --config-setting=--build-option=--plat-name=macosx_11_0_arm64 --verbose # You can't install the arm64 wheel on the CI, so we skip these steps and simply test that the wheel builds # - name: "Install wheel and run tests" @@ -99,7 +103,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: bdkpython-macos-arm64-${{ matrix.python }} - path: /Users/runner/work/bdkpython/bdkpython/dist/*.whl + path: /Users/runner/work/bdk-python/bdk-python/dist/*.whl build-macos-x86_64-wheels: name: "Build and test macOS x86_64 wheels" @@ -126,10 +130,11 @@ jobs: - name: "Generate bdk.py and binaries" run: bash ./scripts/generate-macos-x86_64.sh + - name: "Install build" + run: pip3 install build + - name: "Build wheel" - # Specifying the plat-name argument is necessary to build a wheel with the correct name, - # see issue #350 for more information - run: python3 setup.py bdist_wheel --plat-name macosx_11_0_x86_64 --verbose + run: python3 -m build --wheel --config-setting=--build-option=--plat-name=macosx_11_0_x86_64 --verbose - name: "Install wheel" run: pip3 install ./dist/*.whl @@ -141,7 +146,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: bdkpython-macos-x86_64-${{ matrix.python }} - path: /Users/runner/work/bdkpython/bdkpython/dist/*.whl + path: /Users/runner/work/bdk-python/bdk-python/dist/*.whl build-windows-wheels: name: "Build and test Windows wheels" @@ -169,17 +174,20 @@ jobs: - name: "Generate bdk.py and binaries" run: bash ./scripts/generate-windows.sh + - name: "Install build" + run: pip install build + - name: "Build wheel" - run: python setup.py bdist_wheel --verbose + run: python -m build --wheel --verbose - name: "Upload artifact test" uses: actions/upload-artifact@v4 with: name: bdkpython-windows-${{ matrix.python }} - path: D:\a\bdkpython\bdkpython\dist\*.whl + path: D:\a\bdk-python\bdk-python\dist\*.whl - name: "Install dependencies" - run: Get-ChildItem 'D:\a\bdkpython\bdkpython\dist\*.whl' | ForEach-Object {pip install $_.FullName} + run: Get-ChildItem 'D:\a\bdk-python\bdk-python\dist\*.whl' | ForEach-Object {pip install $_.FullName} shell: powershell - name: "Run tests" @@ -197,7 +205,7 @@ jobs: fetch-depth: 0 - name: "Configure Git safe directory" - run: git config --global --add safe.directory /__w/bdkpython/bdkpython + run: git config --global --add safe.directory /__w/bdk-python/bdk-python - name: "Install Ruff" run: curl -LsSf https://astral.sh/ruff/install.sh | sh diff --git a/README.md b/README.md index 3e3be44..5ffdc79 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,12 @@ This repository uses the bdk-ffi repository as a git submodule. Here are useful ```sh source .localpythonenv/bin/activate + bash scripts/generate-macos-arm64.sh -python3 setup.py bdist_wheel + +python3 -m build --wheel --outdir dist --verbose + pip3 install ./dist/bdkpython-.whl --force-reinstall + python3 -m unittest --verbose ``` diff --git a/justfile b/justfile index 94deda6..e2f1344 100644 --- a/justfile +++ b/justfile @@ -16,6 +16,16 @@ clean: rm -rf ./build/ rm -rf ./dist/ +[group("Build")] +[doc("Build the wheel using pyproject.toml (modern build system).")] +build: + python3 -m build --wheel --verbose + +[group("Build")] +[doc("Install the wheel locally (force reinstall).")] +install: + pip3 install dist/bdkpython-*.whl --force-reinstall + [group("Submodule")] [doc("Initialize bdk-ffi submodule to committed hash.")] submodule-init: diff --git a/pyproject.toml b/pyproject.toml index 2012f16..ea973f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,36 @@ [build-system] -requires = ["setuptools", "wheel", "setuptools-rust"] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "bdkpython" +version = "2.1.0.dev0" +description = "The Python language bindings for the Bitcoin Development Kit" +readme = "README.md" +requires-python = ">=3.7" +license = "MIT OR Apache-2.0" +license-files = ["LICENSE-MIT", "LICENSE-APACHE"] +authors = [ + { name = "Bitcoin Dev Kit Developers", email = "dev@bitcoindevkit.org" } +] +keywords = ["bitcoin", "bdk", "wallet", "ffi", "rust"] +classifiers = [ + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", +] + +[project.urls] +Homepage = "https://github.com/bitcoindevkit" +Repository = "https://github.com/bitcoindevkit/bdk-python" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +bdkpython = ["libbdkffi.*"] [tool.pytest.ini_options] -pythonpath = [ - "." -] \ No newline at end of file +pythonpath = ["."] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index de2e59b..4f49921 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ semantic-version==2.9.0 typing_extensions==4.0.1 setuptools==75.3.2 wheel==0.38.4 +build==1.3.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 9ba7fce..c925d6d 100644 --- a/setup.py +++ b/setup.py @@ -1,35 +1,7 @@ -#!/usr/bin/env python - from setuptools import setup -LONG_DESCRIPTION = """# bdkpython -The Python language bindings for the [Bitcoin Dev Kit](https://github.com/bitcoindevkit). - -## Install the package -```shell -pip install bdkpython -``` - -## Simple example -```python -from bdkpython import Wallet -``` -""" - setup( - name="bdkpython", - version="2.1.0.dev0", - description="The Python language bindings for the Bitcoin Development Kit", - long_description=LONG_DESCRIPTION, - long_description_content_type="text/markdown", - include_package_data = True, - zip_safe=False, - packages=["bdkpython"], - package_dir={"bdkpython": "./src/bdkpython"}, - url="https://github.com/bitcoindevkit/bdkpython", - author="Bitcoin Dev Kit Developers ", - license="MIT or Apache 2.0", # This is required to ensure the library name includes the python version, abi, and platform tags # See issue #350 for more information has_ext_modules=lambda: True, -) +) \ No newline at end of file