From 053873b4bea285edf1ada337856720c2982341c1 Mon Sep 17 00:00:00 2001 From: Linus Nilsson Date: Thu, 12 Mar 2026 00:27:14 +0100 Subject: [PATCH 1/3] chore: setup --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++++ .gitignore | 4 ++++ .vscode/settings.json | 7 +++++++ pymath/__init__.py | 0 pymath/arithmetic.py | 0 pyproject.toml | 28 ++++++++++++++++++++++++++++ setup | 27 +++++++++++++++++++++++++++ test/__init__.py | 0 test/test_arithmetic.py | 0 9 files changed, 103 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .vscode/settings.json create mode 100644 pymath/__init__.py create mode 100644 pymath/arithmetic.py create mode 100644 pyproject.toml create mode 100644 setup create mode 100644 test/__init__.py create mode 100644 test/test_arithmetic.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2ff1ebb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["3.11", "3.12"] # test against multiple versions + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" # cache deps between runs = faster CI + + - name: Install dependencies + run: pip install -e ".[dev]" + + - name: Lint with ruff + run: ruff check . + + - name: Check formatting + run: ruff format --check . + + - name: Run tests with coverage + run: pytest --cov=mathlib --cov-report=term-missing \ No newline at end of file diff --git a/.gitignore b/.gitignore index b7faf40..672bc0f 100644 --- a/.gitignore +++ b/.gitignore @@ -205,3 +205,7 @@ cython_debug/ marimo/_static/ marimo/_lsp/ __marimo__/ + + +# VsCode settings +.vscode/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..303bfd6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.defaultInterpreterPath": ".venv/Scripts/python", + "editor.formatOnSave": true, + "[python]": { + "editor.defaultFormatter": "charliermarsh.ruff" + } +} \ No newline at end of file diff --git a/pymath/__init__.py b/pymath/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pymath/arithmetic.py b/pymath/arithmetic.py new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ffd8eac --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,28 @@ +[build-system] +requires = ["setuptools>=68"] +build-backend = "setuptools.backends.legacy:build" + +[project] +name = "mathlib" +version = "0.1.0" +description = "A math library built for learning" +requires-python = ">=3.11" + +[project.optional-dependencies] +dev = [ + "pytest>=8.0", + "pytest-cov", # coverage reports + "ruff", # linting + formatting (replaces flake8+black) +] + +[tool.ruff] +line-length = 88 + +[tool.ruff.lint] +select = ["E", "F", "W"] # pycodestyle + pyflakes rules + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.coverage.report] +omit = ["tests/*"] \ No newline at end of file diff --git a/setup b/setup new file mode 100644 index 0000000..9558f00 --- /dev/null +++ b/setup @@ -0,0 +1,27 @@ +# Create venv (do this once per machine) +python -m venv .venv + +# Activate — Linux/Mac +source .venv/bin/activate + +# Activate — Windows (VSCode terminal) +.venv\Scripts\activate + +# Install the project in editable mode + dev tools +pip install -e ".[dev]" +``` + +The `-e` flag means **editable install** — changes to your `mathlib/` code take effect immediately without reinstalling. + +--- + +### 4. `.gitignore` +``` +.venv/ +__pycache__/ +*.pyc +.coverage +htmlcov/ +dist/ +*.egg-info/ +.vscode/ \ No newline at end of file diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/test_arithmetic.py b/test/test_arithmetic.py new file mode 100644 index 0000000..e69de29 From 7bc75866a778f8c9175f28ed8bd33adf0507f640 Mon Sep 17 00:00:00 2001 From: Linus Nilsson Date: Thu, 12 Mar 2026 01:19:34 +0100 Subject: [PATCH 2/3] CI: fix --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ff1ebb..753bd53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [main] + branches: [main, dev] pull_request: - branches: [main] + branches: [main, dev] jobs: test: @@ -12,7 +12,7 @@ jobs: strategy: matrix: - python-version: ["3.11", "3.12"] # test against multiple versions + python-version: ["3.11", "3.12"] steps: - name: Checkout code @@ -22,7 +22,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: "pip" # cache deps between runs = faster CI + cache: "pip" - name: Install dependencies run: pip install -e ".[dev]" From 630c6aca9afd40e8c99ee706f11c54dae1d34c5a Mon Sep 17 00:00:00 2001 From: Linus Nilsson Date: Thu, 12 Mar 2026 01:28:44 +0100 Subject: [PATCH 3/3] fix: correct setuptools build backend --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ffd8eac..36e2d69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = ["setuptools>=68"] -build-backend = "setuptools.backends.legacy:build" +build-backend = "etuptools.build_meta" [project] name = "mathlib" @@ -25,4 +25,4 @@ select = ["E", "F", "W"] # pycodestyle + pyflakes rules testpaths = ["tests"] [tool.coverage.report] -omit = ["tests/*"] \ No newline at end of file +omit = ["tests/*"]