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
12 changes: 6 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:
with:
python-version: '3.11'

- name: Install Poetry
- name: Install UV
run: |
pip install poetry
make uv-install-venv

- name: Cache Poetry virtualenv and dependencies
- name: Cache UV virtualenv and dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/pypoetry
~/.cache/uv
~/.cache/pip
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
key: uv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ runner.os }}-
uv-${{ runner.os }}-

- name: Install dependencies
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:
with:
python-version: '3.11'

- name: Install Poetry
- name: Install UV
run: |
pip install poetry
make uv-install-venv

- name: Cache Poetry virtualenv and dependencies
- name: Cache UV virtualenv and dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/pypoetry
~/.cache/uv
~/.cache/pip
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
key: uv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ runner.os }}-
uv-${{ runner.os }}-

- name: Cache pre-commit
uses: actions/cache@v4
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/publish-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,24 @@ jobs:
with:
python-version: '3.11'

- name: Install Poetry
- name: Install UV
run: |
pip install poetry
make uv-install-venv

- name: Cache Poetry virtualenv and dependencies
- name: Cache UV virtualenv and dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/pypoetry
~/.cache/uv
~/.cache/pip
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
key: uv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ runner.os }}-
uv-${{ runner.os }}-

- name: Install dependencies
run: |
make install
make install-dev
make install-docs

- name: Run mkdocs deploy
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:
with:
python-version: '3.11'

- name: Install Poetry
- name: Install UV
run: |
pip install poetry
make uv-install-venv

- name: Cache Poetry virtualenv and dependencies
- name: Cache UV virtualenv and dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/pypoetry
~/.cache/uv
~/.cache/pip
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
key: uv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ runner.os }}-
uv-${{ runner.os }}-

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .make/.bumpversion.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "0.7.1"
current_version = "1.0.0"
commit = true
message = "Makefile version {new_version} released."
tag = true
Expand Down
34 changes: 32 additions & 2 deletions .make/CHANGES_MAKEFILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,41 @@ ______________________________________________________________________

<!-- (New changes here in list form) -->

## [0.7.1](https://github.com/RolnickLab/lab-advanced-template/tree/makefile-0.7.1) (2025-09-17)
## [1.2.0](https://github.com/RolnickLab/lab-advanced-template/tree/makefile-1.2.0) (2026-01-21)

______________________________________________________________________

<!-- (New changes here in list form) -->
- Add auto-initialization script and corresponding makefile targets

## [1.1.0](https://github.com/RolnickLab/lab-advanced-template/tree/makefile-1.1.0) (2026-01-20)

______________________________________________________________________

- Add MkDocs dependencies and skeleton structure for MkDocs pages
- Add `docs` makefile targets
- Refactor base package to `src/core` instead of `src/` and improve package structure to follow current python best practices
- Improve and fix bugs/typos from the conda, poetry and uv targets

## [1.0.0](https://github.com/RolnickLab/lab-advanced-template/tree/makefile-1.0.0) (2025-11-21)

______________________________________________________________________

- BREAKING CHANGE - Make default version of project use `uv`
- Consists of a rework of the `pyproject.toml` file that no longer works with `poetry<2.0.0`
- Added `poetry python install` functionality to the makefike
- Refactored `conda` installation to use miniforge and micromamba instead of miniconda
- Improve determination of build tool and environment by makefile to make experience simpler
- Refactor target group enablement via `Makefile.variables` file instead of commenting
out lines in `Makefile`
- Add link checker to `pre-commit`
- Refactor tests to reduce duplication
- Remove target that installed `poetry` inside conda environment
- Update documentation and README.md
- Convert to Google docstring format

## [0.7.1](https://github.com/RolnickLab/lab-advanced-template/tree/makefile-0.7.1) (2025-09-17)

______________________________________________________________________

## [0.7.0](https://github.com/RolnickLab/lab-advanced-template/tree/makefile-0.7.0) (2025-09-10)

Expand Down
2 changes: 1 addition & 1 deletion .make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# files to include.
########################################################################################
PROJECT_PATH := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))
MAKEFILE_VERSION := 0.7.1
MAKEFILE_VERSION := 1.2.0
BUMP_TOOL := bump-my-version
BUMP_CONFIG_FILE := $(PROJECT_PATH).bumpversion.toml

Expand Down
40 changes: 37 additions & 3 deletions .make/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,41 @@

This folder contains the base makefile targets.

