From b42acdd544d6309d2bd6f5b713c7e32a1c4305ba Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 22 Feb 2026 21:02:46 -0500 Subject: [PATCH 1/2] build(python): migrate to pyproject.toml --- .github/workflows/ci-tests.yml | 17 +---- actions/facebook_post/Dockerfile | 2 +- actions/facebook_post/pyproject.toml | 18 +++++ actions/facebook_post/requirements.txt | 2 - actions/release_homebrew/action.yml | 2 +- actions/release_homebrew/pyproject.toml | 17 +++++ actions/release_homebrew/requirements.txt | 1 - actions/release_setup/Dockerfile | 2 +- actions/release_setup/pyproject.toml | 18 +++++ actions/release_setup/requirements.txt | 2 - actions/setup_python/post-ci.sh | 10 ++- actions/setup_python/pyproject.toml | 23 ++++++ actions/setup_python/setup.cfg | 1 + actions/setup_python/setup.py | 13 ++++ actions/setup_virtual_desktop/pyproject.toml | 19 +++++ .../setup_virtual_desktop/requirements.txt | 4 -- pyproject.toml | 70 +++++++++++++++++++ requirements-dev.txt | 6 -- requirements.txt | 3 - 19 files changed, 193 insertions(+), 37 deletions(-) create mode 100644 actions/facebook_post/pyproject.toml delete mode 100644 actions/facebook_post/requirements.txt create mode 100644 actions/release_homebrew/pyproject.toml delete mode 100644 actions/release_homebrew/requirements.txt create mode 100644 actions/release_setup/pyproject.toml delete mode 100644 actions/release_setup/requirements.txt create mode 100644 actions/setup_python/pyproject.toml create mode 100644 actions/setup_python/setup.cfg create mode 100644 actions/setup_python/setup.py create mode 100644 actions/setup_virtual_desktop/pyproject.toml delete mode 100644 actions/setup_virtual_desktop/requirements.txt create mode 100644 pyproject.toml delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index b16b94b..158238d 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -45,9 +45,7 @@ jobs: shell: bash run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade \ - -r requirements.txt \ - -r requirements-dev.txt + python -m pip install --upgrade -e ".[dev]" - name: Install Node Dependencies shell: bash @@ -78,18 +76,7 @@ jobs: echo "::endgroup::" echo "::group::Run Python Tests" - python -m pytest \ - -rxXs \ - --tb=native \ - --verbose \ - --color=yes \ - --cov=actions \ - --cov-report=term \ - --cov-report=xml:coverage/python-coverage.xml \ - --cov-report=json:coverage/python-coverage.json \ - --junitxml=junit-python.xml \ - -o junit_family=legacy \ - tests + python -m pytest echo "::endgroup::" - name: Test with Jest diff --git a/actions/facebook_post/Dockerfile b/actions/facebook_post/Dockerfile index 0d934ad..d8f1b08 100644 --- a/actions/facebook_post/Dockerfile +++ b/actions/facebook_post/Dockerfile @@ -5,7 +5,7 @@ RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel COPY . /app WORKDIR /app -RUN python -m pip install --no-cache-dir --upgrade -r requirements.txt +RUN python -m pip install --no-cache-dir --upgrade . # github will mount the `GITHUB_WORKSPACE` directory to /github/workspace # https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#workdir diff --git a/actions/facebook_post/pyproject.toml b/actions/facebook_post/pyproject.toml new file mode 100644 index 0000000..5c23850 --- /dev/null +++ b/actions/facebook_post/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "lizardbyte-actions-facebook-post" +version = "0.0.0" +description = "Facebook post action for GitHub workflows." +requires-python = ">=3.12" + +dependencies = [ + "python-dotenv==1.2.1", + "requests==2.32.5", +] + +[tool.setuptools.packages.find] +where = ["."] +include = [] diff --git a/actions/facebook_post/requirements.txt b/actions/facebook_post/requirements.txt deleted file mode 100644 index d2c6cda..0000000 --- a/actions/facebook_post/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -python-dotenv==1.2.1 -requests==2.32.5 diff --git a/actions/release_homebrew/action.yml b/actions/release_homebrew/action.yml index 008c125..f0058ab 100644 --- a/actions/release_homebrew/action.yml +++ b/actions/release_homebrew/action.yml @@ -138,7 +138,7 @@ runs: run: | echo "::group::Install Python Requirements" # install requirements required for this action to complete - "${{ steps.venv.outputs.python-path }}" -m pip install -r requirements.txt + "${{ steps.venv.outputs.python-path }}" -m pip install . echo "::endgroup::" - name: Checkout (org homebrew repo) diff --git a/actions/release_homebrew/pyproject.toml b/actions/release_homebrew/pyproject.toml new file mode 100644 index 0000000..23f25a0 --- /dev/null +++ b/actions/release_homebrew/pyproject.toml @@ -0,0 +1,17 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "lizardbyte-actions-release-homebrew" +version = "0.0.0" +description = "Release Homebrew action for GitHub workflows." +requires-python = ">=3.11" + +dependencies = [ + "python-dotenv==1.2.1", +] + +[tool.setuptools.packages.find] +where = ["."] +include = [] diff --git a/actions/release_homebrew/requirements.txt b/actions/release_homebrew/requirements.txt deleted file mode 100644 index af16912..0000000 --- a/actions/release_homebrew/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -python-dotenv==1.2.1 diff --git a/actions/release_setup/Dockerfile b/actions/release_setup/Dockerfile index 0d934ad..d8f1b08 100644 --- a/actions/release_setup/Dockerfile +++ b/actions/release_setup/Dockerfile @@ -5,7 +5,7 @@ RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel COPY . /app WORKDIR /app -RUN python -m pip install --no-cache-dir --upgrade -r requirements.txt +RUN python -m pip install --no-cache-dir --upgrade . # github will mount the `GITHUB_WORKSPACE` directory to /github/workspace # https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#workdir diff --git a/actions/release_setup/pyproject.toml b/actions/release_setup/pyproject.toml new file mode 100644 index 0000000..4076439 --- /dev/null +++ b/actions/release_setup/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "lizardbyte-actions-release-setup" +version = "0.0.0" +description = "Release setup action for GitHub workflows." +requires-python = ">=3.12" + +dependencies = [ + "python-dotenv==1.2.1", + "requests==2.32.5", +] + +[tool.setuptools.packages.find] +where = ["."] +include = [] diff --git a/actions/release_setup/requirements.txt b/actions/release_setup/requirements.txt deleted file mode 100644 index d2c6cda..0000000 --- a/actions/release_setup/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -python-dotenv==1.2.1 -requests==2.32.5 diff --git a/actions/setup_python/post-ci.sh b/actions/setup_python/post-ci.sh index cb8b42c..fe84523 100644 --- a/actions/setup_python/post-ci.sh +++ b/actions/setup_python/post-ci.sh @@ -26,13 +26,21 @@ if [[ -n "$WITH_PARAMS" ]]; then # setup python python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade -r requirements-dev.txt + + # Convert path for Windows (Git Bash/MSYS produces Unix-style paths that pip rejects) + if command -v cygpath > /dev/null 2>&1; then + INSTALL_PATH="$(cygpath -w "${SCRIPT_DIR}")" + else + INSTALL_PATH="${SCRIPT_DIR}" + fi + python -m pip install --upgrade "${INSTALL_PATH}[dev]" python -m pytest \ -rxXs \ --tb=native \ --verbose \ --color=yes \ + -c "${SCRIPT_DIR}/setup.cfg" \ tests/setup_python else echo "Error: WITH_PARAMS environment variable not set" >&2 diff --git a/actions/setup_python/pyproject.toml b/actions/setup_python/pyproject.toml new file mode 100644 index 0000000..41c0939 --- /dev/null +++ b/actions/setup_python/pyproject.toml @@ -0,0 +1,23 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "lizardbyte-actions-setup-python" +version = "0.0.0" +description = "Setup Python action for GitHub workflows." + +dependencies = [] + +[project.optional-dependencies] +dev = [ + "pytest==4.6.11;python_version<'3.5'", + "pytest==6.1.2;python_version>='3.5' and python_version<'3.6'", + "pytest==7.0.1;python_version>='3.6' and python_version<'3.7'", + "pytest==8.3.5;python_version>='3.7' and python_version<'3.9'", + "pytest==9.0.2;python_version>='3.9'", +] + +[tool.setuptools.packages.find] +where = ["."] +include = [] diff --git a/actions/setup_python/setup.cfg b/actions/setup_python/setup.cfg new file mode 100644 index 0000000..8ffb8ad --- /dev/null +++ b/actions/setup_python/setup.cfg @@ -0,0 +1 @@ +[tool:pytest] diff --git a/actions/setup_python/setup.py b/actions/setup_python/setup.py new file mode 100644 index 0000000..08e2954 --- /dev/null +++ b/actions/setup_python/setup.py @@ -0,0 +1,13 @@ +from setuptools import setup + +setup( + extras_require={ + "dev": [ + "pytest==4.6.11;python_version<'3.5'", + "pytest==6.1.2;python_version>='3.5' and python_version<'3.6'", + "pytest==7.0.1;python_version>='3.6' and python_version<'3.7'", + "pytest==8.3.5;python_version>='3.7' and python_version<'3.9'", + "pytest==9.0.2;python_version>='3.9'", + ], + }, +) diff --git a/actions/setup_virtual_desktop/pyproject.toml b/actions/setup_virtual_desktop/pyproject.toml new file mode 100644 index 0000000..ff35aeb --- /dev/null +++ b/actions/setup_virtual_desktop/pyproject.toml @@ -0,0 +1,19 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "lizardbyte-actions-setup-virtual-desktop" +version = "0.0.0" +description = "Setup virtual desktop action for GitHub workflows." +requires-python = ">=3.12" + +dependencies = [ + # PyGObject provides Python bindings for GObject-based libraries like GTK and AppIndicator + # Only install on Linux where AppIndicator/Ayatana is available + "pygobject==3.54.5;sys_platform=='linux'", +] + +[tool.setuptools.packages.find] +where = ["."] +include = [] diff --git a/actions/setup_virtual_desktop/requirements.txt b/actions/setup_virtual_desktop/requirements.txt deleted file mode 100644 index 92bc560..0000000 --- a/actions/setup_virtual_desktop/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -# Python dependencies for test_appindicator.py -# PyGObject provides Python bindings for GObject-based libraries like GTK and AppIndicator -# Only install on Linux where AppIndicator/Ayatana is available -pygobject==3.54.5; sys_platform == 'linux' diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b38c182 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,70 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "lizardbyte-actions" +version = "0.0.0" +description = "Reusable actions for GitHub workflows." +readme = "README.md" +license = "MIT" +authors = [ + {name = "LizardByte", email = "lizardbyte@users.noreply.github.com"} +] + +dependencies = [ + "lizardbyte-actions-facebook-post @ file:./actions/facebook_post", + "lizardbyte-actions-release-homebrew @ file:./actions/release_homebrew", + "lizardbyte-actions-release-setup @ file:./actions/release_setup", +] + +[project.optional-dependencies] +dev = [ + "pytest==9.0.2", + "pytest-cov==7.0.0", +] + +[project.urls] +Homepage = "https://github.com/LizardByte/actions#readme" +Repository = "https://github.com/LizardByte/actions" +Issues = "https://github.com/LizardByte/actions/issues" + +[tool.setuptools.packages.find] +include = ["actions*"] + +[tool.pytest.ini_options] +testpaths = ["tests"] +pythonpath = ["."] +python_files = ["test_*.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] +addopts = [ + "-rxXs", + "--tb=native", + "--verbose", + "--color=yes", + "--cov=actions", + "--cov-report=term", + "--cov-report=xml:coverage/python-coverage.xml", + "--cov-report=json:coverage/python-coverage.json", + "--junitxml=junit-python.xml", + "-o", "junit_family=legacy", +] + +[tool.coverage.run] +source = ["actions"] +omit = [ + "*/tests/*", + "*/__pycache__/*", +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise AssertionError", + "raise NotImplementedError", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", + "@abstractmethod", +] diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index cb9c340..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,6 +0,0 @@ -pytest==4.6.11;python_version<"3.5" -pytest==6.1.2;python_version>="3.5" and python_version<"3.6" -pytest==7.0.1;python_version>="3.6" and python_version<"3.7" -pytest==8.3.5;python_version>="3.7" and python_version<"3.9" -pytest==9.0.2;python_version>="3.9" -pytest-cov==7.0.0;python_version>="3.9" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index aa225b6..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ --r ./actions/facebook_post/requirements.txt --r ./actions/release_homebrew/requirements.txt --r ./actions/release_setup/requirements.txt From dcbe8d159eefa271cede666bfbcb8993b52bfd0f Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 23 Feb 2026 22:09:55 -0500 Subject: [PATCH 2/2] Move pytest args to setup.cfg and parse dev extras Move pytest CLI options and test paths out of the CI script into actions/setup_python/setup.cfg (using addopts and testpaths) and simplify post-ci.sh to invoke pytest with only -c. Add a get_dev_extras() helper in actions/setup_python/setup.py that parses the [project.optional-dependencies] dev block from pyproject.toml (no toml dependency) and use it for extras_require to centralize dev dependency declarations. --- actions/setup_python/post-ci.sh | 8 +------- actions/setup_python/setup.cfg | 5 +++++ actions/setup_python/setup.py | 32 +++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/actions/setup_python/post-ci.sh b/actions/setup_python/post-ci.sh index fe84523..350020a 100644 --- a/actions/setup_python/post-ci.sh +++ b/actions/setup_python/post-ci.sh @@ -35,13 +35,7 @@ if [[ -n "$WITH_PARAMS" ]]; then fi python -m pip install --upgrade "${INSTALL_PATH}[dev]" - python -m pytest \ - -rxXs \ - --tb=native \ - --verbose \ - --color=yes \ - -c "${SCRIPT_DIR}/setup.cfg" \ - tests/setup_python + python -m pytest -c "${SCRIPT_DIR}/setup.cfg" tests/setup_python else echo "Error: WITH_PARAMS environment variable not set" >&2 exit 1 diff --git a/actions/setup_python/setup.cfg b/actions/setup_python/setup.cfg index 8ffb8ad..912f4f2 100644 --- a/actions/setup_python/setup.cfg +++ b/actions/setup_python/setup.cfg @@ -1 +1,6 @@ [tool:pytest] +addopts = + -rxXs + --tb=native + --verbose + --color=yes diff --git a/actions/setup_python/setup.py b/actions/setup_python/setup.py index 08e2954..4d30b6a 100644 --- a/actions/setup_python/setup.py +++ b/actions/setup_python/setup.py @@ -1,13 +1,31 @@ +import os +import re from setuptools import setup + +def get_dev_extras(): + """Read the dev extras from pyproject.toml without any TOML library dependency.""" + pyproject_path = os.path.join(os.path.dirname(__file__), "pyproject.toml") + + with open(pyproject_path, "r") as f: + content = f.read() + + # Extract the [project.optional-dependencies] dev block + match = re.search( + r'\[project\.optional-dependencies]\s*dev\s*=\s*\[(.*?)]', + content, + re.DOTALL, + ) + if not match: + return [] + + block = match.group(1) + # Extract each quoted string + return re.findall(r'"([^"]+)"', block) + + setup( extras_require={ - "dev": [ - "pytest==4.6.11;python_version<'3.5'", - "pytest==6.1.2;python_version>='3.5' and python_version<'3.6'", - "pytest==7.0.1;python_version>='3.6' and python_version<'3.7'", - "pytest==8.3.5;python_version>='3.7' and python_version<'3.9'", - "pytest==9.0.2;python_version>='3.9'", - ], + "dev": get_dev_extras(), }, )