2018-12-13 21:34:57 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""aioesphomeapi setup script."""
|
2024-08-29 23:15:25 +02:00
|
|
|
|
2023-10-12 20:12:39 +02:00
|
|
|
from distutils.command.build_ext import build_ext
|
2024-08-29 23:15:25 +02:00
|
|
|
import os
|
2023-10-12 20:12:39 +02:00
|
|
|
|
2023-11-11 20:06:27 +01:00
|
|
|
from setuptools import find_packages, setup
|
2018-12-13 21:34:57 +01:00
|
|
|
|
2020-06-19 21:42:32 +02:00
|
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
2021-07-27 01:34:47 +02:00
|
|
|
with open(os.path.join(here, "README.rst"), encoding="utf-8") as readme_file:
|
2020-06-19 21:42:32 +02:00
|
|
|
long_description = readme_file.read()
|
|
|
|
|
|
|
|
|
2024-09-18 01:52:18 +02:00
|
|
|
VERSION = "27.0.1"
|
2021-07-27 01:34:47 +02:00
|
|
|
PROJECT_NAME = "aioesphomeapi"
|
|
|
|
PROJECT_PACKAGE_NAME = "aioesphomeapi"
|
|
|
|
PROJECT_LICENSE = "MIT"
|
|
|
|
PROJECT_AUTHOR = "Otto Winter"
|
|
|
|
PROJECT_COPYRIGHT = " 2019-2020, Otto Winter"
|
|
|
|
PROJECT_URL = "https://esphome.io/"
|
|
|
|
PROJECT_EMAIL = "esphome@nabucasa.com"
|
2018-12-13 21:34:57 +01:00
|
|
|
|
2021-07-27 01:34:47 +02:00
|
|
|
PROJECT_GITHUB_USERNAME = "esphome"
|
|
|
|
PROJECT_GITHUB_REPOSITORY = "aioesphomeapi"
|
2018-12-13 21:34:57 +01:00
|
|
|
|
2023-11-26 15:09:52 +01:00
|
|
|
PYPI_URL = f"https://pypi.python.org/pypi/{PROJECT_PACKAGE_NAME}"
|
|
|
|
GITHUB_PATH = f"{PROJECT_GITHUB_USERNAME}/{PROJECT_GITHUB_REPOSITORY}"
|
|
|
|
GITHUB_URL = f"https://github.com/{GITHUB_PATH}"
|
2018-12-13 21:34:57 +01:00
|
|
|
|
2023-11-26 15:09:52 +01:00
|
|
|
DOWNLOAD_URL = f"{GITHUB_URL}/archive/{VERSION}.zip"
|
2018-12-13 21:34:57 +01:00
|
|
|
|
2023-10-18 06:56:30 +02:00
|
|
|
MODULES_TO_CYTHONIZE = [
|
2023-11-23 18:46:52 +01:00
|
|
|
"aioesphomeapi/client_callbacks.py",
|
2023-10-18 06:56:30 +02:00
|
|
|
"aioesphomeapi/connection.py",
|
|
|
|
"aioesphomeapi/_frame_helper/plain_text.py",
|
|
|
|
"aioesphomeapi/_frame_helper/noise.py",
|
|
|
|
"aioesphomeapi/_frame_helper/base.py",
|
|
|
|
]
|
|
|
|
|
2021-07-27 01:34:47 +02:00
|
|
|
with open(os.path.join(here, "requirements.txt")) as requirements_txt:
|
2020-07-15 13:41:55 +02:00
|
|
|
REQUIRES = requirements_txt.read().splitlines()
|
2018-12-13 21:34:57 +01:00
|
|
|
|
2023-10-18 06:56:30 +02:00
|
|
|
pkgs = find_packages(exclude=["tests", "tests.*"])
|
2023-10-12 20:12:39 +02:00
|
|
|
|
|
|
|
setup_kwargs = {
|
|
|
|
"name": PROJECT_PACKAGE_NAME,
|
|
|
|
"version": VERSION,
|
|
|
|
"url": PROJECT_URL,
|
|
|
|
"download_url": DOWNLOAD_URL,
|
|
|
|
"author": PROJECT_AUTHOR,
|
|
|
|
"author_email": PROJECT_EMAIL,
|
|
|
|
"description": "Python API for interacting with ESPHome devices.",
|
|
|
|
"long_description": long_description,
|
|
|
|
"license": PROJECT_LICENSE,
|
2023-10-18 06:56:30 +02:00
|
|
|
"packages": pkgs,
|
|
|
|
"exclude_package_data": {pkg: ["*.c"] for pkg in pkgs},
|
2023-10-12 20:12:39 +02:00
|
|
|
"include_package_data": True,
|
|
|
|
"zip_safe": False,
|
|
|
|
"install_requires": REQUIRES,
|
|
|
|
"python_requires": ">=3.9",
|
|
|
|
"test_suite": "tests",
|
2023-11-11 20:06:27 +01:00
|
|
|
"entry_points": {
|
|
|
|
"console_scripts": [
|
2023-11-26 18:04:17 +01:00
|
|
|
"aioesphomeapi-logs=aioesphomeapi.log_reader:cli_entry_point",
|
|
|
|
"aioesphomeapi-discover=aioesphomeapi.discover:cli_entry_point",
|
2023-11-11 20:06:27 +01:00
|
|
|
],
|
|
|
|
},
|
2023-10-12 20:12:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class OptionalBuildExt(build_ext):
|
|
|
|
def build_extensions(self):
|
|
|
|
try:
|
|
|
|
super().build_extensions()
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def cythonize_if_available(setup_kwargs):
|
|
|
|
if os.environ.get("SKIP_CYTHON", False):
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
from Cython.Build import cythonize
|
|
|
|
|
|
|
|
setup_kwargs.update(
|
|
|
|
dict(
|
|
|
|
ext_modules=cythonize(
|
2023-10-18 06:56:30 +02:00
|
|
|
MODULES_TO_CYTHONIZE,
|
2023-10-12 20:12:39 +02:00
|
|
|
compiler_directives={"language_level": "3"}, # Python 3
|
|
|
|
),
|
|
|
|
cmdclass=dict(build_ext=OptionalBuildExt),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except Exception:
|
|
|
|
if os.environ.get("REQUIRE_CYTHON"):
|
|
|
|
raise
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
cythonize_if_available(setup_kwargs)
|
|
|
|
|
|
|
|
setup(**setup_kwargs)
|