diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 67120ef..0c76d7a 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -30,7 +30,7 @@ jobs: pip install dist/*.tar.gz - uses: actions/upload-artifact@v4 with: - name: sdist + name: build-sdist path: dist/*.tar.gz build-wheels: runs-on: ubuntu-latest @@ -50,7 +50,7 @@ jobs: python -m pip install dist/*.whl - uses: actions/upload-artifact@v4 with: - name: wheel-${{ matrix.python-version }} + name: build-wheel-${{ matrix.python-version }} path: dist/*.whl publish-artifacts: runs-on: ubuntu-latest @@ -61,28 +61,11 @@ jobs: permissions: id-token: write steps: - - run: | - mkdir dist - - uses: actions/download-artifact@v4 - with: - name: "sdist" - path: "dist/" - - uses: actions/download-artifact@v4 - with: - name: "wheel-3.9" - path: "dist/" - - uses: actions/download-artifact@v4 - with: - name: "wheel-3.10" - path: "dist/" - - uses: actions/download-artifact@v4 - with: - name: "wheel-3.11" - path: "dist/" - uses: actions/download-artifact@v4 with: - name: "wheel-3.12" path: "dist/" + pattern: build-* + merge-multiple: true - run: | ls -lh dist/ - name: Publish package distributions to PyPI diff --git a/.github/workflows/style_check.yml b/.github/workflows/style_check.yml index 6755f44..ff0ac5d 100644 --- a/.github/workflows/style_check.yml +++ b/.github/workflows/style_check.yml @@ -15,21 +15,13 @@ jobs: python-version: [3.9] steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + - name: Install uv + uses: astral-sh/setup-uv@v3 with: - python-version: ${{ matrix.python-version }} - architecture: x64 - cache: 'pip' - cache-dependency-path: 'requirements*' - - name: check OS - run: cat /etc/os-release - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y git make gcc - - name: Install/upgrade dev dependencies - run: python3 -m pip install -r requirements.dev.txt + version: "0.4.21" + enable-cache: true + cache-dependency-glob: "**/pyproject.toml" + - name: Set up Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} - name: Lint check - run: | - make lint + run: uv run --only-dev make lint diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 441941b..5be89e4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,26 +16,16 @@ jobs: uv-resolution: ["lowest-direct", "highest"] steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + - name: Install uv + uses: astral-sh/setup-uv@v3 with: - python-version: ${{ matrix.python-version }} - architecture: x64 - cache: 'pip' - cache-dependency-path: 'requirements*' - - name: check OS - run: cat /etc/os-release - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends git make gcc - - name: Install/upgrade Python setup deps - run: python3 -m pip install --upgrade pip setuptools uv - - name: Install Trainer - run: | - python3 -m uv pip install --resolution=${{ matrix.uv-resolution }} --system "coqui-tts-trainer[dev,test] @ ." + version: "0.4.21" + enable-cache: true + cache-dependency-glob: "**/pyproject.toml" + - name: Set up Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} - name: Unit tests - run: make test_all + run: uv run --resolution=${{ matrix.uv-resolution }} --all-extras make test_all - name: Upload coverage data uses: actions/upload-artifact@v4 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 615dc54..be693ec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,13 @@ repos: - repo: "https://github.com/pre-commit/pre-commit-hooks" - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.10 + rev: v0.6.9 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - - repo: local - hooks: - - id: generate_requirements.py - name: generate_requirements.py - language: system - entry: python bin/generate_requirements.py - files: "pyproject.toml|requirements.*\\.txt|tools/generate_requirements.py" diff --git a/Makefile b/Makefile index eacf888..a273bef 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ style: ## update code style. lint: ## run linter. ruff check ${target_dirs} + ruff format --check ${target_dirs} dev-deps: ## install development deps pip install -r requirements.dev.txt diff --git a/bin/generate_requirements.py b/bin/generate_requirements.py deleted file mode 100644 index bbd32ba..0000000 --- a/bin/generate_requirements.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python -"""Generate requirements/*.txt files from pyproject.toml. - -Adapted from: -https://github.com/numpy/numpydoc/blob/e7c6baf00f5f73a4a8f8318d0cb4e04949c9a5d1/tools/generate_requirements.py -""" - -import sys -from pathlib import Path - -try: # standard module since Python 3.11 - import tomllib as toml -except ImportError: - try: # available for older Python via pip - import tomli as toml - except ImportError: - sys.exit("Please install `tomli` first: `pip install tomli`") - -script_pth = Path(__file__) -repo_dir = script_pth.parent.parent -script_relpth = script_pth.relative_to(repo_dir) -header = [ - f"# Generated via {script_relpth.as_posix()} and pre-commit hook.", - "# Do not edit this file; modify pyproject.toml instead.", -] - - -def generate_requirement_file(name: str, req_list: list[str]) -> None: - req_fname = repo_dir / f"requirements.{name}.txt" - req_fname.write_text("\n".join(header + req_list) + "\n") - - -def main() -> None: - pyproject = toml.loads((repo_dir / "pyproject.toml").read_text()) - generate_requirement_file("dev", pyproject["project"]["optional-dependencies"]["dev"]) - - -if __name__ == "__main__": - main() diff --git a/pyproject.toml b/pyproject.toml index 46fc7c2..ce03ecb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,24 +46,24 @@ dependencies = [ "psutil>=5", "soundfile>=0.12.0", "tensorboard>=2.17.0", - "torch>=2.0", + "torch>=2.1", ] [project.optional-dependencies] -# Development dependencies -dev = [ - "coverage>=7", - "pre-commit>=3", - "pytest>=8", - "ruff==0.4.10", - "tomli>=2; python_version < '3.11'", -] # Dependencies for running the tests test = [ "accelerate>=0.20.0", "torchvision>=0.15.1", ] +[tool.uv] +dev-dependencies = [ + "coverage>=7", + "pre-commit>=3", + "pytest>=8", + "ruff==0.6.9", +] + [project.urls] Homepage = "https://github.com/idiap/coqui-ai-Trainer" Repository = "https://github.com/idiap/coqui-ai-Trainer" diff --git a/requirements.dev.txt b/requirements.dev.txt deleted file mode 100644 index ae2d8bf..0000000 --- a/requirements.dev.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Generated via bin/generate_requirements.py and pre-commit hook. -# Do not edit this file; modify pyproject.toml instead. -coverage -pre-commit -pytest -ruff==0.4.10 -tomli; python_version < '3.11'