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 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 diff --git a/Makefile b/Makefile index eda7a111..462c45bc 100644 --- a/Makefile +++ b/Makefile @@ -2,21 +2,21 @@ 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 build: - $(PYTHON) -m build + $(UV) build 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,21 +29,29 @@ cov-html: cov-xml: $(PYTHON) -m coverage xml -deps: - $(PIP) install --upgrade pip setuptools wheel -r requirements.txt -r requirements-dev.txt +deps: ensure-uv + $(UV) pip install --upgrade pip setuptools wheel -r requirements.txt -r requirements-dev.txt -dev: - $(PIP) install -e . +dev: ensure-uv + $(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: - $(PIP) install dist/*.whl +install: ensure-uv + $(UV) pip install dist/*.whl it: $(MAKE) -C ./integration @@ -55,8 +63,8 @@ lint: test: $(PYTHON) -m coverage run --source=src -m pytest tests -uninstall: - $(PIP) uninstall $(NAME) +uninstall: ensure-uv + $(UV) pip uninstall $(NAME) version: @$(PYTHON) -m setuptools_scm 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/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..7907dafe 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,20 +28,12 @@ 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 - -SHELL := /bin/bash +PYTHON := $(shell command -v python || command -v python3) QUARTO ?= quarto QUARTODOC ?= quartodoc + +SHELL := /bin/bash + +UV := uv