mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 03:33:35 +00:00
Add optional kasa-crypt dependency for speedups (#464)
If installed, use the optimized protocol encryption procedures implemented as a C extension by kasa-crypt (https://pypi.org/project/kasa-crypt/
This commit is contained in:
parent
2d42ca301f
commit
afd54d11d3
28
.github/workflows/ci.yml
vendored
28
.github/workflows/ci.yml
vendored
@ -58,7 +58,7 @@ jobs:
|
|||||||
poetry run pre-commit run check-ast --all-files
|
poetry run pre-commit run check-ast --all-files
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
name: "Python ${{ matrix.python-version}} on ${{ matrix.os }}"
|
name: Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }}
|
||||||
needs: linting
|
needs: linting
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
@ -66,6 +66,24 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy-3.8"]
|
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy-3.8"]
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
extras: [false, true]
|
||||||
|
exclude:
|
||||||
|
- os: macos-latest
|
||||||
|
extras: true
|
||||||
|
- os: windows-latest
|
||||||
|
extras: true
|
||||||
|
- os: ubuntu-latest
|
||||||
|
python-version: "pypy-3.8"
|
||||||
|
extras: true
|
||||||
|
- os: ubuntu-latest
|
||||||
|
python-version: "3.8"
|
||||||
|
extras: true
|
||||||
|
- os: ubuntu-latest
|
||||||
|
python-version: "3.9"
|
||||||
|
extras: true
|
||||||
|
- os: ubuntu-latest
|
||||||
|
python-version: "3.10"
|
||||||
|
extras: true
|
||||||
# exclude pypy on windows, as the poetry install seems to be very flaky:
|
# exclude pypy on windows, as the poetry install seems to be very flaky:
|
||||||
# PermissionError(13, 'The process cannot access the file because it is being used by another process'))
|
# PermissionError(13, 'The process cannot access the file because it is being used by another process'))
|
||||||
# at C:\hostedtoolcache\windows\PyPy\3.7.10\x86\site-packages\requests\models.py:761 in generate
|
# at C:\hostedtoolcache\windows\PyPy\3.7.10\x86\site-packages\requests\models.py:761 in generate
|
||||||
@ -78,10 +96,16 @@ jobs:
|
|||||||
- uses: "actions/setup-python@v2"
|
- uses: "actions/setup-python@v2"
|
||||||
with:
|
with:
|
||||||
python-version: "${{ matrix.python-version }}"
|
python-version: "${{ matrix.python-version }}"
|
||||||
- name: "Install dependencies"
|
- name: "Install dependencies (no speedups)"
|
||||||
|
if: matrix.extras == false
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip poetry
|
python -m pip install --upgrade pip poetry
|
||||||
poetry install
|
poetry install
|
||||||
|
- name: "Install dependencies (with speedups)"
|
||||||
|
if: matrix.extras == true
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip poetry
|
||||||
|
poetry install --extras speedups
|
||||||
- name: "Run tests"
|
- name: "Run tests"
|
||||||
run: |
|
run: |
|
||||||
poetry run pytest --cov kasa --cov-report xml
|
poetry run pytest --cov kasa --cov-report xml
|
||||||
|
@ -219,3 +219,13 @@ class TPLinkSmartHomeProtocol:
|
|||||||
return bytes(
|
return bytes(
|
||||||
TPLinkSmartHomeProtocol._xor_encrypted_payload(ciphertext)
|
TPLinkSmartHomeProtocol._xor_encrypted_payload(ciphertext)
|
||||||
).decode()
|
).decode()
|
||||||
|
|
||||||
|
|
||||||
|
# Try to load the kasa_crypt module and if it is available
|
||||||
|
try:
|
||||||
|
from kasa_crypt import decrypt, encrypt
|
||||||
|
|
||||||
|
TPLinkSmartHomeProtocol.decrypt = decrypt # type: ignore[method-assign]
|
||||||
|
TPLinkSmartHomeProtocol.encrypt = encrypt # type: ignore[method-assign]
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
15
poetry.lock
generated
15
poetry.lock
generated
@ -445,6 +445,18 @@ MarkupSafe = ">=2.0"
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
i18n = ["Babel (>=2.7)"]
|
i18n = ["Babel (>=2.7)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kasa-crypt"
|
||||||
|
version = "0.2.0"
|
||||||
|
description = "Fast kasa crypt"
|
||||||
|
category = "main"
|
||||||
|
optional = true
|
||||||
|
python-versions = ">=3.7,<4.0"
|
||||||
|
files = [
|
||||||
|
{file = "kasa_crypt-0.2.0-cp310-cp310-manylinux_2_31_x86_64.whl", hash = "sha256:9676ac702aa62252fb4de3d5c9ee4895dd93610b9c37e732213b0914fbc0e255"},
|
||||||
|
{file = "kasa_crypt-0.2.0.tar.gz", hash = "sha256:ad2e73276f09ed035d53006985b08eb78869f73e60ac5d66547d9ddc35cb8cc4"},
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "markdown-it-py"
|
name = "markdown-it-py"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
@ -1387,8 +1399,9 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more
|
|||||||
|
|
||||||
[extras]
|
[extras]
|
||||||
docs = ["sphinx", "sphinx_rtd_theme", "sphinxcontrib-programoutput", "myst-parser", "docutils"]
|
docs = ["sphinx", "sphinx_rtd_theme", "sphinxcontrib-programoutput", "myst-parser", "docutils"]
|
||||||
|
speedups = ["orjson", "kasa-crypt"]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.8"
|
python-versions = "^3.8"
|
||||||
content-hash = "ea746265dddc60d13ef0edb476d02181631519af39fa90574e60f8eabe35bbe0"
|
content-hash = "b85f55f0ca928b1f3510da37196c21f40eb07cd4d07b3a9c3dd29215ba9777fe"
|
||||||
|
@ -25,7 +25,8 @@ asyncclick = ">=8"
|
|||||||
pydantic = "^1"
|
pydantic = "^1"
|
||||||
|
|
||||||
# speed ups
|
# speed ups
|
||||||
orjson = { "version" = ">=3.9.1", optional = true, extras = ["speedups"] }
|
orjson = { "version" = ">=3.9.1", optional = true }
|
||||||
|
kasa-crypt = { "version" = ">=0.2.0", optional = true }
|
||||||
|
|
||||||
# required only for docs
|
# required only for docs
|
||||||
sphinx = { version = "^4", optional = true }
|
sphinx = { version = "^4", optional = true }
|
||||||
@ -50,6 +51,7 @@ coverage = {version = "*", extras = ["toml"]}
|
|||||||
|
|
||||||
[tool.poetry.extras]
|
[tool.poetry.extras]
|
||||||
docs = ["sphinx", "sphinx_rtd_theme", "sphinxcontrib-programoutput", "myst-parser", "docutils"]
|
docs = ["sphinx", "sphinx_rtd_theme", "sphinxcontrib-programoutput", "myst-parser", "docutils"]
|
||||||
|
speedups = ["orjson", "kasa-crypt"]
|
||||||
|
|
||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
|
Loading…
Reference in New Issue
Block a user