main: add wheel build

* rearrange folder structure
* ci tests for wheel and module call
pip-support
argrento 2023-06-08 14:15:26 +02:00
rodzic 4c555ee971
commit 2cc2f4f848
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: AF1F4775B5A95299
9 zmienionych plików z 117 dodań i 13 usunięć

3
.gitignore vendored
Wyświetl plik

@ -7,4 +7,5 @@ __pycache__
*.fw
*.bin
venv
.mypy_cache
.mypy_cache
dist

Wyświetl plik

@ -9,7 +9,7 @@ pipeline:
- python -m pip install pylint flake8 mypy>=0.971
- python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- mypy --strict ./
- python -m pylint -f parseable ./*.py
- python -m pylint -f parseable huami_token/*.py
unit_tests:
image: python:${TAG}-buster
@ -24,9 +24,50 @@ pipeline:
- pytest tests/
secrets: [ amazfit_email, amazfit_password ]
wheel_build:
image: python:${TAG}-buster
commands:
- python -m pip install --upgrade pip build wheel
- python -m pip install -r requirements.txt
- python -m build
wheel_test:
image: python:${TAG}-buster
commands:
- python -m pip install --upgrade pip
- python -m pip install dist/*.whl
- python -m pip install pytest
- pytest tests/test_amazfit.py
- python -m huami_token -m amazfit -e $AMAZFIT_EMAIL -p $AMAZFIT_PASSWORD -b >/dev/null 2>&1
secrets: [ amazfit_email, amazfit_password ]
publish_release:
image: woodpeckerci/plugin-gitea-release
settings:
api_key:
from_secret: api_token
base_url: https://codeberg.org
files:
- "dist/*"
target: master
checksum: md5
when:
event: tag
secrets: [ api_token ]
upload_to_index:
image: python:3.8-buster
commands:
- python -m pip install twine
- python -m twine check dist/*
- python -m twine upload dist/*
when:
event: tag
secrets: [ twine_username, twine_password ]
matrix:
TAG:
- 3.8
- 3.9
- 3.10
- 3.11
# - 3.9
# - 3.10
# - 3.11

Wyświetl plik

@ -29,9 +29,8 @@ because only this login methods are supported. If not, create new Amazfit accoun
with e-mail and password.
2. Pair, sync and update your watch with Amazfit App. Your pairing key will be stored on
Huami servers.
3. Clone this repo:
```git clone https://codeberg.org/argrento/huami-token.git```
4. Install requirements: `pip3 install -r requirements.txt`
3. `pip3 install huami_token`
4. Use like this: `python3 -m huami_token ...`
## Usage
```

Wyświetl plik

@ -0,0 +1,17 @@
"""
The huami_token module provides functionalities to retrieve the Bluetooth
access token for the watch or band from Huami servers and also to download the
AGPS data packs, cep_alm_pak.zip and cep_7days.zip.
This module consists of the following main components:
- HuamiAmazfit: A class that encapsulates all the operations related to
token retrieval and AGPS data downloading.
- ERRORS: A dictionary mapping error codes to their descriptions.
- URLS, PAYLOADS: Constants used for making requests to Huami servers.
"""
from .huami_token import HuamiAmazfit
from .errors import ERRORS
from .urls import URLS, PAYLOADS
__all__ = ["HuamiAmazfit", "ERRORS", "URLS", "PAYLOADS"]

Wyświetl plik

@ -0,0 +1,8 @@
"""
Entry point when using huami_token as a module
"""
from .huami_token import main
if __name__ == "__main__":
main()

Wyświetl plik

@ -1,6 +1,7 @@
#!/usr/bin/env python3
# pylint: disable=too-many-instance-attributes
# pylint: disable=invalid-name
# pylint: disable=too-many-instance-attributes, too-many-branches
# pylint: disable=invalid-name, too-many-statements, too-many-locals
# pylint: disable=too-many-nested-blocks
# Copyright (c) 2020 Kirill Snezhko
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@ -31,8 +32,7 @@ import zlib
import requests
import errors
import urls
from . import errors, urls
def encode_uint32(value: int) -> bytes:
"""Convert 4-bytes value into a list with 4 bytes"""
@ -295,7 +295,8 @@ class HuamiAmazfit:
return result
if __name__ == "__main__":
def main() -> None:
""" Main Entry Point """
parser = argparse.ArgumentParser(description="Obtain Bluetooth Auth key from Amazfit "
"servers and download AGPS data.")
parser.add_argument("-m",
@ -417,3 +418,7 @@ if __name__ == "__main__":
print("\nLogged out.")
else:
print("\nError logging out.")
if __name__ == "__main__":
main()

33
pyproject.toml 100644
Wyświetl plik

@ -0,0 +1,33 @@
[build-system]
requires = ["flit_core>=3.4"]
build-backend = "flit_core.buildapi"
[project]
name = "huami_token"
version = "0.7"
authors = [
{ name="Kirill Snezhko", email="kirill.snezhko@pm.me" },
]
description = "This script retrieves the Bluetooth access token for the watch or band from Huami servers. Additionally, it downloads the AGPS data packs, cep_alm_pak.zip and cep_7days.zip."
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"requests == 2.25.1",
"types-requests == 2.25.1"
]
[project.urls]
"Homepage" = "https://codeberg.org/argrento/huami-token"
"Bug Tracker" = "https://codeberg.org/argrento/huami-token/issues"
[project.scripts]
huami_token = "huami_token:main"
[project.optional-dependencies]
test = ["pytest-pylint==0.18.0", "pytest-flake8==1.0.6"]