Skip to content

Commit 34c6f59

Browse files
authored
Merge pull request #20 from RolnickLab/update-makefile-and-default-to-uv
Update makefile and make `uv` project default
2 parents 0434d13 + f4ae7c9 commit 34c6f59

45 files changed

Lines changed: 7842 additions & 8238 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ jobs:
1919
with:
2020
python-version: '3.11'
2121

22-
- name: Install Poetry
22+
- name: Install UV
2323
run: |
24-
pip install poetry
24+
make uv-install-venv
2525
26-
- name: Cache Poetry virtualenv and dependencies
26+
- name: Cache UV virtualenv and dependencies
2727
uses: actions/cache@v4
2828
with:
2929
path: |
30-
~/.cache/pypoetry
30+
~/.cache/uv
3131
~/.cache/pip
32-
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
32+
key: uv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
3333
restore-keys: |
34-
poetry-${{ runner.os }}-
34+
uv-${{ runner.os }}-
3535
3636
- name: Install dependencies
3737
run: |

.github/workflows/pre-commit.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ jobs:
1919
with:
2020
python-version: '3.11'
2121

22-
- name: Install Poetry
22+
- name: Install UV
2323
run: |
24-
pip install poetry
24+
make uv-install-venv
2525
26-
- name: Cache Poetry virtualenv and dependencies
26+
- name: Cache UV virtualenv and dependencies
2727
uses: actions/cache@v4
2828
with:
2929
path: |
30-
~/.cache/pypoetry
30+
~/.cache/uv
3131
~/.cache/pip
32-
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
32+
key: uv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
3333
restore-keys: |
34-
poetry-${{ runner.os }}-
34+
uv-${{ runner.os }}-
3535
3636
- name: Cache pre-commit
3737
uses: actions/cache@v4

.github/workflows/publish-gh-pages.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,24 @@ jobs:
2727
with:
2828
python-version: '3.11'
2929

30-
- name: Install Poetry
30+
- name: Install UV
3131
run: |
32-
pip install poetry
32+
make uv-install-venv
3333
34-
- name: Cache Poetry virtualenv and dependencies
34+
- name: Cache UV virtualenv and dependencies
3535
uses: actions/cache@v4
3636
with:
3737
path: |
38-
~/.cache/pypoetry
38+
~/.cache/uv
3939
~/.cache/pip
40-
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
40+
key: uv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
4141
restore-keys: |
42-
poetry-${{ runner.os }}-
42+
uv-${{ runner.os }}-
4343
4444
- name: Install dependencies
4545
run: |
46-
make install
46+
make install-dev
47+
make install-docs
4748
4849
- name: Run mkdocs deploy
4950
run: |

.github/workflows/test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ jobs:
1919
with:
2020
python-version: '3.11'
2121

22-
- name: Install Poetry
22+
- name: Install UV
2323
run: |
24-
pip install poetry
24+
make uv-install-venv
2525
26-
- name: Cache Poetry virtualenv and dependencies
26+
- name: Cache UV virtualenv and dependencies
2727
uses: actions/cache@v4
2828
with:
2929
path: |
30-
~/.cache/pypoetry
30+
~/.cache/uv
3131
~/.cache/pip
32-
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
32+
key: uv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
3333
restore-keys: |
34-
poetry-${{ runner.os }}-
34+
uv-${{ runner.os }}-
3535
3636
- name: Install dependencies
3737
run: |

.make/.bumpversion.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.bumpversion]
2-
current_version = "0.7.1"
2+
current_version = "1.0.0"
33
commit = true
44
message = "Makefile version {new_version} released."
55
tag = true

.make/CHANGES_MAKEFILE.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,46 @@
44

55
______________________________________________________________________
66

7-
<!-- (New changes here in list form) -->
7+
- Fix test targets
8+
- Move `docs` and `lab` dependency groups as optional groups `[extras]`
9+
- Add `test-notebooks` target to facilitate running tests using notebooks through the `nbval` library
10+
- Add configurable `VENV_PATH` to facilitate using virtual environment created outside of the repository
811

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

1114
______________________________________________________________________
1215

