Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.12"
run: uv python install 3.12
- name: Install dependencies
run: uv sync
- name: Lint with ruff
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install .
pip install -r requirements-pytest.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
uv run ruff check .
uv run ruff format --check .
- name: Type check with ty
continue-on-error: true
run: uv run ty check
- name: Test with pytest
run: |
pytest
uv run pytest
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ __pycache__/
*.py[cod]
*$py.class

AGENTS.md

# C extensions
*.so

Expand Down Expand Up @@ -143,6 +145,9 @@ venv.bak/
.dmypy.json
dmypy.json

# ruff
.ruff_cache/

# Pyre type checker
.pyre/

Expand All @@ -165,6 +170,9 @@ cython_debug/
# Nextflow files
.nextflow/
*.nextflow.log*

# Standalone tools (separate git repos)
tools/
workflows/work/
*work/

Expand All @@ -184,3 +192,8 @@ workflows/work/

# Temp code file
draft.py

# Exculde subject data folders (symlinks)
sub-*

.python-version
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.8
hooks:
- id: ruff-format
- id: ruff
args: [--fix]
- repo: local
hooks:
- id: ty
name: ty (type check)
entry: bash -c 'uv run --frozen ty check || true'
language: system
types: [python]
files: ^linumpy/
pass_filenames: false
# Non-blocking (advisory) until the existing error baseline is resolved.
# Switch entry to just "uv run ty check" once errors reach zero.
verbose: true
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM python:3.12

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /linumpy/

ENV PYTHONDONTWRITEBYTECODE=1
Expand All @@ -14,11 +16,8 @@ RUN apt-get update && apt-get install -y \
zip \
&& rm -rf /var/lib/apt/lists/*

# Upgrade pip, setuptools and wheel
RUN pip install --upgrade pip setuptools wheel build

# Install with verbose output
# Install with uv
COPY linumpy ./linumpy
COPY scripts ./scripts
COPY pyproject.toml requirements.txt README.md setup.py ./
RUN pip install --no-cache-dir -v -e .
COPY pyproject.toml uv.lock README.md .python-version ./
RUN uv sync --frozen --no-dev
14 changes: 7 additions & 7 deletions linumpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Configure thread limits FIRST, before any numerical libraries are imported
import os as _os

from linumpy._thread_config import (
configure_thread_limits,
apply_threadpool_limits,
configure_all_libraries,
configure_sitk,
configure_thread_limits,
)

import os as _os


def get_home():
""" Set a user-writeable file-system location to put files. """
if 'LINUMPY_HOME' in _os.environ:
return _os.environ['LINUMPY_HOME']
return _os.path.join(_os.path.expanduser('~'), '.linumpy')
"""Set a user-writeable file-system location to put files."""
if "LINUMPY_HOME" in _os.environ:
return _os.environ["LINUMPY_HOME"]
return _os.path.join(_os.path.expanduser("~"), ".linumpy")


def get_root():
Expand Down
Loading
Loading