From cbba91248379678d2ceb2e7f62d4183155ab39ab Mon Sep 17 00:00:00 2001 From: cocool97 <34218602+cocool97@users.noreply.github.com> Date: Fri, 24 Jan 2025 15:00:36 +0100 Subject: [PATCH] fix: improve python package build (#85) --- .github/workflows/python-build.yml | 18 ++++++------------ pyadb_client/Cargo.toml | 2 +- pyadb_client/README.md | 18 +++++++++++++----- pyadb_client/pyproject.toml | 13 ------------- pyproject.toml | 16 ++++++++++++++++ 5 files changed, 36 insertions(+), 31 deletions(-) delete mode 100644 pyadb_client/pyproject.toml create mode 100644 pyproject.toml diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index f061024..c598897 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -9,35 +9,29 @@ on: jobs: build-python-packages: runs-on: ubuntu-latest - defaults: - run: - working-directory: pyadb_client steps: - uses: actions/checkout@v4 - - name: Install Python dependencies - run: pip install . + - name: Install Python build dependencies + run: pip install ".[build]" - name: Build Python packages - run: maturin build --release --interpreter "3.8" --interpreter "3.9" --interpreter "3.10" --interpreter "3.11" --interpreter "3.12" --interpreter "3.13" + run: maturin build --release --compatibility manylinux_2_25 --auditwheel=skip publish-python-packages: runs-on: ubuntu-latest - defaults: - run: - working-directory: pyadb_client needs: [build-python-packages] if: github.event_name == 'release' && github.event.action == 'created' steps: - uses: actions/checkout@v4 - - name: Install Python dependencies - run: pip install . + - name: Install Python build dependencies + run: pip install ".[build]" - name: Publish Python packages - run: maturin publish --non-interactive + run: maturin publish --non-interactive --compatibility manylinux_2_25 --auditwheel=skip env: MATURIN_PYPI_TOKEN: ${{ secrets.MATURIN_PYPI_TOKEN }} diff --git a/pyadb_client/Cargo.toml b/pyadb_client/Cargo.toml index 1f5fbdf..eb94360 100644 --- a/pyadb_client/Cargo.toml +++ b/pyadb_client/Cargo.toml @@ -17,4 +17,4 @@ crate-type = ["cdylib"] [dependencies] anyhow = { version = "1.0.94" } adb_client = { version = "2.0.6" } -pyo3 = { version = "0.23.3", features = ["extension-module", "anyhow"] } +pyo3 = { version = "0.23.4", features = ["extension-module", "anyhow", "abi3-py37"] } diff --git a/pyadb_client/README.md b/pyadb_client/README.md index 2a31265..bbadd06 100644 --- a/pyadb_client/README.md +++ b/pyadb_client/README.md @@ -2,11 +2,19 @@ Python library to communicate with ADB devices. Built on top of Rust `adb_client` library. +## Installation + +```bash +pip install pyadb_client +``` + ## Examples ### Use ADB server ```python +from pyadb_client import pyadb_client + server = pyadb_client.PyADBServer("127.0.0.1:5037") for i, device in enumerate(server.devices()): print(i, device.identifier, device.state) @@ -19,6 +27,8 @@ print(device, device.identifier) ### Push a file on device ```python +from pyadb_client import pyadb_client + usb_device = PyADBUSBDevice.autodetect() usb_device.push("file.txt", "/data/local/tmp/file.txt") ``` @@ -31,14 +41,12 @@ cd pyadb_client python3 -m venv .venv source .venv/bin/activate -# Install needed dependencies -pip install -e . +# Install needed build dependencies +pip install ".[build]" # Build development package maturin develop # Build release Python package maturin build --release - -# Publish Python package -``` \ No newline at end of file +``` diff --git a/pyadb_client/pyproject.toml b/pyadb_client/pyproject.toml deleted file mode 100644 index 1900fb6..0000000 --- a/pyadb_client/pyproject.toml +++ /dev/null @@ -1,13 +0,0 @@ -[build-system] -requires = ["maturin>=1,<2"] -build-backend = "maturin" - -[project] -name = "pyadb_client" -dependencies = ["maturin", "patchelf"] -dynamic = ["version"] # Let the build system automatically set package version -classifiers = [ - "Programming Language :: Rust", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", -] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0af9ceb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[build-system] +build-backend = "maturin" +requires = ["maturin>=1,<2"] + +[project] +classifiers = ["Programming Language :: Python", "Programming Language :: Rust"] +dynamic = ["authors", "keywords", "version"] +name = "pyadb_client" +requires-python = ">= 3.7" + +[project.optional-dependencies] +build = ["maturin", "patchelf"] + +[tool.maturin] +include = [{ path = "adb_client/**/*", format = "sdist" }] +manifest-path = "pyadb_client/Cargo.toml"