13-
<!-- (New changes here in list form) -->
16+
- Add auto-initialization script and corresponding makefile targets
17+
18+
## [1.1.0](https://github.com/RolnickLab/lab-advanced-template/tree/makefile-1.1.0) (2026-01-20)
19+
20+
______________________________________________________________________
21+
22+
- Add MkDocs dependencies and skeleton structure for MkDocs pages
23+
- Add `docs` makefile targets
24+
- Refactor base package to `src/core` instead of `src/` and improve package structure to follow current python best practices
25+
- Improve and fix bugs/typos from the conda, poetry and uv targets
26+
27+
## [1.0.0](https://github.com/RolnickLab/lab-advanced-template/tree/makefile-1.0.0) (2025-11-21)
28+
29+
______________________________________________________________________
30+
31+
- BREAKING CHANGE - Make default version of project use `uv`
32+
- Consists of a rework of the `pyproject.toml` file that no longer works with `poetry<2.0.0`
33+
- Added `poetry python install` functionality to the makefike
34+
- Refactored `conda` installation to use miniforge and micromamba instead of miniconda
35+
- Improve determination of build tool and environment by makefile to make experience simpler
36+
- Refactor target group enablement via `Makefile.variables` file instead of commenting
37+
out lines in `Makefile`
38+
- Add link checker to `pre-commit`
39+
- Refactor tests to reduce duplication
40+
- Remove target that installed `poetry` inside conda environment
41+
- Update documentation and README.md
42+
- Convert to Google docstring format
43+
44+
## [0.7.1](https://github.com/RolnickLab/lab-advanced-template/tree/makefile-0.7.1) (2025-09-17)
45+
46+
______________________________________________________________________
1447

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

.make/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# files to include.
1111
########################################################################################
1212
PROJECT_PATH := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))
13-
MAKEFILE_VERSION := 0.7.1
13+
MAKEFILE_VERSION := 1.2.0
1414
BUMP_TOOL := bump-my-version
1515
BUMP_CONFIG_FILE := $(PROJECT_PATH).bumpversion.toml
1616

.make/README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,41 @@
22

33
This folder contains the base makefile targets.
44

5-
It should not be modified outside the [Template's repository](https://github.com/RolnickLab/lab-advanced-template).
5+
The project uses a Makefile to automate most operations. If `make` is available on your
6+
machine there's a good chance this will work.
7+
8+
## The Makefiles
9+
10+
The following Makefile files should not be modified, but can be consulted:
11+
12+
- [Makefile](../Makefile) : Entrypoint of the makefile utilities.
13+
- [base.make](base.make) : Shared utilities, project agnostic.
14+
- [conda.make](conda.make) : Conda related targets.
15+
- [lint.make](lint.make) : Linting and formatting related targets.
16+
- [poetry.make](poetry.make) : Poetry related targets.
17+
- [manager.make](manager.make) : Manages which group to include based on Makefile variables.
18+
- [test.make](test.make) : Test related targets.
19+
- [uv.make](uv.make) : UV related targets.
20+
21+
The following Makefile files are project or user specific and can be modified by
22+
project users:
23+
24+
- [Makefile.variables](../Makefile.variables) : Shared project variables.
25+
- In this file, you can activate or deactivate target groups, and configure
26+
settings according to your project's needs.
27+
- [Makefile.targets](../Makefile.targets) : Shared project targets.
28+
- [Makefile.private](../Makefile.private.example) : User specific variables and targets.
29+
- This file is ignored by git and should never be committed, as it can also contain
30+
secrets. You can override project configurations for local requirements, as
31+
well as personal preferences.
32+
- You can create your own version locally by copying from
33+
[Makefile.private.example](../Makefile.private.example)
34+
35+
## Basic Information
36+
37+
The different targets and their description can be examined by executing the command:
38+
39+
![](img/make_targets.png)
640

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

28-
They should never be run in a project implemented from the template, as they could cause
29-
side effects to your project.
62+
They should **never** be run in a project implemented from the template, as they could
63+
cause side effects to your project.

.make/base.make

Lines changed: 97 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
# Please report bugs to francis.pelletier@mila.quebec
1212
########################################################################################
1313

14+
.DEFAULT_GOAL := help
15+
1416
# Basic variables
1517
PROJECT_PATH := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))
1618
MAKEFILE_NAME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
1719
SHELL := /usr/bin/env bash
1820
BUMP_TOOL := bump-my-version
19-
MAKEFILE_VERSION := 0.7.1
21+
MAKEFILE_VERSION := 1.2.0
2022
DOCKER_COMPOSE ?= docker compose
2123
AUTO_INSTALL ?=
2224

