diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9e3f7e0..d5e9ec0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,6 +18,21 @@ on: jobs: + run-type-checking: + + name: Run tests for type-checking + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version-file: .python-version + allow-prereleases: true + cache: pip + - run: pip install tox-uv + - run: tox -e typing + run-tests: name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }} diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index dce4729..d7e32d4 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,36 +1,91 @@ -name: PyPI +name: Publish Python 🐍 distribution 📦 to PyPI on: push jobs: - build-n-publish: - name: Build and publish Python 🐍 distributions 📦 to PyPI + build: + name: Build distribution 📦 runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 - - - name: Set up Python 3.8 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.8 - + python-version: "3.x" - name: Install pypa/build run: >- - python -m + python3 -m pip install build --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + publish-to-pypi: + name: Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pytask-latex + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: >- + Sign the Python 🐍 distribution 📦 with Sigstore + and upload them to GitHub Release + needs: + - publish-to-pypi + runs-on: ubuntu-latest + + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v2.1.1 with: - password: ${{ secrets.PYPI_API_TOKEN }} + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. `dist/` contains the built + # packages, and the sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 76f9737..e423e8e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: args: [--branch, main] - id: trailing-whitespace - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 # Use the ref you want to point at + rev: v1.10.0 hooks: - id: python-check-blanket-noqa - id: python-check-mock-methods @@ -48,24 +48,6 @@ repos: hooks: - id: codespell args: [-L als, -L falsy] -- repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.9.0' - hooks: - - id: mypy - additional_dependencies: [ - attrs>=21.3.0, - click, - pytask>=0.4.0, - types-PyYAML, - types-setuptools - ] - pass_filenames: false -- repo: https://github.com/mgedmin/check-manifest - rev: "0.49" - hooks: - - id: check-manifest - args: [--no-build-isolation] - additional_dependencies: [setuptools-scm, toml, wheel] - repo: meta hooks: - id: check-hooks-apply diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..8531a3b --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12.2 diff --git a/CHANGES.md b/CHANGES.md index 336916e..873c317 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,11 +4,15 @@ This is a record of all past pytask-latex releases and what went into them in re chronological order. Releases follow [semantic versioning](https://semver.org/) and all releases are available on [Anaconda.org](https://anaconda.org/conda-forge/pytask-latex). -## 0.4.2 - 2023-xx-xx +## 0.4.3 - 2024-xx-xx + +- {pull}`75` adds rye. + +## 0.4.2 - 2023-11-30 - {pull}`65` simplifies dependency management. - {pull}`66` removes using `MetaNode`. -- {pull}`72` updates syntax of tests. +- {pull}`72` updates the syntax of tests. ## 0.4.1 - 2023-10-12 @@ -26,7 +30,7 @@ releases are available on [Anaconda.org](https://anaconda.org/conda-forge/pytask ## 0.2.1 - 2022-04-19 -- {pull}`40` fixes the error message which advises user to transition to the new +- {pull}`40` fixes the error message which advises the user to transition to the new interface. ## 0.2.0 - 2022-04-16 diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 0802715..0000000 --- a/environment.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: pytask-latex - -channels: - - conda-forge/label/pytask_rc - - conda-forge/label/pytask_parallel_rc - - conda-forge - - nodefaults - -dependencies: - - python >= 3.8 - - pip - - setuptools_scm - - toml - - # Package dependencies - - pytask >= 0.4.0 - - pytask-parallel >= 0.4.0 - - latex-dependency-scanner >=0.1.1 - - # Misc - - black - - jupyterlab - - matplotlib - - pre-commit - - pytest - - pytest-cov - - pytest-xdist - - - pip: - - -e . diff --git a/pyproject.toml b/pyproject.toml index ad958f5..3db50d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" [project] name = "pytask_latex" @@ -10,13 +10,17 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only" + "Programming Language :: Python :: 3 :: Only", ] requires-python = ">=3.8" -dependencies = [ "latex-dependency-scanner>=0.1.1", "pluggy>=1.0.0", "pytask>=0.4.0"] -dynamic = [ "version" ] -authors = [ { name = "Tobias Raabe", email = "raabe@poste.de"} ] -readme = { file = "README.md", content-type = "text/markdown"} +dependencies = [ + "latex-dependency-scanner>=0.1.3", + "pluggy>=1.0.0", + "pytask>=0.4.0", +] +dynamic = ["version"] +authors = [{ name = "Tobias Raabe", email = "raabe@poste.de" }] +readme = { file = "README.md", content-type = "text/markdown" } license = { text = "MIT" } [project.urls] @@ -28,28 +32,32 @@ Tracker = "https://github.com/pytask-dev/pytask-latex/issues" [project.optional-dependencies] test = ["pytest", "pytest-cov", "pytest-xdist"] - -[tool.setuptools] -include-package-data = true -zip-safe = false -platforms = [ "any",] -license-files = [ "LICENSE" ] - -[tool.check-manifest] -ignore = ["src/pytask_latex/_version.py"] +typing = [ + "mypy>=1.10.0", +] [project.entry-points.pytask] pytask_latex = "pytask_latex.plugin" -[tool.setuptools.package-dir] -"" = "src" +[tool.rye] +managed = true + +[tool.hatch.build.hooks.vcs] +version-file = "src/pytask_latex/_version.py" + +[tool.hatch.build.targets.sdist] +exclude = ["tests"] +only-packages = true + +[tool.hatch.build.targets.wheel] +exclude = ["tests"] +only-packages = true -[tool.setuptools.packages.find] -where = [ "src" ] -namespaces = false +[tool.hatch.version] +source = "vcs" -[tool.setuptools_scm] -write_to = "src/pytask_latex/_version.py" +[tool.hatch.metadata] +allow-direct-references = true [tool.mypy] files = ["src", "tests"] @@ -73,9 +81,9 @@ unsafe-fixes = true [tool.ruff.lint] extend-ignore = [ - "ANN401", # Allow typing.Any. - "COM812", # Comply with ruff-format - "ISC001", # Comply with ruff-format + "ANN401", # Allow typing.Any. + "COM812", # Comply with ruff-format + "ISC001", # Comply with ruff-format ] select = ["ALL"] @@ -89,7 +97,6 @@ force-single-line = true convention = "numpy" [tool.pytest.ini_options] -# Do not add src since it messes with the loading of pytask-parallel as a plugin. testpaths = ["src", "tests"] markers = [ "wip: Tests that are work-in-progress.", diff --git a/tox.ini b/tox.ini index cee7247..11b16f3 100644 --- a/tox.ini +++ b/tox.ini @@ -9,3 +9,7 @@ passenv = CI extras = test commands = pytest {posargs} + +[testenv:typing] +extras = typing +commands = mypy