Skip to content
Merged
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
30 changes: 30 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Changes here will be overwritten by Copier
_commit: v2.2.0
_src_path: gh:lincc-frameworks/python-project-template
author_email: [email protected]
author_name: LINCC Frameworks
create_example_module: false
custom_install: custom
enforce_style:
- pylint
- black
- isort
failure_notification: []
include_benchmarks: false
include_docs: true
include_notebooks: false
mypy_type_checking: none
package_name: python_project_template
project_description: LINCC-Framework's best practices for python code organization,
testing, documentation, and automation.
project_license: BSD
project_name: python-project-template
project_organization: lincc-frameworks
python_versions:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- '3.14'
test_lowest_version: none
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
24 changes: 24 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# For explanation of this file and uses see
# https://git-scm.com/docs/gitattributes
# https://developer.lsst.io/git/git-lfs.html#using-git-lfs-enabled-repositories
# https://lincc-ppt.readthedocs.io/en/latest/practices/git-lfs.html
#
# Used by https://github.com/lsst/afwdata.git
# *.boost filter=lfs diff=lfs merge=lfs -text
# *.dat filter=lfs diff=lfs merge=lfs -text
# *.fits filter=lfs diff=lfs merge=lfs -text
# *.gz filter=lfs diff=lfs merge=lfs -text
#
# apache parquet files
# *.parq filter=lfs diff=lfs merge=lfs -text
#
# sqlite files
# *.sqlite3 filter=lfs diff=lfs merge=lfs -text
#
# gzip files
# *.gz filter=lfs diff=lfs merge=lfs -text
#
# png image files
# *.png filter=lfs diff=lfs merge=lfs -text

.git_archival.txt export-subst
37 changes: 37 additions & 0 deletions .github/workflows/pre-commit-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# This workflow runs pre-commit hooks on pushes and pull requests to main
# to enforce coding style. To ensure correct configuration, please refer to:
# https://lincc-ppt.readthedocs.io/en/latest/practices/ci_precommit.html
name: Run pre-commit hooks

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
pre-commit-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
sudo apt-get update
uv pip install --system .[dev]
if [ -f requirements.txt ]; then uv pip install --system -r requirements.txt; fi
- uses: pre-commit/[email protected]
with:
extra_args: --all-files --verbose
env:
SKIP: "check-lincc-frameworks-template-version,no-commit-to-branch,check-added-large-files,validate-pyproject,sphinx-build,pytest-check"
- uses: pre-commit-ci/[email protected]
if: failure() && github.event_name == 'pull_request' && github.event.pull_request.draft == false
5 changes: 3 additions & 2 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@main
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@main
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
Expand All @@ -34,6 +34,7 @@ jobs:
run: |
sudo apt-get update
uv pip install --system -e .[dev]
if [ -f requirements.txt ]; then uv pip install --system -r requirements.txt; fi
- name: List dependencies
run: |
pip list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: CI for Template

# This workflow will install Python dependencies, run tests and report code coverage with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Unit test and code coverage

on:
push:
Expand All @@ -15,11 +19,11 @@ jobs:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@main
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@main
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
Expand All @@ -28,6 +32,7 @@ jobs:
run: |
sudo apt-get update
uv pip install --system -e .[dev]
if [ -f requirements.txt ]; then uv pip install --system -r requirements.txt; fi
- name: Run unit tests with pytest / pytest-copie
run: |
git config --global init.defaultBranch main
Expand Down
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,18 @@ dmypy.json
# vscode
.vscode/

# dask
dask-worker-space/

# tmp directory
tmp/

# Mac OS
.DS_Store

# Airspeed Velocity performance results
_results/
_html/
_html/

# Project initialization script
.initialize_new_project.sh
26 changes: 24 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@

repos:
# Compare the local template version to the latest remote template version
# This hook should always pass. It will print a message if the local version
# is out of date.
- repo: https://github.com/lincc-frameworks/pre-commit-hooks
rev: v0.2.2
hooks:
- id: check-lincc-frameworks-template-version
name: Check template version
description: Compare current template version against latest
verbose: true
# Clear output from jupyter notebooks so that only the input cells are committed.
- repo: local
hooks:
- id: jupyter-nb-clear-output
name: Clear output from Jupyter notebooks
description: Clear output from Jupyter notebooks.
files: \.ipynb$
exclude: ^docs/pre_executed
stages: [pre-commit]
language: system
entry: jupyter nbconvert --clear-output
# Prevents committing directly branches named 'main' and 'master'.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
Expand Down Expand Up @@ -44,7 +66,7 @@ repos:
[
"-rn", # Only display messages
"-sn", # Don't display the score
"--max-line-length=120",
"--rcfile=tests/.pylintrc",
]
# Analyze the code style and report code that doesn't adhere.
- repo: https://github.com/psf/black
Expand All @@ -57,7 +79,7 @@ repos:
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.12
language_version: python3.11
# Run unit tests, verify that they pass. Note that coverage is run against
# the ./src directory here because that is what will be committed. In the
# github workflow script, the coverage is run against the installed package
Expand Down
8 changes: 5 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@

# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.10"
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand All @@ -18,5 +19,6 @@ sphinx:
python:
install:
- requirements: docs/requirements.txt
- requirements: requirements.txt
- method: pip
path: .
path: .
51 changes: 51 additions & 0 deletions .setup_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

# Bash Unofficial strict mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/)
# and (https://disconnected.systems/blog/another-bash-strict-mode/)
set -o nounset # Any uninitialized variable is an error
set -o errexit # Exit the script on the failure of any command to execute without error
set -o pipefail # Fail command pipelines on the failure of any individual step
IFS=$'\n\t' #set internal field separator to avoid iteration errors
# Trap all exits and output something helpful
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR

# This script should be run by new developers to install this package in
# editable mode and configure their local environment

echo "Checking virtual environment"
if [ "${VIRTUAL_ENV:-missing}" = "missing" ] && [ "${CONDA_PREFIX:-missing}" = "missing" ]; then
echo 'No virtual environment detected: none of $VIRTUAL_ENV or $CONDA_PREFIX is set.'
echo
echo "=== This script is going to install the project in the system python environment ==="
echo "Proceed? [y/N]"
read -r RESPONCE
if [ "${RESPONCE}" != "y" ]; then
echo "See https://lincc-ppt.readthedocs.io/ for details."
echo "Exiting."
exit 1
fi

fi

echo "Checking pip version"
MINIMUM_PIP_VERSION=22
pipversion=( $(python -m pip --version | awk '{print $2}' | sed 's/\./\n\t/g') )
if let "${pipversion[0]}<${MINIMUM_PIP_VERSION}"; then
echo "Insufficient version of pip found. Requires at least version ${MINIMUM_PIP_VERSION}."
echo "See https://lincc-ppt.readthedocs.io/ for details."
exit 1
fi

echo "Installing package and runtime dependencies in local environment"
python -m pip install -e . > /dev/null

echo "Installing developer dependencies in local environment"
python -m pip install -e .'[dev]' > /dev/null
if [ -f docs/requirements.txt ]; then python -m pip install -r docs/requirements.txt > /dev/null; fi

echo "Installing pre-commit"
pre-commit install > /dev/null

#######################################################
# Include any additional configurations below this line
#######################################################
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2025, LINCC Frameworks Team
Copyright (c) 2025, LINCC Frameworks

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
9 changes: 7 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Minimal makefile for Sphinx documentation
# Makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
Expand All @@ -8,11 +8,16 @@ SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = ../_readthedocs/

.PHONY: help clean Makefile

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile
# Cleans up files generated by the build process
clean:
rm -r "_build/doctrees"
rm -r "$(BUILDDIR)"

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Expand Down
4 changes: 3 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

sphinx
sphinx-rtd-theme>=3.0
sphinx-autoapi
sphinx-copybutton
sphinx-rtd-theme>=3.0
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[project]
name = "python-project-template"
license = "BSD-3-Clause"
Expand All @@ -6,6 +7,7 @@ readme = "README.md"
authors = [
{ name = "LINCC Frameworks", email = "[email protected]" }
]
description = "LINCC-Framework's best practices for python code organization, testing, documentation, and automation."
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand All @@ -14,16 +16,16 @@ classifiers = [
"Programming Language :: Python",
]
dynamic = ["version"]

requires-python = ">=3.9"
dependencies = [
"setuptools_scm",
"sphinx", # Used to automatically generate documentation
"sphinx-rtd-theme>=3.0", # Used to render documentation
"sphinx-copybutton",
"pyyaml-include<3.0",
]
requires-python = ">=3.9"

[project.urls]
"Source Code" = "https://github.com/lincc-frameworks/python-project-template"

# On a mac, install optional dependencies with `pip install '.[dev]'` (include the single quotes)
[project.optional-dependencies]
dev = [
"black", # Used to format code
Expand Down
Empty file added requirements.txt
Empty file.
Loading