@@ -26,24 +28,102 @@ CONDA_TOOL := conda
2628
CONDA_ENVIRONMENT ?=
2729
CONDA_YES_OPTION ?=
2830

29-
# Default environment to install package
30-
# Can be overridden in Makefile.private file
31-
DEFAULT_INSTALL_ENV ?=
32-
DEFAULT_POETRY_INSTALL_ENV ?=
33-
34-
# Colors
35-
_SECTION := \033[1m\033[34m
36-
_TARGET := \033[36m
37-
_NORMAL := \033[0m
38-
39-
.DEFAULT_GOAL := help
31+
# Default variables (if Makefile.variables is missing)
32+
APP_VERSION := 0.0.0
33+
APPLICATION_NAME := src
34+
PYTHON_VERSION := 3.12
35+
DEFAULT_INSTALL_ENV := uv
36+
DEFAULT_BUILD_TOOL := uv
37+
TARGET_GROUPS := lint,test
38+
CONDA_ENVIRONMENT := src-env
39+
40+
# Targets Colors
41+
_ESC := $(shell printf '\033')
42+
_SECTION := $(_ESC)[1m\033[34m
43+
_BLUE := $(_ESC)[1m\033[34m
44+
_TARGET := $(_ESC)[1m\033[36m
45+
_CYAN := $(_ESC)[36m
46+
_NORMAL := $(_ESC)[0m
47+
_WARNING := $(_ESC)[1;39;41m
48+
49+
WARNING := $(_WARNING) -- WARNING -- $(_NORMAL)
4050

4151
# Project and Private variables and targets import to override variables for local
4252
# This is to make sure, sometimes the Makefile includes don't work.
4353
-include Makefile.variables
4454
-include Makefile.private
55+
56+
contains = $(if $(findstring $(1),$(2)),true)
57+
not_in = $(if $(findstring $(1),$(2)),,true)
58+
59+
INSTALL_ENV_IS_VENV := $(call contains,venv,$(DEFAULT_INSTALL_ENV))
60+
INSTALL_ENV_IS_UV := $(call contains,uv,$(DEFAULT_INSTALL_ENV))
61+
INSTALL_ENV_IS_POETRY := $(call contains,poetry,$(DEFAULT_INSTALL_ENV))
62+
INSTALL_ENV_IS_CONDA := $(call contains,conda,$(DEFAULT_INSTALL_ENV))
63+
64+
BUILD_TOOL_IS_UV := $(call contains,uv,$(DEFAULT_BUILD_TOOL))
65+
BUILD_TOOL_IS_POETRY := $(call contains,poetry,$(DEFAULT_BUILD_TOOL))
66+
67+
CONDA_CONFLICT := $(and $(INSTALL_ENV_IS_CONDA),$(BUILD_TOOL_IS_UV))
68+
UV_CONFLICT := $(and $(INSTALL_ENV_IS_POETRY),$(BUILD_TOOL_IS_UV))
69+
POETRY_CONFLICT := $(and $(INSTALL_ENV_IS_UV),$(BUILD_TOOL_IS_POETRY))
70+
PLEASE_FIX_CONFLICT_MSG := Please fix the conflict in your [Makefile.variables] and/or [Makefile.private] file(s)
71+
72+
IS_MAKEFILE_VARIABLES_MISSING := $(call not_in,Makefile.variables,$(MAKEFILE_LIST))
73+
PLEASE_FIX_MISSING_FILE := Please consider adding a [Makefile.variables] file to your project - See lab-advanced-template for more info
74+
75+
TAG_WARN := $(_WARNING) -- WARNING -- $(_NORMAL)
76+
77+
check_configs = $(if $($(1)), \
78+
$(info ) \
79+
$(info $(TAG_WARN) $(2)) \
80+
$(info $(PLEASE_FIX_CONFLICT_MSG)) \
81+
$(info ) \
82+
)
83+
84+
check_files = $(if $($(1)), \
85+
$(info ) \
86+
$(info $(TAG_WARN) $(2)) \
87+
$(info $(PLEASE_FIX_MISSING_FILE)) \
88+
$(info ) \
89+
)
90+
91+
# Config Checks
92+
# These run immediately when you type 'make'
93+
$(call check_configs,CONDA_CONFLICT,'conda' environment is enabled while using 'uv')
94+
$(call check_configs,UV_CONFLICT,'poetry' environment is enabled while using 'uv')
95+
$(call check_configs,POETRY_CONFLICT,'uv' environment is enabled while using 'poetry')
96+
$(call check_files,IS_MAKEFILE_VARIABLES_MISSING,The configuration file 'Makefile.variables' is missing - Using default values)
97+
98+
99+
## -- Initialization targets ---------------------------------------------------------------------------------------- ##
100+
.PHONY: project-init
101+
project-init: ## Initialize the project from the template - Only run once!
102+
@python3 $(PROJECT_PATH).make/scripts/auto_init_script.py
103+
104+
.PHONY: project-init-dry-run
105+
project-init-dry: ## Test run: no changes will be made - Initialize the project from the template
106+
@python3 $(PROJECT_PATH).make/scripts/auto_init_script.py --dry
107+
108+
45109
## -- Informative targets ------------------------------------------------------------------------------------------- ##
46110

111+
.PHONY: info
112+
info: ## Get project configuration info
113+
@echo ""
114+
@echo -e "$(_BLUE)--- Configuration Status ---$(_NORMAL)"
115+
@echo ""
116+
@echo -e "$(_CYAN)Application Name$(_NORMAL) : $(APPLICATION_NAME)"
117+
@echo -e "$(_CYAN)Application version$(_NORMAL) : $(APP_VERSION)"
118+
@echo -e "$(_CYAN)Application Root$(_NORMAL) : [$(PROJECT_PATH)]"
119+
@echo -e "$(_CYAN)Application package$(_NORMAL) : [$(PROJECT_PATH)src/$(APPLICATION_NAME)]"
120+
@echo -e "$(_CYAN)Environment manager$(_NORMAL) : $(DEFAULT_INSTALL_ENV)"
121+
@echo -e "$(_CYAN)Build tool$(_NORMAL) : $(DEFAULT_BUILD_TOOL)"
122+
@echo -e "$(_CYAN)Python version$(_NORMAL) : $(PYTHON_VERSION)"
123+
@echo -e "$(_CYAN)Active makefile targets$(_NORMAL) : [$(TARGET_GROUPS)]"
124+
@echo -e "$(_CYAN)Makefile version$(_NORMAL) : $(MAKEFILE_VERSION)"
125+
126+
47127
.PHONY: all
48128
all: help
49129

@@ -78,7 +158,8 @@ targets: help
78158

79159
.PHONY: version
80160
version: ## display current version
81-
@echo "version: $(APP_VERSION)"
161+
@echo -e "$(_CYAN)Application version$(_NORMAL) : $(APP_VERSION)"
162+
@echo -e "$(_CYAN)Makefile version$(_NORMAL) : $(MAKEFILE_VERSION)"
82163

83164
## -- Virtualenv targets -------------------------------------------------------------------------------------------- ##
84165

@@ -138,15 +219,15 @@ dry: ## Add the dry target for a preview of changes; ex. 'make bump-major dry'
138219

139220
.PHONY: bump-major
140221
bump-major: ## Bump application major version <X.0.0>
141-
$(BUMP_TOOL) bump $(BUMP_ARGS) major
222+
@$(ENV_COMMAND_TOOL) $(BUMP_TOOL) bump $(BUMP_ARGS) major
142223

143224
.PHONY: bump-minor
144225
bump-minor: ## Bump application minor version <0.X.0>
145-
$(BUMP_TOOL) bump $(BUMP_ARGS) minor
226+
@$(ENV_COMMAND_TOOL) $(BUMP_TOOL) bump $(BUMP_ARGS) minor
146227

147228
.PHONY: bump-patch
148229
bump-patch: ## Bump application patch version <0.0.X>
149-
$(BUMP_TOOL) bump $(BUMP_ARGS) patch
230+
@$(ENV_COMMAND_TOOL) $(BUMP_TOOL) bump $(BUMP_ARGS) patch
150231

151232

152233

0 commit comments

Comments
 (0)