Use dynamic fields in pyproject.toml to load requirements and version

Revert requirements.txt changes
This commit is contained in:
Jesse Hills 2024-05-15 19:38:45 +12:00
parent 59909d2dfa
commit 33a047f169
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A
4 changed files with 35 additions and 89 deletions

View File

@ -4,7 +4,6 @@ build-backend = "setuptools.build_meta"
[project]
name = "esphome"
version = "2024.6.0-dev"
license = {text = "MIT"}
description = "Make creating custom firmwares for ESP32/ESP8266 super easy."
readme = "README.md"
@ -22,38 +21,8 @@ classifiers = [
"Topic :: Home Automation",
]
requires-python = ">=3.9.0"
dependencies = [
"async_timeout==4.0.3;python_version<='3.10'",
"cryptography==42.0.2",
"voluptuous==0.14.2",
"PyYAML==6.0.1",
"paho-mqtt==1.6.1",
"colorama==0.4.6",
"icmplib==3.0.4",
"tornado==6.4",
"tzlocal==5.2", # from time
"tzdata>=2021.1", # from time
"pyserial==3.5",
"platformio==6.1.15", # When updating platformio, also update Dockerfile
"esptool==4.7.0",
"click==8.1.7",
"esphome-dashboard==20240412.0",
"aioesphomeapi==24.3.0",
"zeroconf==0.132.2",
"python-magic==0.4.27",
"ruamel.yaml==0.18.6", # dashboard_import
"pip>=21.3.1",
# esp-idf requires this, but doesn't bundle it by default
# https://github.com/espressif/esp-idf/blob/220590d599e134d7a5e7f1e683cc4550349ffbf8/requirements.txt#L24
"kconfiglib==13.7.1",
# esp-idf >= 5.0 requires this
"pyparsing >= 3.0",
# For autocompletion
"argcomplete>=2.0.0",
]
dynamic = ["dependencies", "optional-dependencies", "version"]
[project.urls]
"Documentation" = "https://esphome.io"
@ -72,6 +41,13 @@ platforms = ["any"]
zip-safe = false
include-package-data = true
[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
optional-dependencies.dev = { file = ["requirements_dev.txt"] }
optional-dependencies.test = { file = ["requirements_test.txt"] }
optional-dependencies.displays = { file = ["requirements_optional.txt"] }
version = {attr = "esphome.const.__version__"}
[tool.setuptools.packages.find]
include = ["esphome*"]

View File

@ -1,25 +1,29 @@
# Automatically generated by gen_requirements.py, do not edit
PyYAML==6.0.1
aioesphomeapi==24.3.0
argcomplete>=2.0.0
async_timeout==4.0.3;python_version<='3.10'
click==8.1.7
colorama==0.4.6
async_timeout==4.0.3; python_version <= "3.10"
cryptography==42.0.2
esphome-dashboard==20240412.0
esptool==4.7.0
icmplib==3.0.4
kconfiglib==13.7.1
paho-mqtt==1.6.1
pip>=21.3.1
platformio==6.1.15
pyparsing >= 3.0
pyserial==3.5
python-magic==0.4.27
ruamel.yaml==0.18.6
tornado==6.4
tzdata>=2021.1
tzlocal==5.2
voluptuous==0.14.2
PyYAML==6.0.1
paho-mqtt==1.6.1
colorama==0.4.6
icmplib==3.0.4
tornado==6.4
tzlocal==5.2 # from time
tzdata>=2021.1 # from time
pyserial==3.5
platformio==6.1.15 # When updating platformio, also update Dockerfile
esptool==4.7.0
click==8.1.7
esphome-dashboard==20240412.0
aioesphomeapi==24.3.0
zeroconf==0.132.2
python-magic==0.4.27
ruamel.yaml==0.18.6 # dashboard_import
# esp-idf requires this, but doesn't bundle it by default
# https://github.com/espressif/esp-idf/blob/220590d599e134d7a5e7f1e683cc4550349ffbf8/requirements.txt#L24
kconfiglib==13.7.1
# esp-idf >= 5.0 requires this
pyparsing >= 3.0
# For autocompletion
argcomplete>=2.0.0

View File

@ -1,34 +0,0 @@
#!/usr/bin/env python3
"""Generate updated requirements file."""
from __future__ import annotations
import os
from pathlib import Path
import sys
import tomllib
def main() -> int:
"""Run the script."""
if not os.path.isfile("requirements.txt"):
print("Run this from ESPHome root dir")
return 1
with open("pyproject.toml", "rb") as fp:
data = tomllib.load(fp)
dependencies: list[str] = sorted(data["project"]["dependencies"])
output = [f"# Automatically generated by {Path(__file__).name}, do not edit\n\n"]
output.append("\n".join(dependencies))
output.append("\n")
reqs = "".join(output)
with open("requirements.txt", "w", encoding="utf-8") as fp:
fp.write(reqs)
return 0
if __name__ == "__main__":
sys.exit(main())

View File

@ -20,7 +20,7 @@ fi
pip3 install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt -r requirements_dev.txt
pip3 install setuptools wheel
pip3 install -e . --config-settings editable_mode=compat
pip3 install -e --config-settings editable_mode=compat ".[dev,test,displays]"
pre-commit install