Skip to content

Commit

Permalink
fix: improve python package build (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
cocool97 authored Jan 24, 2025
1 parent 38d8384 commit cbba912
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 31 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion pyadb_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
18 changes: 13 additions & 5 deletions pyadb_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
```
Expand All @@ -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
```
```
13 changes: 0 additions & 13 deletions pyadb_client/pyproject.toml

This file was deleted.

16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit cbba912

Please sign in to comment.