Skip to content

Commit

Permalink
tapo-py: Add action to publish to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-dinculescu committed Sep 30, 2023
1 parent 67cf844 commit 65aee2a
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 4 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/py-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# This file is autogenerated by maturin v1.1.0
# To update, run
#
# maturin generate-ci github
#
name: Python

on:
push:
branches:
- main
tags:
- "*"
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path ./tapo-py/Cargo.toml --features openssl-vendored
before-script-linux: |
# If we're running on rhel centos, install needed packages.
if command -v yum &> /dev/null; then
yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic
# If we're running on i686 we need to symlink libatomic
# in order to build openssl with -latomic flag.
if [[ ! -d "/usr/lib64" ]]; then
ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so
fi
else
# If we're running on debian-based system.
apt update -y && apt-get install -y libssl-dev openssl pkg-config
fi
sccache: "true"
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path ./tapo-py/Cargo.toml --features openssl-vendored
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path ./tapo-py/Cargo.toml --features openssl-vendored
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path ./tapo-py/Cargo.toml
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing *
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml → .github/workflows/rs-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Rust

on:
push:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Crates.io
name: Rust publish
on:
release:
types:
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tapo-py-test/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "tapo-py-test"
version = "0.1.0"
description = ""
authors = ["Mihai Dinculescu <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
tapo = { path = "../tapo-py", develop = true }
plugp100 = "^3.10.3"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
6 changes: 5 additions & 1 deletion tapo-py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ name = "tapo"
crate-type = ["cdylib"]
doc = false

[features]
default = []
openssl-vendored = ["tapo/openssl-vendored"]

[dependencies]
chrono = { workspace = true, default-features = false }
pyo3 = { workspace = true, features = ["chrono"] }
pyo3 = { workspace = true, features = ["chrono", "extension-module"] }
pyo3-asyncio = { workspace = true, features = ["attributes", "tokio-runtime"] }
tapo = { path = "../tapo", features = ["python"] }
tokio = { workspace = true, default-features = false, features = ["sync"] }
2 changes: 1 addition & 1 deletion tapo-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ build-backend = "maturin"
[tool.maturin]
bindings = 'pyo3'
features = ["pyo3/extension-module"]
sdist-include = ["*.so", "LICENSE"]
sdist-include = ["LICENSE", "README.md"]
1 change: 1 addition & 0 deletions tapo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repository = "https://github.com/mihai-dinculescu/tapo"
[features]
default = []
python = ["dep:pyo3"]
openssl-vendored = ["openssl/vendored"]

[dependencies]
anyhow = "1.0"
Expand Down

0 comments on commit 65aee2a

Please sign in to comment.