From fd39b4c172b2d12e67eb135eb0bb23db10abb36a Mon Sep 17 00:00:00 2001 From: Rike-Benjamin Schuppner Date: Mon, 14 Apr 2025 10:11:26 +0200 Subject: [PATCH 1/3] Add build system (for project.scripts) and pytest dev dependency --- pyproject.toml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 2b25f69..7c99243 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + [project] name = "grader" description = "a Python module and command-line utility to grade applications" @@ -23,3 +27,8 @@ grader = "grader.grader:main" [tool.aliases] test = "pytest" + +[dependency-groups] +dev = [ + "pytest", +] From 701e537926651c9c5795209ce965f1350f2e2de7 Mon Sep 17 00:00:00 2001 From: Rike-Benjamin Schuppner Date: Mon, 14 Apr 2025 10:11:40 +0200 Subject: [PATCH 2/3] Make CI use pyproject --- .github/workflows/run-tests.yml | 8 +++++--- .travis.yml | 4 ---- 2 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a6f193d..8c268f1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,9 +17,11 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: - python -m pip install pytest numpy + - name: Install package and test dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest + python -m pip install . - name: Test with pytest run: pytest -v diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 14db1dc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: python -python: - - "3.6" -script: pytest From 858a57365dbb2a42621c75669362d1c42595f122 Mon Sep 17 00:00:00 2001 From: Rike-Benjamin Schuppner Date: Mon, 14 Apr 2025 10:24:41 +0200 Subject: [PATCH 3/3] Take version from grader/__init__.py and remove the git revision stuff --- grader/__init__.py | 35 +---------------------------------- pyproject.toml | 5 ++++- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/grader/__init__.py b/grader/__init__.py index ef1e246..67f2e1a 100644 --- a/grader/__init__.py +++ b/grader/__init__.py @@ -1,39 +1,6 @@ -# -*- coding: utf-8 -*- """ grader: a Python module and command-line utility to grade applications. """ -import os -# current dir -CWD = os.path.abspath(os.path.dirname(__file__)) +__version__ = '0.1' -__name__ = 'grader' -__description__ = 'a Python module and command-line utility to grade applications' -__version__ = '0.1' -__url__ = 'https://github.com/ASPP/grader' -__author__ = 'grader contributor' -__license__ = 'GPLv3+' - - -def revision(): - # get the git SHA if we are in a git repo (only useful for devs) - import subprocess - - # try two options for getting the git revision - # - nice version with tags - # - plain SHA - for cmd in ('git describe --tags --dirty=+'), ('git rev-parse HEAD'): - try: - proc = subprocess.check_output(cmd.split(), cwd=CWD, - stderr=subprocess.PIPE, universal_newlines=True) - revision = proc.strip() - except Exception: - # ok, don't bother - revision = '' - return revision - - -# have a way to test from python -def test(): - import pytest - pytest.main([CWD,]) diff --git a/pyproject.toml b/pyproject.toml index 7c99243..f8936e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,10 +2,12 @@ requires = ["hatchling"] build-backend = "hatchling.build" +[tool.hatch.version] +path = "grader/__init__.py" + [project] name = "grader" description = "a Python module and command-line utility to grade applications" -version = "0.1" authors = [{name = "Grader contributors"}] keywords = ["grading applications"] license = "GPL-3.0-or-later" @@ -17,6 +19,7 @@ classifiers = [ 'Development Status :: 3 - Alpha', urls = {Homepage = "https://github.com/ASPP/grader"} requires-python = ">= 3.10" dependencies = ['numpy',] +dynamic = ["version",] [project.readme] file = "README.md"