From ce0ced0b6a05054c5668961e14ae55ac54f5f0f9 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 29 Jan 2022 06:18:17 +0100 Subject: [PATCH] Move to `setup.cfg` and config for `build-system` (#11484) --- .github/workflows/release.yaml | 2 +- MANIFEST.in | 1 - build-scripts/env.js | 6 +++--- pyproject.toml | 3 +++ script/release | 4 ++-- script/version_bump.js | 4 ++-- setup.cfg | 21 +++++++++++++++++++++ setup.py | 19 ++++++------------- 8 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 pyproject.toml create mode 100644 setup.cfg diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 87b99837d5..1ae009b033 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -41,7 +41,7 @@ jobs: LOKALISE_TOKEN: ${{ secrets.LOKALISE_TOKEN }} - name: Build and release package run: | - python3 -m pip install twine + python3 -m pip install twine build export TWINE_USERNAME="__token__" export TWINE_PASSWORD="${{ secrets.TWINE_TOKEN }}" diff --git a/MANIFEST.in b/MANIFEST.in index 703dc5da5c..384d62c072 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ include README.md -include LICENSE.md graft hass_frontend graft hass_frontend_es5 recursive-exclude * *.py[co] diff --git a/build-scripts/env.js b/build-scripts/env.js index bda99cf010..1320c137dd 100644 --- a/build-scripts/env.js +++ b/build-scripts/env.js @@ -26,11 +26,11 @@ module.exports = { }, version() { const version = fs - .readFileSync(path.resolve(paths.polymer_dir, "setup.py"), "utf8") - .match(/\d{8}\.\d+/); + .readFileSync(path.resolve(paths.polymer_dir, "setup.cfg"), "utf8") + .match(/version\W+=\W(\d{8}\.\d)/); if (!version) { throw Error("Version not found"); } - return version[0]; + return version[1]; }, }; diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..cad8f17be0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools~=60.5", "wheel~=0.37.1"] +build-backend = "setuptools.build_meta" diff --git a/script/release b/script/release index f2d6e91a08..3b981bf503 100755 --- a/script/release +++ b/script/release @@ -11,6 +11,6 @@ yarn install script/build_frontend -rm -rf dist -python3 setup.py -q sdist +rm -rf dist home_assistant_frontend.egg-info +python3 -m build python3 -m twine upload dist/* --skip-existing diff --git a/script/version_bump.js b/script/version_bump.js index 35ad851f15..74fc3770e0 100755 --- a/script/version_bump.js +++ b/script/version_bump.js @@ -50,14 +50,14 @@ async function main(args) { return; } - const setup = fs.readFileSync("setup.py", "utf8"); + const setup = fs.readFileSync("setup.cfg", "utf8"); const version = setup.match(/\d{8}\.\d+/)[0]; const newVersion = method(version); console.log("Current version:", version); console.log("New version:", newVersion); - fs.writeFileSync("setup.py", setup.replace(version, newVersion), "utf-8"); + fs.writeFileSync("setup.cfg", setup.replace(version, newVersion), "utf-8"); if (!commit) { return; diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000..cfcc00c7e3 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,21 @@ +[metadata] +name = home-assistant-frontend +version = 20220127.0 +author = The Home Assistant Authors +author_email = hello@home-assistant.io +license = Apache-2.0 +platforms = any +description = The Home Assistant frontend +long_description = file: README.md +long_description_content_type = text/markdown +url = https://github.com/home-assistant/frontend + +[options] +packages = find: +zip_safe = False +include_package_data = True +python_requires = >= 3.4.0 + +[options.packages.find] +include = + hass_frontend* diff --git a/setup.py b/setup.py index 7417efc3bd..69bf65dd8a 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,7 @@ -from setuptools import setup, find_packages +""" +Entry point for setuptools. Required for editable installs. +TODO: Remove file after updating to pip 21.3 +""" +from setuptools import setup -setup( - name="home-assistant-frontend", - version="20220127.0", - description="The Home Assistant frontend", - url="https://github.com/home-assistant/frontend", - author="The Home Assistant Authors", - author_email="hello@home-assistant.io", - license="Apache-2.0", - packages=find_packages(include=["hass_frontend", "hass_frontend.*"]), - include_package_data=True, - zip_safe=False, -) +setup()