diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 17575ebe375..256a0d7d155 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -107,7 +107,7 @@ repos: pass_filenames: false language: script types: [text] - files: ^(homeassistant/.+/manifest\.json|setup\.py|\.pre-commit-config\.yaml|script/gen_requirements_all\.py)$ + files: ^(homeassistant/.+/manifest\.json|setup\.cfg|\.pre-commit-config\.yaml|script/gen_requirements_all\.py)$ - id: hassfest name: hassfest entry: script/run-in-env.sh python3 -m script.hassfest diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index ce2178288a0..872f2d0c7a8 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 """Generate an updated requirements_all.txt.""" +import configparser import difflib import importlib import os @@ -167,10 +168,9 @@ def explore_module(package, explore_children): def core_requirements(): """Gather core requirements out of setup.py.""" - reqs_raw = re.search( - r"REQUIRES = \[(.*?)\]", Path("setup.py").read_text(), re.S - ).group(1) - return [x[1] for x in re.findall(r"(['\"])(.*?)\1", reqs_raw)] + parser = configparser.ConfigParser() + parser.read("setup.cfg") + return parser["options"]["install_requires"].strip().split("\n") def gather_recursive_requirements(domain, seen=None): diff --git a/setup.cfg b/setup.cfg index f285902985c..4b226b4402c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,6 +14,34 @@ classifier = Programming Language :: Python :: 3.9 Topic :: Home Automation +[options] +install_requires = + aiohttp==3.8.1 + astral==2.2 + async_timeout==4.0.2 + attrs==21.2.0 + atomicwrites==1.4.0 + awesomeversion==22.1.0 + bcrypt==3.1.7 + certifi>=2021.5.30 + ciso8601==2.2.0 + # When bumping httpx, please check the version pins of + # httpcore, anyio, and h11 in gen_requirements_all + httpx==0.21.3 + ifaddr==0.1.7 + jinja2==3.0.3 + PyJWT==2.1.0 + # PyJWT has loose dependency. We want the latest one. + cryptography==35.0.0 + pip>=8.0.3,<20.3 + python-slugify==4.0.1 + pyyaml==6.0 + requests==2.27.1 + typing-extensions>=3.10.0.2,<5.0 + voluptuous==0.12.2 + voluptuous-serialize==2.5.0 + yarl==1.7.2 + [flake8] exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build max-complexity = 25 diff --git a/setup.py b/setup.py index efcf61b85fc..c6f3f1fb02f 100755 --- a/setup.py +++ b/setup.py @@ -31,34 +31,6 @@ PROJECT_URLS = { PACKAGES = find_packages(exclude=["tests", "tests.*"]) -REQUIRES = [ - "aiohttp==3.8.1", - "astral==2.2", - "async_timeout==4.0.2", - "attrs==21.2.0", - "atomicwrites==1.4.0", - "awesomeversion==22.1.0", - "bcrypt==3.1.7", - "certifi>=2021.5.30", - "ciso8601==2.2.0", - # When bumping httpx, please check the version pins of - # httpcore, anyio, and h11 in gen_requirements_all - "httpx==0.21.3", - "ifaddr==0.1.7", - "jinja2==3.0.3", - "PyJWT==2.1.0", - # PyJWT has loose dependency. We want the latest one. - "cryptography==35.0.0", - "pip>=8.0.3,<20.3", - "python-slugify==4.0.1", - "pyyaml==6.0", - "requests==2.27.1", - "typing-extensions>=3.10.0.2,<5.0", - "voluptuous==0.12.2", - "voluptuous-serialize==2.5.0", - "yarl==1.7.2", -] - MIN_PY_VERSION = ".".join(map(str, hass_const.REQUIRED_PYTHON_VER)) setup( @@ -72,7 +44,6 @@ setup( packages=PACKAGES, include_package_data=True, zip_safe=False, - install_requires=REQUIRES, python_requires=f">={MIN_PY_VERSION}", test_suite="tests", entry_points={"console_scripts": ["hass = homeassistant.__main__:main"]},