Skip to content

Commit c0c8d7a

Browse files
committed
Migrate to uv and other 2026-03 devops conventions
Why these changes are being introduced: This repository required an updated from pipenv to uv and/or a handful of python project updated conventions. How this addresses that need: * Migrate dependencies from Pipfile/Pipfile.lock to pyproject.toml with uv * Delete Pipfile and Pipfile.lock * Remove black, replace with ruff format * Update Makefile: pipenv run to uv run, consolidated lint/lint-fix/security targets, pre-push hooks * Replace .pre-commit-config.yaml: default_stages pre-push, ruff-format with --diff, ruff-check without --fix, mypy with broader exclude * Update CI workflow: on push to on pull_request with paths-ignore, add permissions read-all, use python-uv-shared-* workflows * Update README: pipenv references replaced with uv * Use importlib.metadata for dynamic __version__ instead of hardcoded string * Bump project version to 4.0.0 Side effects of this change: * Pre-commit hooks now fire on push instead of commit * Linting hooks no longer auto-fix code; run make lint-fix manually Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/TIMX-600
1 parent 4cf98a4 commit c0c8d7a

18 files changed

Lines changed: 1958 additions & 2306 deletions

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: CI
2-
on: push
2+
permissions: read-all
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '.github/**'
37
jobs:
48
test:
5-
uses: mitlibraries/.github/.github/workflows/python-shared-test.yml@main
9+
uses: mitlibraries/.github/.github/workflows/python-uv-shared-test.yml@main
610
lint:
7-
uses: mitlibraries/.github/.github/workflows/python-shared-lint.yml@main
11+
uses: mitlibraries/.github/.github/workflows/python-uv-shared-lint.yml@main

.pre-commit-config.yaml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
default_language_version:
22
python: python3.12
3+
default_stages:
4+
- pre-push
35
repos:
46
- repo: local
57
hooks:
6-
- id: black-apply
7-
name: black-apply
8-
entry: pipenv run black
8+
- id: ruff-format
9+
name: ruff-format
10+
entry: uv run ruff format --diff
911
language: system
1012
pass_filenames: true
11-
types: ["python"]
13+
types: [ "python" ]
14+
1215
- id: mypy
1316
name: mypy
14-
entry: pipenv run mypy
17+
entry: uv run mypy
1518
language: system
1619
pass_filenames: true
17-
types: ["python"]
18-
exclude: "tests/"
19-
- id: ruff-apply
20-
name: ruff-apply
21-
entry: pipenv run ruff check --fix
20+
types: [ "python" ]
21+
exclude: "(tests/|output/|migrations/)"
22+
23+
- id: ruff-check
24+
name: ruff-check
25+
entry: uv run ruff check
2226
language: system
2327
pass_filenames: true
24-
types: ["python"]
25-
- id: pip-audit
26-
name: pip-audit
27-
entry: pipenv run pip-audit
28-
language: system
29-
pass_filenames: false
28+
types: [ "python" ]

Makefile

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,60 @@ help: # Preview Makefile commands
77
@awk 'BEGIN { FS = ":.*#"; print "Usage: make <target>\n\nTargets:" } \
88
/^[-_[:alpha:]]+:.?*#/ { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST)
99

10-
#######################
11-
# Dependency commands
12-
#######################
10+
# ensure OS binaries aren't called if naming conflict with Make recipes
11+
.PHONY: help install venv update test coveralls lint lint-fix security minio-start
1312

14-
install: # Install Python dependencies
15-
pipenv install --dev
16-
pipenv run pre-commit install
13+
##############################################
14+
# Python Environment and Dependency commands
15+
##############################################
1716

18-
update: install # Update Python dependencies
19-
pipenv clean
20-
pipenv update --dev
17+
install: .venv .git/hooks/pre-commit .git/hooks/pre-push # Install Python dependencies and create virtual environment if not exists
18+
uv sync --dev
19+
20+
.venv: # Creates virtual environment if not found
21+
@echo "Creating virtual environment at .venv..."
22+
uv venv .venv
23+
24+
.git/hooks/pre-commit: # Sets up pre-commit commit hooks if not setup
25+
@echo "Installing pre-commit commit hooks..."
26+
uv run pre-commit install --hook-type pre-commit
27+
28+
.git/hooks/pre-push: # Sets up pre-commit push hooks if not setup
29+
@echo "Installing pre-commit push hooks..."
30+
uv run pre-commit install --hook-type pre-push
31+
32+
venv: .venv # Create the Python virtual environment
33+
34+
update: # Update Python dependencies
35+
uv lock --upgrade
36+
uv sync --dev
2137

2238
######################
2339
# Unit test commands
2440
######################
2541

2642
test: # Run tests and print a coverage report
27-
pipenv run coverage run --source=timdex_dataset_api -m pytest -vv
28-
pipenv run coverage report -m
43+
uv run coverage run --source=timdex_dataset_api -m pytest -vv
44+
uv run coverage report -m
2945

3046
coveralls: test # Write coverage data to an LCOV report
31-
pipenv run coverage lcov -o ./coverage/lcov.info
47+
uv run coverage lcov -o ./coverage/lcov.info
3248

3349
####################################
34-
# Code quality and safety commands
50+
# Code linting and formatting
3551
####################################
3652

37-
lint: black mypy ruff safety # Run linters
38-
39-
black: # Run 'black' linter and print a preview of suggested changes
40-
pipenv run black --check --diff .
41-
42-
mypy: # Run 'mypy' linter
43-
pipenv run mypy .
44-
45-
ruff: # Run 'ruff' linter and print a preview of errors
46-
pipenv run ruff check .
47-
48-
safety: # Check for security vulnerabilities and verify Pipfile.lock is up-to-date
49-
pipenv run pip-audit
50-
pipenv verify
51-
52-
lint-apply: black-apply ruff-apply # Apply changes with 'black' and resolve 'fixable errors' with 'ruff'
53-
54-
black-apply: # Apply changes with 'black'
55-
pipenv run black .
53+
lint: # Run linting, alerts only, no code changes
54+
uv run ruff format --diff
55+
uv run mypy .
56+
uv run ruff check .
5657

57-
ruff-apply: # Resolve 'fixable errors' with 'ruff'
58-
pipenv run ruff check --fix .
58+
lint-fix: # Run linting, auto fix behaviors where supported
59+
uv run ruff format .
60+
uv run ruff check --fix .
5961

62+
security: # Run security / vulnerability checks
63+
uv run pip-audit
6064

6165
######################
6266
# Minio S3 Instance
@@ -69,4 +73,4 @@ minio-start:
6973
-v $(MINIO_DATA):/data \
7074
-e "MINIO_ROOT_USER=$(MINIO_USERNAME)" \
7175
-e "MINIO_ROOT_PASSWORD=$(MINIO_PASSWORD)" \
72-
quay.io/minio/minio server /data --console-address ":9001"
76+
quay.io/minio/minio server /data --console-address ":9001"

Pipfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)