From eb98552c4e162b594acc8cba706217b0068c9505 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sun, 16 Nov 2025 00:52:43 +0100 Subject: [PATCH] CI build debian packages --- .github/workflows/build-deb.yml | 121 ++++++++++++++ .github/workflows/build.yml | 156 ------------------ CMakeLists.txt | 3 +- Dockerfile.jammy => Dockerfile.linux | 8 +- Dockerfile.noble | 36 ---- README.md | 68 +++----- bin/build_libmonero_python.sh | 44 +++-- debian/bookworm/changelog | 3 + debian/bookworm/compat | 1 + debian/bookworm/control | 14 ++ debian/bookworm/copyright | 6 + debian/bookworm/format | 1 + debian/bookworm/rules | 4 + debian/bullseye/changelog | 3 + debian/bullseye/compat | 1 + debian/bullseye/control | 14 ++ debian/bullseye/copyright | 6 + debian/bullseye/format | 1 + debian/bullseye/rules | 4 + debian/jammy/control | 2 +- debian/noble/control | 2 +- debian/trixie/changelog | 4 + debian/trixie/compat | 1 + debian/trixie/control | 14 ++ debian/trixie/copyright | 6 + debian/trixie/format | 1 + debian/trixie/rules | 4 + docker/build.sh | 50 +++++- setup.py | 7 +- ...monero_connection_priority_comparator.pyi} | 0 30 files changed, 316 insertions(+), 269 deletions(-) create mode 100644 .github/workflows/build-deb.yml delete mode 100644 .github/workflows/build.yml rename Dockerfile.jammy => Dockerfile.linux (92%) delete mode 100644 Dockerfile.noble create mode 100644 debian/bookworm/changelog create mode 100644 debian/bookworm/compat create mode 100644 debian/bookworm/control create mode 100644 debian/bookworm/copyright create mode 100644 debian/bookworm/format create mode 100755 debian/bookworm/rules create mode 100644 debian/bullseye/changelog create mode 100644 debian/bullseye/compat create mode 100644 debian/bullseye/control create mode 100644 debian/bullseye/copyright create mode 100644 debian/bullseye/format create mode 100755 debian/bullseye/rules create mode 100644 debian/trixie/changelog create mode 100644 debian/trixie/compat create mode 100644 debian/trixie/control create mode 100644 debian/trixie/copyright create mode 100644 debian/trixie/format create mode 100755 debian/trixie/rules rename src/python/{monero_connection_priority_comparator.py => monero_connection_priority_comparator.pyi} (100%) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml new file mode 100644 index 0000000..57a86fb --- /dev/null +++ b/.github/workflows/build-deb.yml @@ -0,0 +1,121 @@ +name: Build Debian Packages + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + build: + name: ${{ matrix.distro_name }} (${{ matrix.name }} / ${{ matrix.arch }}) + runs-on: ubuntu-latest + env: + PACKAGE_NAME: python3-monero_${{ github.run_id }}-1${{ matrix.name }}1_${{ matrix.arch }} + + strategy: + fail-fast: true + matrix: + include: + - name: noble + distro_name: ubuntu + base_image: ubuntu:24.04 + arch: amd64 + - name: noble + distro_name: ubuntu + base_image: ubuntu:24.04 + arch: arm64 + - name: noble + distro_name: ubuntu + base_image: ubuntu:24.04 + arch: armhf + - name: jammy + distro_name: ubuntu + base_image: ubuntu:22.04 + arch: amd64 + - name: jammy + distro_name: ubuntu + base_image: ubuntu:22.04 + arch: arm64 + - name: jammy + distro_name: ubuntu + base_image: ubuntu:22.04 + arch: armhf + - name: trixie + distro_name: debian + base_image: debian:trixie + arch: amd64 + - name: trixie + distro_name: debian + base_image: debian:trixie + arch: arm64 + - name: trixie + distro_name: debian + base_image: debian:trixie + arch: armhf + - name: bookworm + distro_name: debian + base_image: debian:bookworm + arch: amd64 + - name: bookworm + distro_name: debian + base_image: debian:bookworm + arch: arm64 + - name: bookworm + distro_name: debian + base_image: debian:bookworm + arch: armhf + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup qemu + if: matrix.arch == 'arm64' || matrix.arch == 'armhf' + uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 + + - name: Setup docker buildx + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 + + - name: Free up disk space + run: | + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc || true + docker system prune -af || true + + - name: Prepare build environment + run: | + PLATFORM=${{ matrix.arch == 'amd64' && 'linux/amd64' || + matrix.arch == 'armhf' && 'linux/arm/v7' || + 'linux/arm64' }} + + docker buildx build \ + --platform $PLATFORM \ + --build-arg BASE_IMAGE=${{ matrix.base_image }} \ + --build-arg THREADS=3 \ + -t monero-python:${{ matrix.name }}-${{ matrix.arch }} \ + -f Dockerfile.linux \ + --load \ + . + + - name: Build monero-python + run: | + PLATFORM=${{ matrix.arch == 'amd64' && 'linux/amd64' || + matrix.arch == 'armhf' && 'linux/arm/v7' || + 'linux/arm64' }} + PACKAGE_NAME="python3-monero_${{ github.run_id }}-1${{ matrix.name }}1_${{ matrix.arch }}" + + docker run --rm \ + --platform $PLATFORM \ + -v $PWD:/monero-python -w /monero-python \ + -e PACKAGE_NAME="${PACKAGE_NAME}" \ + monero-python:${{ matrix.name }}-${{ matrix.arch }} \ + bash -euxc "./docker/build.sh" + + - name: Upload deb package + uses: actions/upload-artifact@v4 + with: + name: python3-monero_${{ github.run_id }}-1${{ matrix.name }}1_${{ matrix.arch }} + path: build/*.deb diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index a137a21..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,156 +0,0 @@ -name: 'Build' - -on: - push: - branches: - - main - pull_request: - branches: - - main - - workflow_dispatch: - -jobs: - noble: - - runs-on: ubuntu-24.04 - env: - PACKAGE_NAME: python3-monero_${{ github.ref_name }}-1noble1_amd64 - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - sudo apt update - sudo apt install -y build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz git curl autoconf libtool gperf nettle-dev libevent-dev debhelper python3-all python3-pip python3-pybind11 python3-pytest - pip3 install pybind11-stubgen pytest --break-system-packages - - - name: Install expat - run: | - wget https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.bz2 - tar -xf expat-2.4.8.tar.bz2 - sudo rm expat-2.4.8.tar.bz2 - cd expat-2.4.8 - ./configure --enable-static --disable-shared - make - sudo make install - cd ../ - - - name: Install unbound - run: | - wget https://www.nlnetlabs.nl/downloads/unbound/unbound-1.22.0.tar.gz - tar xzf unbound-1.22.0.tar.gz - sudo apt install -y build-essential - sudo apt install -y libssl-dev - sudo apt install -y libexpat1-dev - sudo apt-get install -y bison - sudo apt-get install -y flex - cd unbound-1.22.0 - ./configure --with-libexpat=/usr --with-ssl=/usr --enable-static-exe - make - sudo make install - cd ../ - - - name: Update submodules - run: | - git submodule update --init --recursive - - - name: Build monero-cpp shared library - run: | - mkdir build - cd external/monero-cpp - ./bin/build_libmonero_cpp.sh - cp build/libmonero* ../../build - cd ../../ - - - name: Build monero-python - run: | - pip3 install . --target build/${PACKAGE_NAME}/usr/lib/python3/dist-packages - - - name: Build DEB package - run: | - cp -R src/python build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/monero - rm -rf build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/pybind11* - rm -rf build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/bin - cp -R debian/noble build/${PACKAGE_NAME}/DEBIAN - cp external/monero-cpp/build/libmonero-cpp.so build/${PACKAGE_NAME}/usr/lib/ - dpkg-deb --build build/${PACKAGE_NAME} - - - name: Upload DEB - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }}-deb - path: build/${{ env.PACKAGE_NAME }}.deb - - jammy: - - runs-on: ubuntu-22.04 - env: - PACKAGE_NAME: python3-monero_${{ github.ref_name }}-1jammy1_amd64 - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - sudo apt update - sudo apt install -y build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz git curl autoconf libtool gperf nettle-dev libevent-dev debhelper python3-all python3-pip python3-pybind11 python3-pytest - pip3 install pybind11-stubgen pytest - - - name: Install expat - run: | - wget https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.bz2 - tar -xf expat-2.4.8.tar.bz2 - sudo rm expat-2.4.8.tar.bz2 - cd expat-2.4.8 - ./configure --enable-static --disable-shared - make - sudo make install - cd ../ - - - name: Install unbound - run: | - wget https://www.nlnetlabs.nl/downloads/unbound/unbound-1.22.0.tar.gz - tar xzf unbound-1.22.0.tar.gz - sudo apt install -y build-essential - sudo apt install -y libssl-dev - sudo apt install -y libexpat1-dev - sudo apt-get install -y bison - sudo apt-get install -y flex - cd unbound-1.22.0 - ./configure --with-libexpat=/usr --with-ssl=/usr --enable-static-exe - make - sudo make install - cd ../ - - - name: Update submodules - run: | - git submodule update --init --recursive - - - name: Build monero-cpp shared library - run: | - mkdir build - cd external/monero-cpp - ./bin/build_libmonero_cpp.sh - cp build/libmonero* ../../build - cd ../../ - - - name: Build monero-python - run: | - pip3 install . --target build/${PACKAGE_NAME}/usr/lib/python3/dist-packages - - - name: Build DEB package - run: | - cp -R src/python build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/monero - rm -rf build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/pybind11* - rm -rf build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/bin - cp -R debian/jammy build/${PACKAGE_NAME}/DEBIAN - cp external/monero-cpp/build/libmonero-cpp.so build/${PACKAGE_NAME}/usr/lib/ - dpkg-deb --build build/${PACKAGE_NAME} - - - name: Upload DEB - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }}-deb - path: build/${{ env.PACKAGE_NAME }}.deb diff --git a/CMakeLists.txt b/CMakeLists.txt index e2ae297..d88cd61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,7 @@ include_directories( ) link_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/build - ${CMAKE_CURRENT_SOURCE_DIR}/lib + ${CMAKE_CURRENT_SOURCE_DIR}/external/monero-cpp/build ) pybind11_add_module(monero ${SOURCES}) diff --git a/Dockerfile.jammy b/Dockerfile.linux similarity index 92% rename from Dockerfile.jammy rename to Dockerfile.linux index 26f2fd3..12a52dd 100644 --- a/Dockerfile.jammy +++ b/Dockerfile.linux @@ -1,4 +1,6 @@ -FROM ubuntu:22.04 +ARG BASE_IMAGE=ubuntu:24.04 + +FROM ${BASE_IMAGE} ENV DEBIAN_FRONTEND=noninteractive @@ -6,7 +8,7 @@ RUN apt-get update && apt-get install -y \ build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev \ libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev \ qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev \ - libprotobuf-dev protobuf-compiler libudev-dev \ + libprotobuf-dev protobuf-compiler libudev-dev libzstd-dev \ libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev \ libboost-locale-dev libboost-program-options-dev libboost-regex-dev \ libboost-serialization-dev libboost-system-dev libboost-thread-dev \ @@ -15,8 +17,6 @@ RUN apt-get update && apt-get install -y \ debhelper bison flex wget \ && rm -rf /var/lib/apt/lists/* -RUN pip3 install pybind11-stubgen pytest - RUN wget https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.bz2 \ && tar -xf expat-2.4.8.tar.bz2 \ && cd expat-2.4.8 \ diff --git a/Dockerfile.noble b/Dockerfile.noble deleted file mode 100644 index e27e1b0..0000000 --- a/Dockerfile.noble +++ /dev/null @@ -1,36 +0,0 @@ -FROM ubuntu:24.04 - -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get update && apt-get install -y \ - build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev \ - libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev \ - qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev \ - libprotobuf-dev protobuf-compiler libudev-dev \ - libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev \ - libboost-locale-dev libboost-program-options-dev libboost-regex-dev \ - libboost-serialization-dev libboost-system-dev libboost-thread-dev \ - python3 python3-pip python3-all python3-pybind11 python3-pytest \ - ccache doxygen graphviz git curl autoconf libtool gperf nettle-dev libevent-dev \ - debhelper bison flex wget \ - && rm -rf /var/lib/apt/lists/* - -RUN pip3 install pybind11-stubgen pytest --break-system-packages - -RUN wget https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.bz2 \ - && tar -xf expat-2.4.8.tar.bz2 \ - && cd expat-2.4.8 \ - && ./configure --enable-static --disable-shared \ - && make -j$(nproc) && make install \ - && cd .. && rm -rf expat-2.4.8* - -RUN wget https://www.nlnetlabs.nl/downloads/unbound/unbound-1.22.0.tar.gz \ - && tar xzf unbound-1.22.0.tar.gz \ - && cd unbound-1.22.0 \ - && ./configure --with-libexpat=/usr --with-ssl=/usr --enable-static-exe \ - && make -j$(nproc) && make install \ - && cd .. && rm -rf unbound-1.22.0* - -RUN git config --global --add safe.directory '*' - -WORKDIR /monero-python diff --git a/README.md b/README.md index 4717c7e..df36c57 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ # Monero Python Library -[![Build](https://github.com/everoddandeven/monero-python/actions/workflows/build.yml/badge.svg)](https://github.com/everoddandeven/monero-python/actions/workflows/build.yml) +[![Build](https://github.com/everoddandeven/monero-python/actions/workflows/build-deb.yml/badge.svg)](https://github.com/everoddandeven/monero-python/actions/workflows/build-deb.yml) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/aeff91a5b1d543ddb400f88ffce150a8)](https://app.codacy.com/gh/everoddandeven/monero-python/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) -Python library for using Monero +> [!CAUTION] +> +> monero-python is without funding and needs tests to reach a stable release for production environments, expect bugs and breaking changes. +> There is a [Monero CSS proposal](https://repo.getmonero.org/monero-project/ccs-proposals/-/merge_requests/598) +> for maintenance of this library, check it out! A Python library for creating Monero applications using RPC and Python bindings to [monero v0.18.4.3 'Fluorine Fermi'](https://github.com/monero-project/monero/tree/v0.18.4.3). @@ -80,44 +85,6 @@ wallet_rpc.relay_tx(created_tx) # relay the transaction wallet_full.close(true) ``` -## Using monero-python in your project - -#### For pip: - -```bash -# still not available, waiting for legacy monero package replace on PyPI - -pip3 install monero -``` - -#### For system-wide installation: - -##### Ubuntu -```bash -# still not available on official debian/ubuntu repository - -sudo apt install -y python3-monero -``` - -##### Fedora/RedHat - -```bash -# still not available on official fedora repository - -sudo dnf install -y python3-monero -``` - -#### If using RPC servers: - -1. Download and install [Monero CLI](https://web.getmonero.org/downloads/). -2. Start monerod, e.g.: `./monerod --stagenet` (or use a remote daemon). -3. Start monero-wallet-rpc, e.g.: `./monero-wallet-rpc --daemon-address http://localhost:38081 --stagenet --rpc-bind-port 38083 --rpc-login rpc_user:abc123 --wallet-dir ./` - -> [!NOTE] -> On Windows, if you want to use native wallets instead of monero-wallet-rpc, or if you want to process binary data, first install MSYS2: -> 1. Install [MSYS2](https://www.msys2.org/). -> 2. Environment variables > System variables > Path > Edit > New > C:\msys64\mingw64\bin - ## Building monero-python from source For convenience, native libraries for Linux, macOS, and Windows are distributed with monero-python, but they can be built independently from source: @@ -166,14 +133,31 @@ For convenience, native libraries for Linux, macOS, and Windows are distributed cd monero-python docker build --tag monero-python:build-linux --build-arg THREADS=4 --file Dockerfile.linux . ``` -4. Build +4. (Optional) Specify build image + ```sh + cd monero-python + docker build --tag monero-python:build-linux --build-arg BASE_IMAGE="ubuntu:22.04" --build-arg THREADS=4 --file Dockerfile.linux . + ``` + +5. Build ```sh docker run --rm -it -v :/monero-python -w /monero-python monero-python:build-linux sh ./docker/build.sh ``` * `MONERO_PYTHON_DIR_FULL_PATH` - full path to `monero-python` directory -5. Library build will be placed in `monero-python/build` directory +6. Library build will be placed in `monero-python/build` directory + +## Use RPC servers in your project: + +1. Download and install [Monero CLI](https://web.getmonero.org/downloads/). +2. Start monerod, e.g.: `./monerod --stagenet` (or use a remote daemon). +3. Start monero-wallet-rpc, e.g.: `./monero-wallet-rpc --daemon-address http://localhost:38081 --stagenet --rpc-bind-port 38083 --rpc-login rpc_user:abc123 --wallet-dir ./` + +> [!NOTE] +> On Windows, if you want to use native wallets instead of monero-wallet-rpc, or if you want to process binary data, first install MSYS2: +> 1. Install [MSYS2](https://www.msys2.org/). +> 2. Environment variables > System variables > Path > Edit > New > C:\msys64\mingw64\bin ## Memory Growth diff --git a/bin/build_libmonero_python.sh b/bin/build_libmonero_python.sh index c287cbd..3104e6f 100755 --- a/bin/build_libmonero_python.sh +++ b/bin/build_libmonero_python.sh @@ -1,24 +1,36 @@ #!/bin/sh -#EMCC_DEBUG=1 - -# build boost library -cd ./external/boost/ && -./bootstrap.sh && -./b2 headers && -cd ../../ +# build monero-project dependencies +cd ./external/monero-cpp/external/monero-project/ || exit 1 +git submodule update --init --force || exit 1 +HOST_NCORES=$(nproc 2>/dev/null || shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) +if [[ $(uname -s) == "MINGW64_NT"* || $(uname -s) == "MSYS"* ]]; then + bit=$(getconf LONG_BIT) + if [ "$bit" == "64" ]; then + make release-static-win64 -j$HOST_NCORES || exit 1 + else + make release-static-win32 -j$HOST_NCORES || exit 1 + fi +else + # OS is not windows + mkdir -p build/release && + cd build/release && + cmake -DCMAKE_BUILD_TYPE=Release ../../ + make -j$HOST_NCORES wallet cryptonote_protocol || exit 1 +fi +cd ../../../../ # build libmonero-cpp shared library -cd ./external/monero-cpp/ && -./bin/build_libmonero_cpp.sh && - -# copy libmonero-cpp shared library to ./build -cd ../../ && -mkdir -p ./build && -cp ./external/monero-cpp/build/libmonero-cpp.* ./build && - -# build monero-python mkdir -p build && cd build && cmake .. && +cmake --build . && make . +cd ../../../ + +# build libmonero-python shared library +mkdir -p build && +cd build && +cmake .. +make -j$HOST_NCORES + diff --git a/debian/bookworm/changelog b/debian/bookworm/changelog new file mode 100644 index 0000000..d7b08ca --- /dev/null +++ b/debian/bookworm/changelog @@ -0,0 +1,3 @@ +python3-monero (0.0.1-1) main; urgency=medium + + -- everoddandeven diff --git a/debian/bookworm/compat b/debian/bookworm/compat new file mode 100644 index 0000000..b4de394 --- /dev/null +++ b/debian/bookworm/compat @@ -0,0 +1 @@ +11 diff --git a/debian/bookworm/control b/debian/bookworm/control new file mode 100644 index 0000000..cc48eff --- /dev/null +++ b/debian/bookworm/control @@ -0,0 +1,14 @@ +Source: python3-monero +Section: python +Priority: optional +Maintainer: everoddandeven +Build-Depends: build-essential, cmake, pkg-config, debhelper, python3-all, libssl-dev, libzmq3-dev, libunbound-dev, libsodium-dev, libunwind8-dev, liblzma-dev, libreadline6-dev, libexpat1-dev, libpgm-dev, qttools5-dev-tools, libhidapi-dev, libusb-1.0-0-dev, libprotobuf-dev, protobuf-compiler, libudev-dev, libboost-chrono-dev, libboost-date-time-dev, libboost-filesystem-dev, libboost-locale-dev, libboost-program-options-dev, libboost-regex-dev libboost-serialization-dev, libboost-system-dev, libboost-thread-dev, python3, ccache, doxygen, graphviz, nettle-dev, libevent-dev, python3-pip, python3-pybind11, python3-pytest, pybind11-dev +Depends: libunbound8, libprotobuf23, libboost-chrono1.74.0, libboost-filesystem1.74.0, libboost-program-options1.74.0, libboost-regex1.74.0, libboost-serialization1.74.0, libboost-thread1.74.0, libhidapi-libusb0 +Standards-Version: 4.5.0 +Homepage: https://github.com/everoddandeven/monero-python +Rules-Requires-Root: no +Package: python3-monero +Architecture: any +Description: Python bindings for monero-cpp + This package provides Python 3 bindings for the monero-cpp library using pybind11. +Version: 0.0.1 diff --git a/debian/bookworm/copyright b/debian/bookworm/copyright new file mode 100644 index 0000000..1398915 --- /dev/null +++ b/debian/bookworm/copyright @@ -0,0 +1,6 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: monero-python +Source: https://github.com/everoddandeven/monero-python +Files: * +Copyright: 2025 everoddandeven +License: MIT diff --git a/debian/bookworm/format b/debian/bookworm/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/bookworm/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/bookworm/rules b/debian/bookworm/rules new file mode 100755 index 0000000..050e29a --- /dev/null +++ b/debian/bookworm/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ --buildsystem=cmake diff --git a/debian/bullseye/changelog b/debian/bullseye/changelog new file mode 100644 index 0000000..d7b08ca --- /dev/null +++ b/debian/bullseye/changelog @@ -0,0 +1,3 @@ +python3-monero (0.0.1-1) main; urgency=medium + + -- everoddandeven diff --git a/debian/bullseye/compat b/debian/bullseye/compat new file mode 100644 index 0000000..b4de394 --- /dev/null +++ b/debian/bullseye/compat @@ -0,0 +1 @@ +11 diff --git a/debian/bullseye/control b/debian/bullseye/control new file mode 100644 index 0000000..cc48eff --- /dev/null +++ b/debian/bullseye/control @@ -0,0 +1,14 @@ +Source: python3-monero +Section: python +Priority: optional +Maintainer: everoddandeven +Build-Depends: build-essential, cmake, pkg-config, debhelper, python3-all, libssl-dev, libzmq3-dev, libunbound-dev, libsodium-dev, libunwind8-dev, liblzma-dev, libreadline6-dev, libexpat1-dev, libpgm-dev, qttools5-dev-tools, libhidapi-dev, libusb-1.0-0-dev, libprotobuf-dev, protobuf-compiler, libudev-dev, libboost-chrono-dev, libboost-date-time-dev, libboost-filesystem-dev, libboost-locale-dev, libboost-program-options-dev, libboost-regex-dev libboost-serialization-dev, libboost-system-dev, libboost-thread-dev, python3, ccache, doxygen, graphviz, nettle-dev, libevent-dev, python3-pip, python3-pybind11, python3-pytest, pybind11-dev +Depends: libunbound8, libprotobuf23, libboost-chrono1.74.0, libboost-filesystem1.74.0, libboost-program-options1.74.0, libboost-regex1.74.0, libboost-serialization1.74.0, libboost-thread1.74.0, libhidapi-libusb0 +Standards-Version: 4.5.0 +Homepage: https://github.com/everoddandeven/monero-python +Rules-Requires-Root: no +Package: python3-monero +Architecture: any +Description: Python bindings for monero-cpp + This package provides Python 3 bindings for the monero-cpp library using pybind11. +Version: 0.0.1 diff --git a/debian/bullseye/copyright b/debian/bullseye/copyright new file mode 100644 index 0000000..1398915 --- /dev/null +++ b/debian/bullseye/copyright @@ -0,0 +1,6 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: monero-python +Source: https://github.com/everoddandeven/monero-python +Files: * +Copyright: 2025 everoddandeven +License: MIT diff --git a/debian/bullseye/format b/debian/bullseye/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/bullseye/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/bullseye/rules b/debian/bullseye/rules new file mode 100755 index 0000000..050e29a --- /dev/null +++ b/debian/bullseye/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ --buildsystem=cmake diff --git a/debian/jammy/control b/debian/jammy/control index 3e72931..cc48eff 100644 --- a/debian/jammy/control +++ b/debian/jammy/control @@ -8,7 +8,7 @@ Standards-Version: 4.5.0 Homepage: https://github.com/everoddandeven/monero-python Rules-Requires-Root: no Package: python3-monero -Architecture: amd64 +Architecture: any Description: Python bindings for monero-cpp This package provides Python 3 bindings for the monero-cpp library using pybind11. Version: 0.0.1 diff --git a/debian/noble/control b/debian/noble/control index 262ff2b..5b047dc 100644 --- a/debian/noble/control +++ b/debian/noble/control @@ -8,7 +8,7 @@ Standards-Version: 4.5.0 Homepage: https://github.com/everoddandeven/monero-python Rules-Requires-Root: no Package: python3-monero -Architecture: amd64 +Architecture: any Description: Python bindings for monero-cpp This package provides Python 3 bindings for the monero-cpp library using pybind11. Version: 0.0.1 diff --git a/debian/trixie/changelog b/debian/trixie/changelog new file mode 100644 index 0000000..dca30e8 --- /dev/null +++ b/debian/trixie/changelog @@ -0,0 +1,4 @@ +python3-monero (0.0.1-1) main; urgency=medium + + -- everoddandeven + diff --git a/debian/trixie/compat b/debian/trixie/compat new file mode 100644 index 0000000..b4de394 --- /dev/null +++ b/debian/trixie/compat @@ -0,0 +1 @@ +11 diff --git a/debian/trixie/control b/debian/trixie/control new file mode 100644 index 0000000..5b047dc --- /dev/null +++ b/debian/trixie/control @@ -0,0 +1,14 @@ +Source: python3-monero +Section: python +Priority: optional +Maintainer: everoddandeven +Build-Depends: build-essential, cmake, pkg-config, debhelper, python3-all, libssl-dev, libzmq3-dev, libunbound-dev, libsodium-dev, libunwind8-dev, liblzma-dev, libreadline6-dev, libexpat1-dev, libpgm-dev, qttools5-dev-tools, libhidapi-dev, libusb-1.0-0-dev, libprotobuf-dev, protobuf-compiler, libudev-dev, libboost-chrono-dev, libboost-date-time-dev, libboost-filesystem-dev, libboost-locale-dev, libboost-program-options-dev, libboost-regex-dev libboost-serialization-dev, libboost-system-dev, libboost-thread-dev, python3, ccache, doxygen, graphviz, nettle-dev, libevent-dev, python3-pip, python3-pybind11, python3-pytest, pybind11-dev +Depends: libunbound8, libprotobuf32t64, libboost-chrono1.83.0, libboost-filesystem1.83.0, libboost-program-options1.83.0, libboost-regex1.83.0, libboost-serialization1.83.0, libboost-thread1.83.0, libhidapi-libusb0 +Standards-Version: 4.5.0 +Homepage: https://github.com/everoddandeven/monero-python +Rules-Requires-Root: no +Package: python3-monero +Architecture: any +Description: Python bindings for monero-cpp + This package provides Python 3 bindings for the monero-cpp library using pybind11. +Version: 0.0.1 diff --git a/debian/trixie/copyright b/debian/trixie/copyright new file mode 100644 index 0000000..1398915 --- /dev/null +++ b/debian/trixie/copyright @@ -0,0 +1,6 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: monero-python +Source: https://github.com/everoddandeven/monero-python +Files: * +Copyright: 2025 everoddandeven +License: MIT diff --git a/debian/trixie/format b/debian/trixie/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/trixie/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/trixie/rules b/debian/trixie/rules new file mode 100755 index 0000000..050e29a --- /dev/null +++ b/debian/trixie/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ --buildsystem=cmake diff --git a/docker/build.sh b/docker/build.sh index 4e683dd..f44ac21 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -2,27 +2,63 @@ set -e DISTRO_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d'=' -f2) +DEFAULT_VERSION="0.0.1" if [ -z "$DISTRO_CODENAME" ]; then DISTRO_CODENAME=$(lsb_release -c -s 2>/dev/null || echo "unknown") fi -PACKAGE_NAME=${PACKAGE_NAME:-python3-monero_main-1${DISTRO_CODENAME}1_amd64} +ARCH=$(dpkg --print-architecture 2>/dev/null || uname -m) +if [ "$ARCH" == "x86_64" ]; then + ARCH="amd64" +elif [[ "$ARCH" == arm64* || "$ARCH" == aarch64* ]]; then + ARCH="arm64" +fi + +PACKAGE_NAME=${PACKAGE_NAME:-python3-monero_${DEFAULT_VERSION}-1${DISTRO_CODENAME}1_${ARCH}} + +echo "Building package: ${PACKAGE_NAME}" +echo "Distro codename: ${DISTRO_CODENAME}" +echo "Architecture: ${ARCH}" git submodule update --init --recursive mkdir -p build -cd ./external/monero-cpp -./bin/build_libmonero_cpp.sh -cp build/libmonero* ../../build -cd ../../ + +# build monero-project dependencies +cd ./external/monero-cpp/external/monero-project/ +git submodule update --init --force +HOST_NCORES=$(nproc 2>/dev/null || shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) +if [[ $(uname -s) == "MINGW64_NT"* || $(uname -s) == "MSYS"* ]]; then + bit=$(getconf LONG_BIT) + if [ "$bit" == "64" ]; then + make release-static-win64 -j$HOST_NCORES + else + make release-static-win32 -j$HOST_NCORES + fi +else + # OS is not windows + mkdir -p build/release && + cd build/release && + cmake -DSTATIC=ON -DBUILD_64=ON -DCMAKE_BUILD_TYPE=Release ../../ + make -j$HOST_NCORES wallet cryptonote_protocol +fi +cd ../../../../ + +# build libmonero-cpp shared library +mkdir -p build && +cd build && +cmake .. && +cmake --build . && +make . +cd ../../../ pip3 install . --target build/${PACKAGE_NAME}/usr/lib/python3/dist-packages cp -R src/python build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/monero rm -rf build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/pybind11* rm -rf build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/bin -cp -R debian build/${PACKAGE_NAME}/DEBIAN +cp -R "debian/${DISTRO_CODENAME}" "build/${PACKAGE_NAME}/DEBIAN" cp external/monero-cpp/build/libmonero-cpp.so build/${PACKAGE_NAME}/usr/lib/ dpkg-deb --build build/${PACKAGE_NAME} -echo "Package built: build/${PACKAGE_NAME}.deb" +echo "Package built successfully: build/${PACKAGE_NAME}.deb" diff --git a/setup.py b/setup.py index 3cd5583..9608fb7 100644 --- a/setup.py +++ b/setup.py @@ -27,8 +27,7 @@ str(this_dir / 'src' / 'cpp' / 'wallet') ], library_dirs=[ - str(this_dir / 'build'), - str(this_dir / 'lib') + str(this_dir / 'external' / 'monero-cpp' / 'build') ], libraries=['monero-cpp'], language='c++', @@ -47,8 +46,8 @@ url='https://github.com/everoddandeven/monero-python', download_url="https://github.com/everoddandeven/monero-python/releases", description='A Python library for using Monero.', - long_description='A library for using monero-cpp through python bindings.', - keywords=["monero", "monero-python", "python"], + long_description='Python bindings for monero-cpp.', + keywords=["monero", "monero-python", "python", "bindings", "pybind11"], ext_modules=ext_modules, install_requires=['pybind11>=2.12.0'], cmdclass={"build_ext": build_ext} diff --git a/src/python/monero_connection_priority_comparator.py b/src/python/monero_connection_priority_comparator.pyi similarity index 100% rename from src/python/monero_connection_priority_comparator.py rename to src/python/monero_connection_priority_comparator.pyi