diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 434be54..545c040 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -28,15 +28,26 @@ jobs: - "3.9" - "3.8" os: - - ubuntu-22.04 - - windows-2022 - - macos-12 + - ubuntu-latest + - windows-latest + - macos-latest steps: - - name: Setup python for tox + - name: Setup python for test ${{ matrix.py }} uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: ${{ matrix.py }} + allow-prereleases: true + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v2 + with: + enable-cache: true + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: install hatch + run: uv pip install hatch --system + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Pick environment to run run: | import codecs; import os @@ -44,23 +55,12 @@ jobs: py = "test.{}".format(py if py.startswith("pypy") else f"py{py}") print(f"Picked {py}") with codecs.open(os.environ["GITHUB_ENV"], mode="a", encoding="utf-8") as file_handler: - file_handler.write("FORCE_COLOR=1\n") - file_handler.write(f"ENV={py}\n") + file_handler.write(f"FORCE_COLOR=1\nENV={py}\n") shell: python - - name: Install Hatch - uses: pypa/hatch@install - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup python for test ${{ matrix.py }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.py }} - allow-prereleases: true - name: Setup test environment run: | hatch -v env create ${ENV} - hatch run ${ENV}:pip freeze + hatch run ${ENV}:uv pip tree shell: bash - name: Run test suite run: hatch -v run ${ENV}:run @@ -83,19 +83,24 @@ jobs: coverage: name: Combine coverage - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest needs: test steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Let us have colors + run: echo "FORCE_COLOR=true" >> "$GITHUB_ENV" - uses: actions/setup-python@v5 with: python-version: "3.12" - - name: Let us have colors - run: echo "FORCE_COLOR=true" >> "$GITHUB_ENV" - - name: Install Hatch - uses: pypa/hatch@install + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v2 + with: + enable-cache: true + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: install hatch + run: uv pip install hatch --system + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup coverage tool run: | hatch -v env create coverage @@ -121,23 +126,28 @@ jobs: fail-fast: false matrix: os: - - ubuntu-22.04 - - windows-2022 + - ubuntu-latest + - windows-latest env: - - {"name": "default", "target": "show"} - - {"name": "type", "target": "run"} - - {"name": "docs", "target": "build"} - - {"name": "readme", "target": "run"} + - { "name": "default", "target": "show" } + - { "name": "type", "target": "run" } + - { "name": "docs", "target": "build" } + - { "name": "readme", "target": "run" } steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup Python "3.12" uses: actions/setup-python@v5 with: python-version: "3.12" - - name: Install Hatch - uses: pypa/hatch@install + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v2 + with: + enable-cache: true + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: install hatch + run: uv pip install hatch --system + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup ${{ matrix.env.name }} run: | hatch -v env create ${{ matrix.env.name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3df5a88..5a1e8ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: jobs: release: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest environment: name: release url: https://pypi.org/p/platformdirs @@ -16,12 +16,14 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.12" + - name: setup uv for tox + uses: yezz123/setup-uv@v4 - name: Install build - run: python -m pip install build + run: uv pip install build[uv] --system - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Build package - run: pyproject-build -s -w . -o dist + run: pyproject-build --installer uv --sdist --wheel . --outdir dist - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@v1.10.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3b74092..721285d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,28 +4,31 @@ repos: hooks: - id: end-of-file-fixer - id: trailing-whitespace + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.29.2 + hooks: + - id: check-github-workflows + args: ["--verbose"] - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: - id: codespell - additional_dependencies: [ "tomli>=2.0.1" ] - - repo: https://github.com/PyCQA/docformatter - rev: v1.7.5 + additional_dependencies: ["tomli>=2.0.1"] + - repo: https://github.com/tox-dev/pyproject-fmt + rev: "2.2.3" hooks: - - id: docformatter - additional_dependencies: [ "tomli>=2.0.1" ] - args: [ "--in-place", "--config", "./pyproject.toml" ] + - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.3" + rev: "v0.6.4" hooks: - id: ruff-format - id: ruff - args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix" ] - - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.2.1" + args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"] + - repo: https://github.com/rbubley/mirrors-prettier + rev: "v3.3.3" hooks: - - id: pyproject-fmt - additional_dependencies: ["tox>=4.14.2"] + - id: prettier + args: ["--print-width=120", "--prose-wrap=always"] - repo: meta hooks: - id: check-hooks-apply diff --git a/pyproject.toml b/pyproject.toml index 7c35da1..66f7e4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ build-backend = "hatchling.build" requires = [ "hatch-vcs>=0.4", - "hatchling>=1.18", + "hatchling>=1.25", ] [project] @@ -46,20 +46,20 @@ dynamic = [ "version", ] optional-dependencies.docs = [ - "furo>=2023.9.10", - "proselint>=0.13", - "sphinx>=7.2.6", - "sphinx-autodoc-typehints>=1.25.2", + "furo>=2024.8.6", + "proselint>=0.14", + "sphinx>=8.0.2", + "sphinx-autodoc-typehints>=2.4", ] optional-dependencies.test = [ "appdirs==1.4.4", "covdefaults>=2.3", - "pytest>=7.4.3", - "pytest-cov>=4.1", - "pytest-mock>=3.12", + "pytest>=8.3.2", + "pytest-cov>=5", + "pytest-mock>=3.14", ] optional-dependencies.type = [ - "mypy>=1.8", + "mypy>=1.11.2", ] urls.Documentation = "https://platformdirs.readthedocs.io" urls.Homepage = "https://github.com/platformdirs/platformdirs" @@ -76,6 +76,7 @@ build.targets.sdist.include = [ version.source = "vcs" [tool.hatch.envs.default] +installer = "uv" description = "Development environment" features = [ "test", @@ -83,12 +84,13 @@ features = [ "type", ] scripts = { show = [ - "python -m pip list --format=columns", + "uv pip tree", 'python -c "import sys; print(sys.executable)"', ] } [tool.hatch.envs.test] template = "test" +installer = "uv" # dev-mode = false # cannot enable this until https://github.com/pypa/hatch/issues/1237 description = "Run the test suite" matrix = [ @@ -105,7 +107,9 @@ matrix = [ features = [ "test", ] -env-vars = { COVERAGE_FILE = "report/.coverage.{matrix:python}", COVERAGE_PROCESS_START = "pyproject.toml", _COVERAGE_SRC = "src/platformdirs" } +env-vars.COVERAGE_FILE = "report/.coverage.{matrix:python}" +env-vars.COVERAGE_PROCESS_START = "pyproject.toml" +env-vars._COVERAGE_SRC = "src/platformdirs" [tool.hatch.envs.test.scripts] run = [ """ @@ -118,11 +122,12 @@ run = [ [tool.hatch.envs.coverage] template = "coverage" +installer = "uv" description = "combine coverage files and generate diff" dependencies = [ "covdefaults>=2.3", - "coverage[toml]>=7.3.2", - "diff-cover>=8.0.1", + "coverage[toml]>=7.6.1", + "diff-cover>=9.2", ] env-vars = { COVERAGE_FILE = "report/.coverage" } [tool.hatch.envs.coverage.scripts] @@ -136,6 +141,7 @@ run = [ [tool.hatch.envs.type] template = "type" +installer = "uv" description = "Run the type checker" python = "3.12" dev-mode = false @@ -150,11 +156,12 @@ scripts = { run = [ [tool.hatch.envs.fix] template = "fix" +installer = "uv" description = "Run the pre-commit tool to lint and autofix issues" python = "3.12" detached = true dependencies = [ - "pre-commit>=3.6", + "pre-commit-uv>=4.1", ] scripts = { "run" = [ "pre-commit run --all-files --show-diff-on-failure", @@ -162,6 +169,7 @@ scripts = { "run" = [ [tool.hatch.envs.docs] template = "docs" +installer = "uv" description = "Build documentation using Sphinx" python = "3.12" dev-mode = false @@ -178,15 +186,16 @@ build = [ [tool.hatch.envs.readme] template = "readme" +installer = "uv" description = "check that the long description is valid" python = "3.12" dependencies = [ - "build[virtualenv]>=1.0.3", - "twine>=4.0.2", - "check-wheel-contents>=0.6.0", + "build[uv]>=1.2.2", + "twine>=5.1.1", + "check-wheel-contents>=0.6", ] scripts = { "run" = [ - "python -m build -o dist", + "pyproject-build --installer uv -o dist", "twine check dist/*.whl dist/*.tar.gz", "check-wheel-contents dist", ] } @@ -232,13 +241,6 @@ builtin = "clear,usage,en-GB_to_en-US" count = true quiet-level = 3 -[tool.docformatter] -blank = true -recursive = true -pre-summary-newline = true -wrap-descriptions = 120 -wrap-summaries = 120 - [tool.pyproject-fmt] max_supported_python = "3.13"