diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 252d669..c6b84f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,27 +10,67 @@ on: pull_request: jobs: - checkreqs: + test: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] os: [macOS-latest, ubuntu-latest, windows-latest] steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Set Up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true + - uses: astral-sh/setup-uv@v3 - name: Install - run: | - python -m pip install --upgrade pip - make setup - pip install -U . + run: uv sync --extra test --extra dev - name: Test - run: make test + run: | + git config --global user.name "Unit Test" + git config --global user.email "example@example.com" + make test - name: Lint - run: make lint + run: | + make lint + - name: Metacheckdeps + run: | + make checkdeps + + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.14" + - uses: astral-sh/setup-uv@v3 + - name: Install + run: uv sync --extra test --extra dev + - name: Build + run: uv run python -m build + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: sdist + path: dist + + publish: + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + environment: pypi + permissions: + contents: read + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + name: sdist + path: dist + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.gitignore b/.gitignore index d431df9..d6fda1d 100644 --- a/.gitignore +++ b/.gitignore @@ -83,7 +83,7 @@ celerybeat-schedule # Environments .env -.venv +.venv* env/ venv/ ENV/ @@ -105,3 +105,9 @@ venv.bak/ # Visual Studio Code .vscode/ + +# Vim swapfiles +*.sw[op] + +# Setuptools-scm +_version.py diff --git a/Makefile b/Makefile index 0ec4714..fd1011d 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,25 @@ -PYTHON?=python -SOURCES=checkdeps setup.py - -.PHONY: venv -venv: - $(PYTHON) -m venv .venv - source .venv/bin/activate && make setup - @echo 'run `source .venv/bin/activate` to use virtualenv' - -# The rest of these are intended to be run within the venv, where python points -# to whatever was used to set up the venv. +.venv: + uv sync --extra dev --extra test .PHONY: setup setup: - python -m pip install -Ur requirements-dev.txt + uv sync --extra dev --extra test .PHONY: test test: - python -m coverage run -m checkdeps.tests $(TESTOPTS) - python -m coverage report + uv run coverage run -m pytest $(TESTOPTS) + uv run coverage report .PHONY: format format: - python -m ufmt format $(SOURCES) + uv run ruff format + uv run ruff check --fix .PHONY: lint lint: - python -m ufmt check $(SOURCES) - python -m flake8 $(SOURCES) - python -m checkdeps checkdeps --allow-names checkdeps - mypy --strict checkdeps + uv run ruff check + uv run python -m checkdeps --allow-names checkdeps checkdeps + uv run mypy --strict --install-types --non-interactive checkdeps .PHONY: release release: diff --git a/README.md b/README.md index 94e40e1..8c8bafc 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,18 @@ more self-contained. * Offer to add missing deps * Better handling of version-dependent deps in an `if` or `try`/`except` +# Version Compat + +This library is compatile with Python 3.10+, but should be linted under the +newest stable version. + +# Versioning + +This library follows [meanver](https://meanver.org/) which basically means +[semver](https://semver.org/) along with a promise to rename when the major +version changes. + # License checkdeps is copyright [Tim Hatch](https://timhatch.com/), and licensed under -the MIT license. I am providing code in this repository to you under an open -source license. This is my personal repository; the license you receive to -my code is from me and not from my employer. See the `LICENSE` file for details. +the MIT license. See the `LICENSE` file for details. diff --git a/checkdeps/__init__.py b/checkdeps/__init__.py index e69de29..9976658 100644 --- a/checkdeps/__init__.py +++ b/checkdeps/__init__.py @@ -0,0 +1,4 @@ +try: + from ._version import __version__ +except ImportError: # pragma: no cover + __version__ = "dev" diff --git a/checkdeps/py.typed b/checkdeps/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b409db3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,93 @@ +[build-system] +requires = [ + "setuptools >= 77", + "setuptools-scm >= 8", +] +build-backend = "setuptools.build_meta" + +[project] +name = "checkdeps" +description = "Ensures your first-order deps are correct" +readme = "README.md" +requires-python = ">=3.10" +license = "MIT" +authors = [ + { name = "Tim Hatch", email = "tim@timhatch.com" }, +] +classifiers = [ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] +dynamic = ["version"] +dependencies = [] + +[project.urls] +Homepage = "https://github.com/python-packaging/checkdeps/" + +[project.optional-dependencies] +dev = [ + "build >= 1", + "checkdeps == 0.9.0", + "mypy == 1.19.1", + "ruff == 0.15.6", +] +test = [ + "coverage >= 7.14", + "pytest >= 8", +] + +[project.scripts] +# foo = "foo:bar" + +[tool.setuptools] +packages = { find = {} } +include-package-data = true + +[tool.setuptools.package-data] +"checkdeps" = ["py.typed"] + +[tool.setuptools_scm] +version_file = "checkdeps/_version.py" + +[tool.coverage.run] +branch = true +parallel = true +source = ["checkdeps", "tests"] + +[tool.coverage.report] +fail_under = 70 +precision = 1 +show_missing = true +skip_covered = true + +[tool.pytest.ini_options] +addopts = "-ra" +testpaths = ["tests"] + +[tool.mypy] +ignore_missing_imports = true + +[tool.ruff] +line-length = 88 +target-version = "py310" + +[tool.ruff.lint] +select = [ + "E4", + "E7", + "E9", + "F", + "I", # isort +] + +[tool.ruff.lint.isort] +order-by-type = false + +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "PLR2004", # Magic value used instead of constant (only in tests) +] diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e69de29