Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: always use uv for dependency management #265

Merged
merged 5 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
tags:
- "v*.*.*"
env:
UV_SYSTEM_PYTHON: true
jobs:
default:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM python:3

ENV UV_SYSTEM_PYTHON=true

RUN apt-get update && apt-get install -y make

WORKDIR /sdk
Expand Down
30 changes: 19 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ rsconnect-python
ruff
setuptools
setuptools-scm
uv
16 changes: 4 additions & 12 deletions vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ENV ?= dev

IMAGE_TAG ?= $(NAME):latest

NAME := posit-sdk-py
NAME := posit-sdk

ifeq ($(ENV), prod)
NETLIFY_ARGS := --prod
Expand All @@ -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
PYTHON := $(shell command -v python3 2>/dev/null || command -v python)

SHELL := /bin/bash

QUARTO ?= quarto

QUARTODOC ?= quartodoc

UV := uv
Loading