diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 17d4e40..f3769fb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,9 +5,6 @@ concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true -env: - CONDA_EXE: mamba - on: push: branches: @@ -18,6 +15,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 }} @@ -33,18 +45,12 @@ jobs: - uses: actions/checkout@v4 - uses: r-lib/actions/setup-tinytex@v2 if: runner.os != 'Windows' - - uses: mamba-org/setup-micromamba@v1 + - uses: actions/setup-python@v5 with: - environment-name: gha-testing - condarc: | - channels: - - nodefaults - - conda-forge - create-args: >- - python=${{ matrix.python-version }} - mamba - tox-conda - cache-environment: true + python-version: ${{ matrix.python-version }} + cache: pip + allow-prereleases: true + - run: pip install tox-uv - name: Install MacOS dependencies. if: runner.os == 'macOS' @@ -56,26 +62,22 @@ jobs: shell: bash -l {0} run: tlmgr install import epstopdf biblatex biber - - name: Install core dependencies. - shell: bash -l {0} - run: conda install -c conda-forge tox-conda coverage - # Unit, integration, and end-to-end tests. - name: Run unit tests and doctests. shell: bash -l {0} - run: tox -e pytest -- src tests -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto + run: tox -e test -- src tests -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml - - name: Upload coverage report for unit tests and doctests. - if: runner.os == 'Linux' && matrix.python-version == '3.10' - shell: bash -l {0} - run: bash <(curl -s https://codecov.io/bash) -F unit -c + - name: Upload unit test coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v4 + with: + flags: unit - name: Run end-to-end tests. shell: bash -l {0} - run: tox -e pytest -- src tests -m end_to_end --cov=./ --cov-report=xml -n auto + run: tox -e test -- src tests -m end_to_end --cov=./ --cov-report=xml - - name: Upload coverage reports of end-to-end tests. - if: runner.os == 'Linux' && matrix.python-version == '3.10' - shell: bash -l {0} - run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c + - name: Upload end_to_end test coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v4 + with: + flags: end_to_end diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index dce4729..adc8cf3 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/latex-dependency-scanner + 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 0b13bc5..4c58ef5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,10 +4,17 @@ repos: hooks: - id: check-added-large-files args: ['--maxkb=25'] + - id: check-case-conflict - id: check-merge-conflict + - id: check-vcs-permalinks - id: check-yaml - id: debug-statements - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: mixed-line-ending + - id: no-commit-to-branch + args: [--branch, main] + - id: trailing-whitespace - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: @@ -36,12 +43,6 @@ repos: rev: v2.2.6 hooks: - id: codespell -- repo: https://github.com/mgedmin/check-manifest - rev: "0.49" - hooks: - - id: check-manifest - args: [--no-build-isolation] - additional_dependencies: [setuptools-scm, wheel, toml] - 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 0484762..afdc29c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,10 @@ This is a record of all past latex-dependency-scanner releases and what went into them in reverse chronological order. Releases follow [semantic versioning](https://semver.org/) and all releases are available on [PyPI](https://pypi.org/project/latex-dependency-scanner) and [Anaconda.org](https://anaconda.org/pytask/latex-dependency-scanner). +## 0.1.3 - 2024-xx-xx + +- {pull}`31` adds rye. + ## 0.1.2 - 2023-10-02 - {pull}`21` updates the readme and other infrastructure files. diff --git a/pyproject.toml b/pyproject.toml index 0738583..2500260 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,66 @@ [build-system] -requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" -[tool.setuptools_scm] -write_to = "src/latex_dependency_scanner/_version.py" +[project] +name = "latex_dependency_scanner" +description = "Scan LaTeX documents for their dependencies." +classifiers = [ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", +] +requires-python = ">=3.8" +dynamic = ["version"] + +[[project.authors]] +name = "Tobias Raabe" +email = "raabe@posteo.de" + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[project.license] +text = "MIT" + +[project.urls] +Homepage = "https://github.com/pytask-dev/latex-dependency-scanner" +Changelog = "https://github.com/pytask-dev/latex-dependency-scanner/blob/main/CHANGES.md" +Documentation = "https://github.com/pytask-dev/latex-dependency-scanner" +Github = "https://github.com/pytask-dev/latex-dependency-scanner" +Tracker = "https://github.com/pytask-dev/latex-dependency-scanner/issues" + +[project.optional-dependencies] +typing = [ + "mypy>=1.10.0", +] +test = [ + "pytest>=8.1.1", + "pytest-cov>=5.0.0", +] + +[tool.rye] +managed = true + +[tool.hatch.build.hooks.vcs] +version-file = "src/latex_dependency_scanner/_version.py" + +[tool.hatch.build.targets.sdist] +exclude = ["tests"] +only-packages = true + +[tool.hatch.build.targets.wheel] +exclude = ["tests"] +only-packages = true + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.metadata] +allow-direct-references = true [tool.mypy] files = ["src", "tests"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index e6e78f2..0000000 --- a/setup.cfg +++ /dev/null @@ -1,35 +0,0 @@ -[metadata] -name = latex_dependency_scanner -description = Scan LaTeX documents for their dependencies. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/pytask-dev/latex-dependency-scanner -author = Tobias Raabe -author_email = raabe@posteo.de -license = MIT -license_files = LICENSE -platforms = any -classifiers = - Development Status :: 3 - Alpha - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only -project_urls = - Changelog = https://github.com/pytask-dev/latex-dependency-scanner/blob/main/CHANGES.md - Documentation = https://github.com/pytask-dev/latex-dependency-scanner - Github = https://github.com/pytask-dev/latex-dependency-scanner - Tracker = https://github.com/pytask-dev/latex-dependency-scanner/issues - -[options] -packages = find: -python_requires = >=3.8 -package_dir = =src -zip_safe = False - -[options.packages.find] -where = src - -[check-manifest] -ignore = - src/latex_dependency_scanner/_version.py diff --git a/tox.ini b/tox.ini index f7022c8..d4e05af 100644 --- a/tox.ini +++ b/tox.ini @@ -1,33 +1,15 @@ [tox] -envlist = pytest +requires = tox>=4 +envlist = test, typing [testenv] -usedevelop = true +passenv = CI +package = editable -[testenv:pytest] -conda_channels = - conda-forge -conda_deps = - pytest - pytest-cov - pytest-xdist - sphinx -commands = - pytest {posargs} +[testenv:typing] +extras = typing +commands = mypy -[pytest] -testpaths = - src - tests -addopts = --doctest-modules -filterwarnings = - ignore: the imp module is deprecated in favour of importlib - ignore: Using or importing the ABCs from 'collections' instead of from -markers = - wip: Tests that are work-in-progress. - unit: Flag for unit tests which target mainly a single function. - integration: Flag for integration tests which may comprise of multiple unit tests. - end_to_end: Flag for tests that cover the whole program. -norecursedirs = - .idea - .tox +[testenv:test] +extras = test +commands = pytest {posargs}