It should not be modified outside the [Template's repository](https://github.com/RolnickLab/lab-advanced-template).
The project uses a Makefile to automate most operations. If `make` is available on your
machine there's a good chance this will work.

## The Makefiles

The following Makefile files should not be modified, but can be consulted:

- [Makefile](../Makefile) : Entrypoint of the makefile utilities.
- [base.make](base.make) : Shared utilities, project agnostic.
- [conda.make](conda.make) : Conda related targets.
- [lint.make](lint.make) : Linting and formatting related targets.
- [poetry.make](poetry.make) : Poetry related targets.
- [manager.make](manager.make) : Manages which group to include based on Makefile variables.
- [test.make](test.make) : Test related targets.
- [uv.make](uv.make) : UV related targets.

The following Makefile files are project or user specific and can be modified by
project users:

- [Makefile.variables](../Makefile.variables) : Shared project variables.
- In this file, you can activate or deactivate target groups, and configure
settings according to your project's needs.
- [Makefile.targets](../Makefile.targets) : Shared project targets.
- [Makefile.private](../Makefile.private.example) : User specific variables and targets.
- This file is ignored by git and should never be committed, as it can also contain
secrets. You can override project configurations for local requirements, as
well as personal preferences.
- You can create your own version locally by copying from
[Makefile.private.example](../Makefile.private.example)

## Basic Information

The different targets and their description can be examined by executing the command:

![](img/make_targets.png)

If there is a problem with the contents of these targets, please open an
issue [here](https://github.com/RolnickLab/lab-advanced-template/issues).
Expand All @@ -25,5 +59,5 @@ essentially bash scripts to test the different makefile targets.
These should only be run when modifying the makefiles inside the
[Template's repository](https://github.com/RolnickLab/lab-advanced-template).

They should never be run in a project implemented from the template, as they could cause
side effects to your project.
They should **never** be run in a project implemented from the template, as they could
cause side effects to your project.
116 changes: 99 additions & 17 deletions .make/base.make
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
# Please report bugs to francis.pelletier@mila.quebec
########################################################################################

.DEFAULT_GOAL := help

# Basic variables
PROJECT_PATH := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))
MAKEFILE_NAME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
SHELL := /usr/bin/env bash
BUMP_TOOL := bump-my-version
MAKEFILE_VERSION := 0.7.1
MAKEFILE_VERSION := 1.2.0
DOCKER_COMPOSE ?= docker compose
AUTO_INSTALL ?=

Expand All @@ -26,24 +28,102 @@ CONDA_TOOL := conda
CONDA_ENVIRONMENT ?=
CONDA_YES_OPTION ?=

# Default environment to install package
# Can be overridden in Makefile.private file
DEFAULT_INSTALL_ENV ?=
DEFAULT_POETRY_INSTALL_ENV ?=

# Colors
_SECTION := \033[1m\033[34m
_TARGET := \033[36m
_NORMAL := \033[0m

.DEFAULT_GOAL := help
# Default variables (if Makefile.variables is missing)
APP_VERSION := 0.0.0
APPLICATION_NAME := src
PYTHON_VERSION := 3.12
DEFAULT_INSTALL_ENV := uv
DEFAULT_BUILD_TOOL := uv
TARGET_GROUPS := lint,test
CONDA_ENVIRONMENT := src-env

# Targets Colors
_ESC := $(shell printf '\033')
_SECTION := $(_ESC)[1m\033[34m
_BLUE := $(_ESC)[1m\033[34m
_TARGET := $(_ESC)[1m\033[36m
_CYAN := $(_ESC)[36m
_NORMAL := $(_ESC)[0m
_WARNING := $(_ESC)[1;39;41m

WARNING := $(_WARNING) -- WARNING -- $(_NORMAL)

# Project and Private variables and targets import to override variables for local
# This is to make sure, sometimes the Makefile includes don't work.
-include Makefile.variables
-include Makefile.private

contains = $(if $(findstring $(1),$(2)),true)
not_in = $(if $(findstring $(1),$(2)),,true)

INSTALL_ENV_IS_VENV := $(call contains,venv,$(DEFAULT_INSTALL_ENV))
INSTALL_ENV_IS_UV := $(call contains,uv,$(DEFAULT_INSTALL_ENV))
INSTALL_ENV_IS_POETRY := $(call contains,poetry,$(DEFAULT_INSTALL_ENV))
INSTALL_ENV_IS_CONDA := $(call contains,conda,$(DEFAULT_INSTALL_ENV))

BUILD_TOOL_IS_UV := $(call contains,uv,$(DEFAULT_BUILD_TOOL))
BUILD_TOOL_IS_POETRY := $(call contains,poetry,$(DEFAULT_BUILD_TOOL))

CONDA_CONFLICT := $(and $(INSTALL_ENV_IS_CONDA),$(BUILD_TOOL_IS_UV))
UV_CONFLICT := $(and $(INSTALL_ENV_IS_POETRY),$(BUILD_TOOL_IS_UV))
POETRY_CONFLICT := $(and $(INSTALL_ENV_IS_UV),$(BUILD_TOOL_IS_POETRY))
PLEASE_FIX_CONFLICT_MSG := Please fix the conflict in your [Makefile.variables] and/or [Makefile.private] file(s)

IS_MAKEFILE_VARIABLES_MISSING := $(call not_in,Makefile.variables,$(MAKEFILE_LIST))
PLEASE_FIX_MISSING_FILE := Please consider adding a [Makefile.variables] file to your project - See lab-advanced-template for more info

TAG_WARN := $(_WARNING) -- WARNING -- $(_NORMAL)

check_configs = $(if $($(1)), \
$(info ) \
$(info $(TAG_WARN) $(2)) \
$(info $(PLEASE_FIX_CONFLICT_MSG)) \
$(info ) \
)

check_files = $(if $($(1)), \
$(info ) \
$(info $(TAG_WARN) $(2)) \
$(info $(PLEASE_FIX_MISSING_FILE)) \
$(info ) \
)

# Config Checks
# These run immediately when you type 'make'
$(call check_configs,CONDA_CONFLICT,'conda' environment is enabled while using 'uv')
$(call check_configs,UV_CONFLICT,'poetry' environment is enabled while using 'uv')
$(call check_configs,POETRY_CONFLICT,'uv' environment is enabled while using 'poetry')
$(call check_files,IS_MAKEFILE_VARIABLES_MISSING,The configuration file 'Makefile.variables' is missing - Using default values)


## -- Initialization targets ---------------------------------------------------------------------------------------- ##
.PHONY: project-init
project-init: ## Initialize the project from the template - Only run once!
@python3 $(PROJECT_PATH).make/scripts/auto_init_script.py

.PHONY: project-init-dry-run
project-init-dry: ## Test run: no changes will be made - Initialize the project from the template
@python3 $(PROJECT_PATH).make/scripts/auto_init_script.py --dry


## -- Informative targets ------------------------------------------------------------------------------------------- ##

.PHONY: info
info: ## Get project configuration info
@echo ""
@echo -e "$(_BLUE)--- Configuration Status ---$(_NORMAL)"
@echo ""
@echo -e "$(_CYAN)Application Name$(_NORMAL) : $(APPLICATION_NAME)"
@echo -e "$(_CYAN)Application version$(_NORMAL) : $(APP_VERSION)"
@echo -e "$(_CYAN)Application Root$(_NORMAL) : [$(PROJECT_PATH)]"
@echo -e "$(_CYAN)Application package$(_NORMAL) : [$(PROJECT_PATH)src/$(APPLICATION_NAME)]"
@echo -e "$(_CYAN)Environment manager$(_NORMAL) : $(DEFAULT_INSTALL_ENV)"
@echo -e "$(_CYAN)Build tool$(_NORMAL) : $(DEFAULT_BUILD_TOOL)"
@echo -e "$(_CYAN)Python version$(_NORMAL) : $(PYTHON_VERSION)"
@echo -e "$(_CYAN)Active makefile targets$(_NORMAL) : [$(TARGET_GROUPS)]"
@echo -e "$(_CYAN)Makefile version$(_NORMAL) : $(MAKEFILE_VERSION)"


.PHONY: all
all: help

Expand Down Expand Up @@ -78,11 +158,13 @@ targets: help

.PHONY: version
version: ## display current version
@echo "version: $(APP_VERSION)"
@echo -e "$(_CYAN)Application version$(_NORMAL) : $(APP_VERSION)"
@echo -e "$(_CYAN)Makefile version$(_NORMAL) : $(MAKEFILE_VERSION)"

## -- Virtualenv targets -------------------------------------------------------------------------------------------- ##

VENV_PATH := $(PROJECT_PATH).venv
DEFAULT_VENV_PATH := $(PROJECT_PATH).venv
VENV_PATH := $(DEFAULT_VENV_PATH)
VENV_ACTIVATE := $(VENV_PATH)/bin/activate

.PHONY: venv-create
Expand Down Expand Up @@ -138,15 +220,15 @@ dry: ## Add the dry target for a preview of changes; ex. 'make bump-major dry'

.PHONY: bump-major
bump-major: ## Bump application major version <X.0.0>
$(BUMP_TOOL) bump $(BUMP_ARGS) major
@$(ENV_COMMAND_TOOL) $(BUMP_TOOL) bump $(BUMP_ARGS) major

.PHONY: bump-minor
bump-minor: ## Bump application minor version <0.X.0>
$(BUMP_TOOL) bump $(BUMP_ARGS) minor
@$(ENV_COMMAND_TOOL) $(BUMP_TOOL) bump $(BUMP_ARGS) minor

.PHONY: bump-patch
bump-patch: ## Bump application patch version <0.0.X>
$(BUMP_TOOL) bump $(BUMP_ARGS) patch
@$(ENV_COMMAND_TOOL) $(BUMP_TOOL) bump $(BUMP_ARGS) patch



Loading