From bb59ca4b36ec0d8bf77b8e591a58309483a2c599 Mon Sep 17 00:00:00 2001 From: tdstein Date: Thu, 5 Sep 2024 10:15:17 -0400 Subject: [PATCH 1/5] build: always use uv for dependency management --- Makefile | 20 ++++++++++++++------ requirements-dev.txt | 1 + vars.mk | 15 +++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index eda7a111..62d31649 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ include vars.mk .DEFAULT_GOAL := all -.PHONY: build clean cov default deps dev docs fmt fix install it lint test uninstall version help +.PHONY: build clean cov default deps dev docs ensure-uv fmt fix install it lint test uninstall version help all: deps dev test lint build @@ -13,10 +13,10 @@ clean: $(MAKE) -C ./docs $@ $(MAKE) -C ./integration $@ rm -rf .coverage .mypy_cache .pytest_cache .ruff_cache *.egg-info build coverage.xml dist htmlcov coverage.xml + find src -name "_version.py" -exec rm -rf {} + find . -name "*.egg-info" -exec rm -rf {} + find . -name "*.pyc" -exec rm -f {} + find . -name "__pycache__" -exec rm -rf {} + - find . -name "_version.py" -exec rm -rf {} + find . -type d -empty -delete cov: @@ -29,20 +29,28 @@ cov-html: cov-xml: $(PYTHON) -m coverage xml -deps: +deps: ensure-uv $(PIP) install --upgrade pip setuptools wheel -r requirements.txt -r requirements-dev.txt -dev: +dev: ensure-uv $(PIP) install -e . docs: $(MAKE) -C ./docs +ensure-uv: + @if ! command -v uv >/dev/null 2>&1; then \ + if ! command -v pip >/dev/null 2>&1; then \ + $(PYTHON) -m ensurepip; \ + fi; \ + $(PYTHON) -m pip install uv; \ + fi + fmt: $(PYTHON) -m ruff check --fix $(PYTHON) -m ruff format . -install: +install: ensure-uv $(PIP) install dist/*.whl it: @@ -55,7 +63,7 @@ lint: test: $(PYTHON) -m coverage run --source=src -m pytest tests -uninstall: +uninstall: ensure-uv $(PIP) uninstall $(NAME) version: diff --git a/requirements-dev.txt b/requirements-dev.txt index 92cc2a3d..53e68658 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,3 +10,4 @@ rsconnect-python ruff setuptools setuptools-scm +uv diff --git a/vars.mk b/vars.mk index 26e3ac93..bee84819 100644 --- a/vars.mk +++ b/vars.mk @@ -18,7 +18,7 @@ ENV ?= dev IMAGE_TAG ?= $(NAME):latest -NAME := posit-sdk-py +NAME := posit-sdk ifeq ($(ENV), prod) NETLIFY_ARGS := --prod @@ -28,17 +28,8 @@ endif NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee -ifneq ($(shell command -v uv 2>/dev/null),) -PYTHON := python -else -PYTHON := python3 -endif - -ifneq ($(shell command -v uv 2>/dev/null),) -PIP := uv pip -else -PIP := pip3 -endif +PYTHON := $(shell command -v python3 2>/dev/null || command -v python) +PIP = uv pip SHELL := /bin/bash From 1d9e5347a9167b40dd419a40eb076f128b5eac5c Mon Sep 17 00:00:00 2001 From: tdstein Date: Thu, 5 Sep 2024 10:46:53 -0400 Subject: [PATCH 2/5] ci: set env UV_SYSTEM_PYTHON=true --- .github/workflows/ci.yaml | 2 ++ .github/workflows/coverage.yaml | 2 ++ .github/workflows/release.yaml | 2 ++ .github/workflows/site.yaml | 2 ++ 4 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 650ed9dd..a89c6ba1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,6 +4,8 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + UV_SYSTEM_PYTHON: true jobs: lint: runs-on: ubuntu-latest diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index d7338ad4..7310e6fd 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -4,6 +4,8 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + UV_SYSTEM_PYTHON: true jobs: cov: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3ceb385b..6aef2b91 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,6 +3,8 @@ on: push: tags: - "v*.*.*" +env: + UV_SYSTEM_PYTHON: true jobs: default: runs-on: ubuntu-latest diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 23e90177..bc91aa28 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -4,6 +4,8 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + UV_SYSTEM_PYTHON: true jobs: preview: runs-on: ubuntu-latest From 1004582ad9c323deda7d258eb66312547597f098 Mon Sep 17 00:00:00 2001 From: tdstein Date: Thu, 5 Sep 2024 10:51:25 -0400 Subject: [PATCH 3/5] build: set env UV_SYSTEM_PYTHON=true --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 99170d9d..a2014369 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM python:3 +ENV UV_SYSTEM_PYTHON=true + RUN apt-get update && apt-get install -y make WORKDIR /sdk From e54e32f79c1952e2edc64b81ddf94b76040af9a6 Mon Sep 17 00:00:00 2001 From: tdstein Date: Mon, 9 Sep 2024 09:54:19 -0400 Subject: [PATCH 4/5] build: use uv build --- Makefile | 12 ++++++------ vars.mk | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 62d31649..462c45bc 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ include vars.mk all: deps dev test lint build build: - $(PYTHON) -m build + $(UV) build clean: $(MAKE) -C ./docs $@ @@ -30,16 +30,16 @@ cov-xml: $(PYTHON) -m coverage xml deps: ensure-uv - $(PIP) install --upgrade pip setuptools wheel -r requirements.txt -r requirements-dev.txt + $(UV) pip install --upgrade pip setuptools wheel -r requirements.txt -r requirements-dev.txt dev: ensure-uv - $(PIP) install -e . + $(UV) pip install -e . docs: $(MAKE) -C ./docs ensure-uv: - @if ! command -v uv >/dev/null 2>&1; then \ + @if ! command -v $(UV) >/dev/null 2>&1; then \ if ! command -v pip >/dev/null 2>&1; then \ $(PYTHON) -m ensurepip; \ fi; \ @@ -51,7 +51,7 @@ fmt: $(PYTHON) -m ruff format . install: ensure-uv - $(PIP) install dist/*.whl + $(UV) pip install dist/*.whl it: $(MAKE) -C ./integration @@ -64,7 +64,7 @@ test: $(PYTHON) -m coverage run --source=src -m pytest tests uninstall: ensure-uv - $(PIP) uninstall $(NAME) + $(UV) pip uninstall $(NAME) version: @$(PYTHON) -m setuptools_scm diff --git a/vars.mk b/vars.mk index bee84819..11399bb0 100644 --- a/vars.mk +++ b/vars.mk @@ -29,10 +29,11 @@ endif NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee PYTHON := $(shell command -v python3 2>/dev/null || command -v python) -PIP = uv pip SHELL := /bin/bash QUARTO ?= quarto QUARTODOC ?= quartodoc + +UV := uv From 818e1b87932d7895c20453cf237c5f40ac4182a5 Mon Sep 17 00:00:00 2001 From: tdstein Date: Mon, 9 Sep 2024 10:06:25 -0400 Subject: [PATCH 5/5] docs: use uv --- docs/Makefile | 2 +- vars.mk | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index 086f8c63..fdc04a79 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -28,7 +28,7 @@ clean: find . -type d -empty -delete deps: - $(PIP) install --upgrade pip -r requirements-site.txt + $(UV) pip install --upgrade pip -r requirements-site.txt $(QUARTO) add --no-prompt posit-dev/product-doc-theme@v4.0.2 $(QUARTO) add --no-prompt machow/quartodoc diff --git a/vars.mk b/vars.mk index 11399bb0..7907dafe 100644 --- a/vars.mk +++ b/vars.mk @@ -28,12 +28,12 @@ endif NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee -PYTHON := $(shell command -v python3 2>/dev/null || command -v python) - -SHELL := /bin/bash +PYTHON := $(shell command -v python || command -v python3) QUARTO ?= quarto QUARTODOC ?= quartodoc +SHELL := /bin/bash + UV := uv