From 798aa61f55aba3e5dad65d6c2590eb63f1a7a95c Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 14:25:00 -0400 Subject: [PATCH 01/42] Auto white space formatting --- pyproject.toml | 3 ++- src/posit/connect/paginator.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 42d418af..99a75f2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ dependencies = [ "typing-extensions" ] + [project.urls] Source = "https://github.com/posit-dev/posit-sdk-py" Issues = "https://github.com/posit-dev/posit-sdk-py/issues" @@ -72,7 +73,7 @@ select = [ # https://docs.astral.sh/ruff/rules/#isort-i # # Sort imports. - "I" + "I", ] ignore = [ # NumPy style docstring convention with noted exceptions. diff --git a/src/posit/connect/paginator.py b/src/posit/connect/paginator.py index a85c5e64..2308e42c 100644 --- a/src/posit/connect/paginator.py +++ b/src/posit/connect/paginator.py @@ -38,7 +38,7 @@ class Paginator: url (str): The URL of the paginated API endpoint. """ - def __init__(self, session: requests.Session, url: str, params = {}) -> None: + def __init__(self, session: requests.Session, url: str, params={}) -> None: self.session = session self.url = url self.params = params From bfa0bae2b7fc5f22832ab87981a684f770c6c322 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 14:25:12 -0400 Subject: [PATCH 02/42] Ignore `uv.lock` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d2f46c2a..47fab16e 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST +uv.lock # PyInstaller # Usually these files are written by a python script from a template From 39d99f2e3de8fd0de999df121a0358ab806f0c24 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 14:25:40 -0400 Subject: [PATCH 03/42] Move requirements into pyproject.toml --- pyproject.toml | 21 +++++++++++++++++---- requirements-dev.txt | 13 ------------- requirements.txt | 3 --- 3 files changed, 17 insertions(+), 20 deletions(-) delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt diff --git a/pyproject.toml b/pyproject.toml index 99a75f2d..a92b4afe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,10 +19,23 @@ classifiers = [ "Typing :: Typed", ] dynamic = ["version"] -dependencies = [ - "requests>=2.31.0,<3", - "packaging", - "typing-extensions" +dependencies = ["requests>=2.31.0,<3", "packaging", "typing-extensions"] + +[project.optional-dependencies] +dev = [ + "build", + "coverage", + "pandas", + "pre-commit", + "pyjson5", + "pyright", + "pytest", + "responses", + "rsconnect-python", + "ruff", + "setuptools", + "setuptools-scm", + "uv", ] diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 52466717..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,13 +0,0 @@ -build -coverage -pandas -pre-commit -pyjson5 -pyright -pytest -responses -rsconnect-python -ruff -setuptools -setuptools-scm -uv diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 4dc65af9..00000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -requests==2.32.2 -packaging==24.1 -typing-extensions==4.12.2 From 4f269461b59a9ee4578374239fffd23b613026bd Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 14:25:55 -0400 Subject: [PATCH 04/42] Add `VENV` to makefile vars --- vars.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/vars.mk b/vars.mk index 36cec07c..d9a7fbc9 100644 --- a/vars.mk +++ b/vars.mk @@ -18,3 +18,4 @@ PROJECT_NAME := posit-sdk # Python settings PYTHON ?= $(shell command -v python || command -v python3) UV ?= uv +VENV ?= .venv From 02bbe651c33f04e604bace33d6970f6e0e957fbc Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 14:28:17 -0400 Subject: [PATCH 05/42] Remove `deps` target in favor of consolidated `dev` target --- Makefile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 00922626..a336c34e 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ include vars.mk .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 +all: dev test lint build build: $(UV) build @@ -29,11 +29,8 @@ cov-html: cov-xml: $(PYTHON) -m coverage xml -deps: ensure-uv - $(UV) pip install --upgrade pip setuptools wheel -r requirements.txt -r requirements-dev.txt - dev: ensure-uv - $(UV) pip install -e . + $(UV) pip install -e '.[dev]' docs: $(MAKE) -C ./docs @@ -68,13 +65,12 @@ version: help: @echo "Makefile Targets" - @echo " all Run deps, dev, test, lint, and build" + @echo " all Run dev, test, lint, and build" @echo " build Build the project" @echo " clean Clean up project artifacts" @echo " cov Generate a coverage report" @echo " cov-html Generate an HTML coverage report and open it" @echo " cov-xml Generate an XML coverage report" - @echo " deps Install dependencies" @echo " dev Install the project in editable mode" @echo " docs Build the documentation" @echo " ensure-uv Ensure 'uv' is installed" From 7013adaa98f336f89ac377cebda8e9dd7c1e5cd7 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 14:30:16 -0400 Subject: [PATCH 06/42] Replace all `$(PYTHON) -m` with `$(UV) run` to force local venv * Be sure to require that UV exists so that all commands work from a fresh checkout * If `.venv` does not exist, create it when checking for UV --- Makefile | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index a336c34e..562544ac 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,11 @@ include vars.mk .DEFAULT_GOAL := all -.PHONY: build clean cov default deps dev docs ensure-uv fmt fix install it lint test uninstall version help +.PHONY: build clean cov default dev docs ensure-uv _ensure-uv-cmd _ensure-uv-venv fmt fix install it lint test uninstall version help all: dev test lint build -build: +build: ensure-uv $(UV) build clean: @@ -19,15 +19,15 @@ clean: find . -name "__pycache__" -exec rm -rf {} + find . -type d -empty -delete -cov: - $(PYTHON) -m coverage report +cov: dev + $(UV) run coverage report -cov-html: - $(PYTHON) -m coverage html +cov-html: dev + $(UV) run coverage html open htmlcov/index.html -cov-xml: - $(PYTHON) -m coverage xml +cov-xml: dev + $(UV) run coverage xml dev: ensure-uv $(UV) pip install -e '.[dev]' @@ -35,14 +35,18 @@ dev: ensure-uv docs: $(MAKE) -C ./docs -ensure-uv: +$(VENV): + $(UV) venv $(VENV) +_ensure-uv-venv: _ensure-uv-cmd $(VENV) +_ensure-uv-cmd: @if ! command -v $(UV) >/dev/null; then \ $(PYTHON) -m ensurepip && $(PYTHON) -m pip install uv; \ fi +ensure-uv: _ensure-uv-cmd _ensure-uv-venv -fmt: - $(PYTHON) -m ruff check --fix - $(PYTHON) -m ruff format +fmt: dev + $(UV) run ruff check --fix + $(UV) run ruff format install: ensure-uv $(UV) pip install dist/*.whl @@ -50,18 +54,18 @@ install: ensure-uv it: $(MAKE) -C ./integration -lint: - $(PYTHON) -m pyright - $(PYTHON) -m ruff check +lint: dev + $(UV) run pyright + $(UV) run ruff check -test: - $(PYTHON) -m coverage run --source=src -m pytest tests +test: dev + $(UV) run coverage run --source=src -m pytest tests uninstall: ensure-uv $(UV) pip uninstall $(PROJECT_NAME) -version: - @$(PYTHON) -m setuptools_scm +version: dev + @$(UV) run setuptools_scm help: @echo "Makefile Targets" From 8c2b6e050f538545f74732b108cadb080b48c8de Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 17:24:37 -0400 Subject: [PATCH 07/42] Update virtual env name --- Makefile | 10 +++++----- vars.mk | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 562544ac..ee03ba3e 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ include vars.mk all: dev test lint build -build: ensure-uv +build: dev $(UV) build clean: @@ -32,12 +32,12 @@ cov-xml: dev dev: ensure-uv $(UV) pip install -e '.[dev]' -docs: +docs: ensure-uv $(MAKE) -C ./docs -$(VENV): - $(UV) venv $(VENV) -_ensure-uv-venv: _ensure-uv-cmd $(VENV) +$(VIRTUAL_ENV): + $(UV) venv $(VIRTUAL_ENV) +_ensure-uv-venv: _ensure-uv-cmd $(VIRTUAL_ENV) _ensure-uv-cmd: @if ! command -v $(UV) >/dev/null; then \ $(PYTHON) -m ensurepip && $(PYTHON) -m pip install uv; \ diff --git a/vars.mk b/vars.mk index d9a7fbc9..0f635f4d 100644 --- a/vars.mk +++ b/vars.mk @@ -18,4 +18,5 @@ PROJECT_NAME := posit-sdk # Python settings PYTHON ?= $(shell command -v python || command -v python3) UV ?= uv -VENV ?= .venv +# uv defaults virtual environment to `$VIRTUAL_ENV` if set; otherwise .venv +VIRTUAL_ENV ?= .venv From f90be408a8294b838ee7f81a113fecb11ca30809 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 17:24:48 -0400 Subject: [PATCH 08/42] Require a uv version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ee03ba3e..79533c00 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ $(VIRTUAL_ENV): _ensure-uv-venv: _ensure-uv-cmd $(VIRTUAL_ENV) _ensure-uv-cmd: @if ! command -v $(UV) >/dev/null; then \ - $(PYTHON) -m ensurepip && $(PYTHON) -m pip install uv; \ + $(PYTHON) -m ensurepip && $(PYTHON) -m pip install "uv >= 0.4.27"; \ fi ensure-uv: _ensure-uv-cmd _ensure-uv-venv From 0f7740cc69b29f5c8691f372cd11fa0febed2e65 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 17:25:19 -0400 Subject: [PATCH 09/42] Use uv install groups --- Makefile | 2 +- docs/Makefile | 2 +- docs/requirements-site.txt | 1 - pyproject.toml | 36 ++++++++++++++++++------------------ 4 files changed, 20 insertions(+), 21 deletions(-) delete mode 100644 docs/requirements-site.txt diff --git a/Makefile b/Makefile index 79533c00..efd9069e 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ cov-xml: dev $(UV) run coverage xml dev: ensure-uv - $(UV) pip install -e '.[dev]' + $(UV) pip install -e . docs: ensure-uv $(MAKE) -C ./docs diff --git a/docs/Makefile b/docs/Makefile index ae4deb92..76964e84 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -36,9 +36,9 @@ clean: find . -type d -empty -delete deps: - $(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 + cd .. && $(MAKE) dev preview: CURRENT_YEAR=$(CURRENT_YEAR) \ diff --git a/docs/requirements-site.txt b/docs/requirements-site.txt deleted file mode 100644 index b3aa648b..00000000 --- a/docs/requirements-site.txt +++ /dev/null @@ -1 +0,0 @@ -quartodoc diff --git a/pyproject.toml b/pyproject.toml index a92b4afe..e1209adb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,24 +21,6 @@ classifiers = [ dynamic = ["version"] dependencies = ["requests>=2.31.0,<3", "packaging", "typing-extensions"] -[project.optional-dependencies] -dev = [ - "build", - "coverage", - "pandas", - "pre-commit", - "pyjson5", - "pyright", - "pytest", - "responses", - "rsconnect-python", - "ruff", - "setuptools", - "setuptools-scm", - "uv", -] - - [project.urls] Source = "https://github.com/posit-dev/posit-sdk-py" Issues = "https://github.com/posit-dev/posit-sdk-py/issues" @@ -112,3 +94,21 @@ ignore = [ [tool.ruff.lint.pydocstyle] convention = "numpy" + + +[dependency-groups] +build = ["build"] +coverage = ["coverage"] +examples = ["rsconnect-python", "pandas"] +git = ["pre-commit"] +site = ["quartodoc"] +test = ["responses", "pytest", "pyjson5"] +# Default install group by `uv` +dev = [ + { include-group = "build" }, + { include-group = "coverage" }, + { include-group = "examples" }, + { include-group = "git" }, + { include-group = "site" }, + { include-group = "test" }, +] From 736ef34154f6ab8870fe31a5402b3ec11de09403 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 17:31:59 -0400 Subject: [PATCH 10/42] Remove `make deps` calls. Remove pip cache. Autoformating --- .github/workflows/ci.yaml | 61 +++++++++++++-------------------- .github/workflows/coverage.yaml | 9 ++--- .github/workflows/release.yaml | 23 +++++-------- .github/workflows/site.yaml | 8 ----- CONTRIBUTING.md | 2 +- Dockerfile | 2 -- 6 files changed, 36 insertions(+), 69 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2cf10d30..6c474d86 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,11 +12,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - with: - python-version: 3.x - check-latest: true - cache: 'pip' - - run: make deps - run: make lint - run: make fmt @@ -26,21 +21,18 @@ jobs: fail-fast: false matrix: python-version: - - '3.8' - - '3.9' - - '3.10' - - '3.11' - - '3.12' + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - check-latest: true - cache: 'pip' - - run: make deps - - run: make dev - - run: make test + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - run: make dev + - run: make test integration-test: runs-on: ubuntu-latest @@ -68,18 +60,18 @@ jobs: - 2022.12.0 - 2022.11.0 steps: - - uses: actions/checkout@v4 - - uses: docker/setup-buildx-action@v3 - - name: Write Posit Connect license to disk - run: echo "$CONNECT_LICENSE" > ./integration/license.lic - env: - CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }} - - run: make -C ./integration ${{ matrix.CONNECT_VERSION }} - - uses: actions/upload-artifact@v4 - if: always() - with: - name: ${{ matrix.CONNECT_VERSION }} - Integration Test Report - path: integration/reports/*.xml + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - name: Write Posit Connect license to disk + run: echo "$CONNECT_LICENSE" > ./integration/license.lic + env: + CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }} + - run: make -C ./integration ${{ matrix.CONNECT_VERSION }} + - uses: actions/upload-artifact@v4 + if: always() + with: + name: ${{ matrix.CONNECT_VERSION }} - Integration Test Report + path: integration/reports/*.xml integration-test-report: needs: integration-test @@ -99,15 +91,10 @@ jobs: files: "artifacts/**/*.xml" report_individual_runs: true - build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - with: - python-version: 3.x - check-latest: true - cache: 'pip' - - run: make deps + - run: make dev - run: make build diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 611494cd..b57e3818 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -12,16 +12,11 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - with: - python-version: 3.x - check-latest: true - cache: 'pip' - - run: make deps - run: make dev - run: make test - run: make cov-xml - if: ${{ ! github.event.pull_request.head.repo.fork }} uses: orgoro/coverage@v3.2 with: - coverageFile: coverage.xml - token: ${{ secrets.GITHUB_TOKEN }} + coverageFile: coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 38bd98d8..e9edabf1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,17 +11,12 @@ jobs: permissions: id-token: write steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - check-latest: true - cache: 'pip' - - uses: actions/setup-node@v4 - - run: make deps - - run: make build - - run: make install - - id: release - uses: pypa/gh-action-pypi-publish@release/v1 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + - uses: actions/setup-node@v4 + - run: make build + - run: make install + - id: release + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 6e3c96af..3abb7b52 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -26,10 +26,6 @@ jobs: with: fetch-depth: 0 - uses: actions/setup-python@v5 - with: - python-version: 3.x - check-latest: true - cache: 'pip' - run: make deps - run: make build - run: make install @@ -49,10 +45,6 @@ jobs: with: fetch-depth: 0 - uses: actions/setup-python@v5 - with: - python-version: 3.x - check-latest: true - cache: 'pip' - uses: actions/setup-node@v4 - uses: quarto-dev/quarto-actions/setup@v2 - run: make deps diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5c290734..d7afa2ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ Use the default make target to execute the full build pipeline. For details on s ## Style Guide -We use [Ruff](https://docs.astral.sh/ruff/) for linting and code formatting. Run `make deps` to install it. +We use [Ruff](https://docs.astral.sh/ruff/) for linting and code formatting. All proposed changes must successfully pass the `make lint` rules prior to merging. diff --git a/Dockerfile b/Dockerfile index a2014369..1a3f3b9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,6 @@ WORKDIR /sdk COPY Makefile pyproject.toml requirements.txt requirements-dev.txt vars.mk ./ -RUN --mount=type=cache,mode=0755,target=/root/.cache/pip make deps - COPY .git .git COPY src src From e10b7424c73f338a2f4ca2bb771920e272cda931 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:45:59 -0400 Subject: [PATCH 11/42] Remove requirements files --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1a3f3b9c..c9d0c88e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y make WORKDIR /sdk -COPY Makefile pyproject.toml requirements.txt requirements-dev.txt vars.mk ./ +COPY Makefile pyproject.toml vars.mk ./ COPY .git .git COPY src src From 1e353d1849d8ebc5a89f639e9a9190a1d38c7291 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:46:16 -0400 Subject: [PATCH 12/42] Remove `package: posit` as top level package covers it --- docs/_quarto.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/_quarto.yml b/docs/_quarto.yml index 4cacdfce..f77c78ba 100644 --- a/docs/_quarto.yml +++ b/docs/_quarto.yml @@ -82,7 +82,6 @@ quartodoc: include_empty: true sections: - title: Clients - package: posit desc: > The `Client` is the entrypoint for each Posit product. Initialize a `Client` to get started. contents: @@ -96,7 +95,6 @@ quartodoc: - patch - delete - title: Posit Connect Resources - package: posit contents: - connect.bundles - connect.content @@ -106,7 +104,6 @@ quartodoc: - connect.users - connect.vanities - title: Posit Connect Metrics - package: posit contents: - connect.metrics - connect.metrics.usage From 84465785459578e2855ad8fa8ee9304745a01de9 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:46:38 -0400 Subject: [PATCH 13/42] Make sure version has dev deps installed to calc version directly --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index efd9069e..f69422b6 100644 --- a/Makefile +++ b/Makefile @@ -64,8 +64,9 @@ test: dev uninstall: ensure-uv $(UV) pip uninstall $(PROJECT_NAME) -version: dev - @$(UV) run setuptools_scm +version: + @$(MAKE) dev &>/dev/null + @$(UV) run python -m setuptools_scm help: @echo "Makefile Targets" From fe67a36616b06540ed0679fba6246bbbf9090abc Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:46:42 -0400 Subject: [PATCH 14/42] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 47fab16e..c5b32315 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,5 @@ cython_debug/ # Ruff .ruff_cache/ + +/.luarc.json From ab55352d4492937bd022b2a4d157e110db0d6438 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:48:49 -0400 Subject: [PATCH 15/42] Only install quarto extensions if necessary --- docs/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index 76964e84..c5811f24 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -35,10 +35,11 @@ clean: rm -rf _extensions _inv _site .quarto reference objects.json find . -type d -empty -delete -deps: +_extensions/posit-dev/posit-docs/_extension.yml: $(QUARTO) add --no-prompt posit-dev/product-doc-theme@v4.0.2 +_extensions/machow/interlinks/_extension.yml: $(QUARTO) add --no-prompt machow/quartodoc - cd .. && $(MAKE) dev +deps: ensure-dev _extensions/posit-dev/posit-docs/_extension.yml _extensions/machow/interlinks/_extension.yml preview: CURRENT_YEAR=$(CURRENT_YEAR) \ From ae7c6fa0697fbeede120105022a7c999a330655e Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:49:09 -0400 Subject: [PATCH 16/42] Activate uv env before running quartodoc or quarto commands --- docs/Makefile | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index c5811f24..51326fe2 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -21,15 +21,25 @@ endif all: deps api build -api: - $(QUARTODOC) build - $(QUARTODOC) interlinks +ensure-dev: + $(MAKE) -C .. dev + +api: ensure-dev + @echo "::group::quartodoc interlinks" + source ../.venv/bin/activate && \ + $(QUARTODOC) interlinks + @echo "::endgroup::" + @echo "::group::quartodoc build" + source ../.venv/bin/activate && \ + $(QUARTODOC) build --verbose + @echo "::endgroup::" cp -r _extensions/ reference/_extensions # Required to render footer -build: - CURRENT_YEAR=$(CURRENT_YEAR) \ - PROJECT_VERSION=$(PROJECT_VERSION) \ - $(QUARTO) render +build: ensure-dev + source ../.venv/bin/activate && \ + CURRENT_YEAR=$(CURRENT_YEAR) \ + PROJECT_VERSION=$(PROJECT_VERSION) \ + $(QUARTO) render clean: rm -rf _extensions _inv _site .quarto reference objects.json @@ -41,7 +51,8 @@ _extensions/machow/interlinks/_extension.yml: $(QUARTO) add --no-prompt machow/quartodoc deps: ensure-dev _extensions/posit-dev/posit-docs/_extension.yml _extensions/machow/interlinks/_extension.yml -preview: +preview: ensure-dev + source ../.venv/bin/activate && \ CURRENT_YEAR=$(CURRENT_YEAR) \ PROJECT_VERSION=$(PROJECT_VERSION) \ $(QUARTO) preview From 55f6f5f900abc22c86aa19c223fcd952d1503a7d Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:49:27 -0400 Subject: [PATCH 17/42] Add setuptools as a package dep for the version --- pyproject.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e1209adb..59d4f19b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,12 @@ classifiers = [ "Typing :: Typed", ] dynamic = ["version"] -dependencies = ["requests>=2.31.0,<3", "packaging", "typing-extensions"] +dependencies = [ + "requests>=2.31.0,<3", + "packaging", + "typing-extensions", + "setuptools-scm;python_version>='3.12'", +] [project.urls] Source = "https://github.com/posit-dev/posit-sdk-py" From 3fb419bfad1548296428a2eebf2e3f3cbb2cd0ae Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:49:44 -0400 Subject: [PATCH 18/42] Add more dev pkgs --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 59d4f19b..eb0b7cd1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,7 +106,8 @@ build = ["build"] coverage = ["coverage"] examples = ["rsconnect-python", "pandas"] git = ["pre-commit"] -site = ["quartodoc"] +lint = ["ruff", "pyright"] +site = ["quartodoc==0.8.1", "griffe>=1.3.2"] test = ["responses", "pytest", "pyjson5"] # Default install group by `uv` dev = [ @@ -114,6 +115,7 @@ dev = [ { include-group = "coverage" }, { include-group = "examples" }, { include-group = "git" }, + { include-group = "lint" }, { include-group = "site" }, { include-group = "test" }, ] From 9ddbd5fd8691b32e6936d4a1ec3754ceb6a55b4c Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:50:26 -0400 Subject: [PATCH 19/42] !: Remove support for python 3.8 (EOL) Conflict with quartodoc is exposed by `uv` --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index eb0b7cd1..def2f26d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "posit-sdk" description = "Posit SDK for Python" readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.9" license = { file = "LICENSE" } keywords = ["posit", "sdk"] classifiers = [ From 845ccd6bb2b726e7dce391ad603291c2c0265dae Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 00:55:30 -0400 Subject: [PATCH 20/42] Drop 3.8 in CI and docs --- .github/workflows/ci.yaml | 1 - CONTRIBUTING.md | 2 +- docs/installation.qmd | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6c474d86..baa27e5f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,7 +21,6 @@ jobs: fail-fast: false matrix: python-version: - - "3.8" - "3.9" - "3.10" - "3.11" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d7afa2ca..631c8f17 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,7 @@ The `posit-sdk` is a software development kit (SDK) for working with Posit's pro Before contributing to the `posit-sdk`, ensure that the following prerequisites are met: -- Python >=3.8 +- Python >=3.9 > [!INFO] > We require using virtual environments to maintain a clean and consistent development environment. diff --git a/docs/installation.qmd b/docs/installation.qmd index 435f7ed4..3ea6906e 100644 --- a/docs/installation.qmd +++ b/docs/installation.qmd @@ -8,7 +8,7 @@ toc-depth: 2 ## Python version -We recommend using the latest version of Python available to you. The Posit SDK supports Python 3.8 and newer. +We recommend using the latest version of Python available to you. The Posit SDK supports Python 3.9 and newer. ## Dependencies From 81c7bc03eaeb11736c6e287a3641ef71705f7ade Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 01:02:03 -0400 Subject: [PATCH 21/42] Do not use uv system envvar; Use uv to install python --- .github/workflows/ci.yaml | 14 +++++++------- .github/workflows/coverage.yaml | 5 ++--- .github/workflows/release.yaml | 5 ++--- .github/workflows/site.yaml | 9 ++++----- Dockerfile | 2 -- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index baa27e5f..7753975c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,14 +4,14 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - UV_SYSTEM_PYTHON: true jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v3 + - run: uv python install + - run: make dev - run: make lint - run: make fmt @@ -27,9 +27,8 @@ jobs: - "3.12" steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} + - uses: astral-sh/setup-uv@v3 + - run: uv python install ${{ matrix.python-version }} - run: make dev - run: make test @@ -94,6 +93,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v3 + - run: uv python install - run: make dev - run: make build diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index b57e3818..bdd492f2 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -4,14 +4,13 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - UV_SYSTEM_PYTHON: true jobs: cov: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v3 + - run: uv python install - run: make dev - run: make test - run: make cov-xml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e9edabf1..f641a1af 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,8 +3,6 @@ on: push: tags: - "v*.*.*" -env: - UV_SYSTEM_PYTHON: true jobs: default: runs-on: ubuntu-latest @@ -14,7 +12,8 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v3 + - run: uv python install - uses: actions/setup-node@v4 - run: make build - run: make install diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index 3abb7b52..c736da7a 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -6,9 +6,6 @@ on: - "v*.*.*" pull_request: -env: - UV_SYSTEM_PYTHON: true - permissions: id-token: write pages: write @@ -25,7 +22,8 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v3 + - run: uv python install - run: make deps - run: make build - run: make install @@ -44,7 +42,8 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v3 + - run: uv python install - uses: actions/setup-node@v4 - uses: quarto-dev/quarto-actions/setup@v2 - run: make deps diff --git a/Dockerfile b/Dockerfile index c9d0c88e..9dc985fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ FROM python:3 -ENV UV_SYSTEM_PYTHON=true - RUN apt-get update && apt-get install -y make WORKDIR /sdk From d280f65f8537ffcf80d70c468255fa642cb9997b Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 01:17:44 -0400 Subject: [PATCH 22/42] Update site.yaml --- .github/workflows/site.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml index c736da7a..2b6063bc 100644 --- a/.github/workflows/site.yaml +++ b/.github/workflows/site.yaml @@ -24,9 +24,7 @@ jobs: fetch-depth: 0 - uses: astral-sh/setup-uv@v3 - run: uv python install - - run: make deps - - run: make build - - run: make install + - run: make build install - uses: quarto-dev/quarto-actions/setup@v2 - run: make docs - uses: actions/configure-pages@v3 @@ -46,7 +44,6 @@ jobs: - run: uv python install - uses: actions/setup-node@v4 - uses: quarto-dev/quarto-actions/setup@v2 - - run: make deps - run: make dev - run: make docs - id: preview From 96c25352a7868f43fe6fc31a71a3cb79d7b89bec Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 01:38:54 -0400 Subject: [PATCH 23/42] Activate UV before calling rsconnect --- integration/Makefile | 1 + pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/Makefile b/integration/Makefile index 36a496bf..9679506a 100644 --- a/integration/Makefile +++ b/integration/Makefile @@ -134,4 +134,5 @@ help: test: mkdir -p logs set -o pipefail; \ + source ../.venv/bin/activate && \ CONNECT_VERSION=${CONNECT_VERSION} CONNECT_API_KEY="$(shell rsconnect bootstrap -i -s http://connect:3939 --raw)" $(PYTHON) -m pytest -s --junit-xml=./reports/$(CONNECT_VERSION).xml | tee ./logs/$(CONNECT_VERSION).log; diff --git a/pyproject.toml b/pyproject.toml index def2f26d..87f03d7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,7 +108,7 @@ examples = ["rsconnect-python", "pandas"] git = ["pre-commit"] lint = ["ruff", "pyright"] site = ["quartodoc==0.8.1", "griffe>=1.3.2"] -test = ["responses", "pytest", "pyjson5"] +test = ["rsconnect-python", "responses", "pytest", "pyjson5"] # Default install group by `uv` dev = [ { include-group = "build" }, From f3c1e9f93fe99a98ae8e045c64fa022680350b6f Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 01:51:22 -0400 Subject: [PATCH 24/42] Update Makefile --- integration/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/integration/Makefile b/integration/Makefile index 9679506a..46cb4825 100644 --- a/integration/Makefile +++ b/integration/Makefile @@ -134,5 +134,7 @@ help: test: mkdir -p logs set -o pipefail; \ - source ../.venv/bin/activate && \ - CONNECT_VERSION=${CONNECT_VERSION} CONNECT_API_KEY="$(shell rsconnect bootstrap -i -s http://connect:3939 --raw)" $(PYTHON) -m pytest -s --junit-xml=./reports/$(CONNECT_VERSION).xml | tee ./logs/$(CONNECT_VERSION).log; + CONNECT_VERSION=${CONNECT_VERSION} \ + CONNECT_API_KEY="$(shell $(UV) run rsconnect bootstrap -i -s http://connect:3939 --raw)" \ + $(UV) run pytest -s --junit-xml=./reports/$(CONNECT_VERSION).xml | \ + tee ./logs/$(CONNECT_VERSION).log; From 5cd225c2453643015fd6c956b9de6f679f0ae61c Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 01:53:25 -0400 Subject: [PATCH 25/42] Use UV to run quartodoc now that the system isn't being used --- docs/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index 51326fe2..f3cce09f 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -26,12 +26,10 @@ ensure-dev: api: ensure-dev @echo "::group::quartodoc interlinks" - source ../.venv/bin/activate && \ - $(QUARTODOC) interlinks + $(UV) run $(QUARTODOC) interlinks @echo "::endgroup::" @echo "::group::quartodoc build" - source ../.venv/bin/activate && \ - $(QUARTODOC) build --verbose + $(UV) run $(QUARTODOC) build --verbose @echo "::endgroup::" cp -r _extensions/ reference/_extensions # Required to render footer From b38b830d207a7920a1839e6630e2669c7946f18f Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 02:00:19 -0400 Subject: [PATCH 26/42] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 631c8f17..6ab2696d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ Before contributing to the `posit-sdk`, ensure that the following prerequisites ## Instructions > [!WARNING] -> Executing `make` will install third-party packages in your Python environment. Please review the [`Makefile`](./Makefile) to verify behavior before executing any commands. +> Executing `make` will install third-party packages in your `.venv` virtual Python environment. Please review the [`Makefile`](./Makefile) to verify behavior before executing any commands. 1. Fork the repository and open it in your development environment. 2. Activate your Python environment (e.g., `source .venv/bin/activate`) From 6ceed86e478b95f9924d0172f096b4da1e019e25 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 02:06:11 -0400 Subject: [PATCH 27/42] Test on python 3.13 --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7753975c..8b17e6cf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,6 +25,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@v4 - uses: astral-sh/setup-uv@v3 From 89a16084a69ad4a32247595f8cc6a87e2b0f67a7 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:17:24 -0400 Subject: [PATCH 28/42] Add back python 3.8 support and tests --- .github/workflows/ci.yaml | 1 + pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8b17e6cf..3eeb39f3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,6 +21,7 @@ jobs: fail-fast: false matrix: python-version: + - "3.8" - "3.9" - "3.10" - "3.11" diff --git a/pyproject.toml b/pyproject.toml index 87f03d7d..c3e8f95b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "posit-sdk" description = "Posit SDK for Python" readme = "README.md" -requires-python = ">=3.9" +requires-python = ">=3.8" license = { file = "LICENSE" } keywords = ["posit", "sdk"] classifiers = [ From 1ea9dd8dfe619c60e787a1be92ba966f087d9589 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:25:43 -0400 Subject: [PATCH 29/42] Comment examples install group for now --- pyproject.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c3e8f95b..566a8120 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,11 +109,14 @@ git = ["pre-commit"] lint = ["ruff", "pyright"] site = ["quartodoc==0.8.1", "griffe>=1.3.2"] test = ["rsconnect-python", "responses", "pytest", "pyjson5"] -# Default install group by `uv` +# Default install group by `uv`: `dev` dev = [ { include-group = "build" }, { include-group = "coverage" }, - { include-group = "examples" }, + # # Must comment out `examples` group until only python>3.8 is supported + # # `numpy==1.24.4` requires `distutils`, which is not available in python3.12 + # # `numpy>1.24.4` does not require `distutils` + # { include-group = "examples" }, { include-group = "git" }, { include-group = "lint" }, { include-group = "site" }, From b8047c84bd059fe1bac74104bfd9608ef4438a42 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:26:23 -0400 Subject: [PATCH 30/42] Get quartodoc to install on the fly when building --- docs/Makefile | 17 +++++++++-------- pyproject.toml | 2 -- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index f3cce09f..51a41792 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -6,7 +6,8 @@ CURRENT_YEAR ?= $(shell date +%Y) # Quarto settings QUARTO ?= quarto -QUARTODOC ?= quartodoc +# quartodoc doesn't like py3.8; Run using `--with` as it can conflict with the project's dependencies +QUARTODOC ?= --with "quartodoc==0.8.1" quartodoc # Netlify settings NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee @@ -26,18 +27,18 @@ ensure-dev: api: ensure-dev @echo "::group::quartodoc interlinks" - $(UV) run $(QUARTODOC) interlinks + $(UV) tool run --with ../ $(QUARTODOC) interlinks @echo "::endgroup::" @echo "::group::quartodoc build" - $(UV) run $(QUARTODOC) build --verbose + $(UV) tool run --with ../ $(QUARTODOC) build --verbose @echo "::endgroup::" cp -r _extensions/ reference/_extensions # Required to render footer build: ensure-dev - source ../.venv/bin/activate && \ - CURRENT_YEAR=$(CURRENT_YEAR) \ - PROJECT_VERSION=$(PROJECT_VERSION) \ - $(QUARTO) render + CURRENT_YEAR=$(CURRENT_YEAR) \ + PROJECT_VERSION=$(PROJECT_VERSION) \ + $(UV) tool run --with ../ \ + $(QUARTO) render clean: rm -rf _extensions _inv _site .quarto reference objects.json @@ -50,9 +51,9 @@ _extensions/machow/interlinks/_extension.yml: deps: ensure-dev _extensions/posit-dev/posit-docs/_extension.yml _extensions/machow/interlinks/_extension.yml preview: ensure-dev - source ../.venv/bin/activate && \ CURRENT_YEAR=$(CURRENT_YEAR) \ PROJECT_VERSION=$(PROJECT_VERSION) \ + $(UV) tool run --with ../ \ $(QUARTO) preview deploy: diff --git a/pyproject.toml b/pyproject.toml index 566a8120..8a845c1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,7 +107,6 @@ coverage = ["coverage"] examples = ["rsconnect-python", "pandas"] git = ["pre-commit"] lint = ["ruff", "pyright"] -site = ["quartodoc==0.8.1", "griffe>=1.3.2"] test = ["rsconnect-python", "responses", "pytest", "pyjson5"] # Default install group by `uv`: `dev` dev = [ @@ -119,6 +118,5 @@ dev = [ # { include-group = "examples" }, { include-group = "git" }, { include-group = "lint" }, - { include-group = "site" }, { include-group = "test" }, ] From 5dede91914a5235fa09dfb192a81688a8b9fda68 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:27:50 -0400 Subject: [PATCH 31/42] Collapse to a single target --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f69422b6..d907aece 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ include vars.mk .DEFAULT_GOAL := all -.PHONY: build clean cov default dev docs ensure-uv _ensure-uv-cmd _ensure-uv-venv fmt fix install it lint test uninstall version help +.PHONY: build clean cov default dev docs ensure-uv fmt fix install it lint test uninstall version help all: dev test lint build @@ -37,12 +37,12 @@ docs: ensure-uv $(VIRTUAL_ENV): $(UV) venv $(VIRTUAL_ENV) -_ensure-uv-venv: _ensure-uv-cmd $(VIRTUAL_ENV) -_ensure-uv-cmd: +ensure-uv: $(VIRTUAL_ENV) @if ! command -v $(UV) >/dev/null; then \ $(PYTHON) -m ensurepip && $(PYTHON) -m pip install "uv >= 0.4.27"; \ fi -ensure-uv: _ensure-uv-cmd _ensure-uv-venv + @$(UV) pip install "uv >= 0.4.27" --quiet + @$(MAKE) $(VIRTUAL_ENV) 1>/dev/null fmt: dev $(UV) run ruff check --fix From c0f6bc8f31ced9b1da8d9517357e07bf03760525 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:28:15 -0400 Subject: [PATCH 32/42] Use uv tool run --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d907aece..c02e418d 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,8 @@ ensure-uv: $(VIRTUAL_ENV) @$(MAKE) $(VIRTUAL_ENV) 1>/dev/null fmt: dev - $(UV) run ruff check --fix - $(UV) run ruff format + $(UV) tool run --with . ruff check --fix + $(UV) tool run --with . ruff format install: ensure-uv $(UV) pip install dist/*.whl @@ -55,11 +55,11 @@ it: $(MAKE) -C ./integration lint: dev - $(UV) run pyright - $(UV) run ruff check + $(UV) tool run --with . pyright + $(UV) tool run --with . ruff check test: dev - $(UV) run coverage run --source=src -m pytest tests + $(UV) tool run coverage run --source=src -m pytest tests uninstall: ensure-uv $(UV) pip uninstall $(PROJECT_NAME) From 1b6665a243cf274c6d7fbbfc25472632ace0f710 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:28:32 -0400 Subject: [PATCH 33/42] Be sure to build before installing --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c02e418d..45f841f7 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ fmt: dev $(UV) tool run --with . ruff check --fix $(UV) tool run --with . ruff format -install: ensure-uv +install: build $(UV) pip install dist/*.whl it: From 3c14bb5c5dcc8815abfae1d74973870a3839761d Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:44:47 -0400 Subject: [PATCH 34/42] Use uv quiet param to produce no unexpected output for version --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 45f841f7..c71b5834 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,9 @@ ensure-uv: $(VIRTUAL_ENV) @if ! command -v $(UV) >/dev/null; then \ $(PYTHON) -m ensurepip && $(PYTHON) -m pip install "uv >= 0.4.27"; \ fi + @# Be sure latest pip is installed @$(UV) pip install "uv >= 0.4.27" --quiet + @# Install virtual environment @$(MAKE) $(VIRTUAL_ENV) 1>/dev/null fmt: dev @@ -65,8 +67,8 @@ uninstall: ensure-uv $(UV) pip uninstall $(PROJECT_NAME) version: - @$(MAKE) dev &>/dev/null - @$(UV) run python -m setuptools_scm + @$(MAKE) ensure-uv &>/dev/null + @$(UV) run --quiet python -m setuptools_scm help: @echo "Makefile Targets" From 1dc01fc370ea61a6379c4457bd001e77d04d964c Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:47:38 -0400 Subject: [PATCH 35/42] Update Makefile --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c71b5834..3537262b 100644 --- a/Makefile +++ b/Makefile @@ -47,8 +47,8 @@ ensure-uv: $(VIRTUAL_ENV) @$(MAKE) $(VIRTUAL_ENV) 1>/dev/null fmt: dev - $(UV) tool run --with . ruff check --fix - $(UV) tool run --with . ruff format + $(UV) run ruff check --fix + $(UV) run ruff format install: build $(UV) pip install dist/*.whl @@ -57,11 +57,11 @@ it: $(MAKE) -C ./integration lint: dev - $(UV) tool run --with . pyright - $(UV) tool run --with . ruff check + $(UV) run pyright + $(UV) run ruff check test: dev - $(UV) tool run coverage run --source=src -m pytest tests + $(UV) run coverage run --source=src -m pytest tests uninstall: ensure-uv $(UV) pip uninstall $(PROJECT_NAME) From 657d227e31446d123e7c369b9f026263d07c4600 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:54:14 -0400 Subject: [PATCH 36/42] Update Makefile --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3537262b..2abc6c19 100644 --- a/Makefile +++ b/Makefile @@ -37,14 +37,14 @@ docs: ensure-uv $(VIRTUAL_ENV): $(UV) venv $(VIRTUAL_ENV) -ensure-uv: $(VIRTUAL_ENV) +ensure-uv: @if ! command -v $(UV) >/dev/null; then \ $(PYTHON) -m ensurepip && $(PYTHON) -m pip install "uv >= 0.4.27"; \ fi - @# Be sure latest pip is installed - @$(UV) pip install "uv >= 0.4.27" --quiet - @# Install virtual environment + @# Install virtual environment (before calling `uv pip install ...`) @$(MAKE) $(VIRTUAL_ENV) 1>/dev/null + @# Be sure recent uv is installed + @$(UV) pip install "uv >= 0.4.27" --quiet fmt: dev $(UV) run ruff check --fix From 6a3e3eaf8c0a3492c0d4a490853e355ab02e7ed5 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 15:59:45 -0400 Subject: [PATCH 37/42] Revert version change Co-authored-by: Taylor Steinberg --- docs/installation.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation.qmd b/docs/installation.qmd index 3ea6906e..435f7ed4 100644 --- a/docs/installation.qmd +++ b/docs/installation.qmd @@ -8,7 +8,7 @@ toc-depth: 2 ## Python version -We recommend using the latest version of Python available to you. The Posit SDK supports Python 3.9 and newer. +We recommend using the latest version of Python available to you. The Posit SDK supports Python 3.8 and newer. ## Dependencies From d89cbddc1feaedd8d876b385f4c689e3778763a2 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 16:08:12 -0400 Subject: [PATCH 38/42] Remove `setuptools-scm` from direct deps --- Makefile | 2 +- pyproject.toml | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 2abc6c19..883b035d 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ uninstall: ensure-uv version: @$(MAKE) ensure-uv &>/dev/null - @$(UV) run --quiet python -m setuptools_scm + @$(UV) run --quiet --with "setuptools_scm" python -m setuptools_scm help: @echo "Makefile Targets" diff --git a/pyproject.toml b/pyproject.toml index 8a845c1d..70a06c2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,12 +19,7 @@ classifiers = [ "Typing :: Typed", ] dynamic = ["version"] -dependencies = [ - "requests>=2.31.0,<3", - "packaging", - "typing-extensions", - "setuptools-scm;python_version>='3.12'", -] +dependencies = ["requests>=2.31.0,<3", "packaging", "typing-extensions"] [project.urls] Source = "https://github.com/posit-dev/posit-sdk-py" From 979afd8486037949278c22ca1ebe98a16f130f80 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 16:42:08 -0400 Subject: [PATCH 39/42] Install project deps before copying src for faster builds --- Dockerfile | 5 ++++- Makefile | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9dc985fc..84c92634 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,10 @@ RUN apt-get update && apt-get install -y make WORKDIR /sdk -COPY Makefile pyproject.toml vars.mk ./ +COPY Makefile pyproject.toml vars.mk uv.lock ./ + +# Run before `COPY src src` to cache dependencies for faster iterative builds +RUN --mount=type=cache,mode=0755,target=/root/.cache/pip make docker-deps COPY .git .git COPY src src diff --git a/Makefile b/Makefile index 883b035d..5ba3e47e 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ include vars.mk .DEFAULT_GOAL := all -.PHONY: build clean cov default dev docs ensure-uv fmt fix install it lint test uninstall version help +.PHONY: build clean cov default dev docker-deps docs ensure-uv fmt fix install it lint test uninstall version help all: dev test lint build @@ -32,6 +32,12 @@ cov-xml: dev dev: ensure-uv $(UV) pip install -e . +docker-deps: ensure-uv + # Sync given the `uv.lock` file + # --frozen : assert that the lock file exists + # --no-install-project : do not install the project itself, but install its dependencies + $(UV) sync --frozen --no-install-project + docs: ensure-uv $(MAKE) -C ./docs From bde1ba33f729fcf56057b57c2083217200df68b6 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 16:48:09 -0400 Subject: [PATCH 40/42] Create the lock file if it does not exist --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5ba3e47e..956afbee 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,9 @@ fmt: dev install: build $(UV) pip install dist/*.whl -it: +uv.lock: dev + $(UV) lock +it: uv.lock $(MAKE) -C ./integration lint: dev From b01cb204efcc2a41572da6ca9f8e2ed177a9c676 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 16:58:32 -0400 Subject: [PATCH 41/42] Make sure uv.lock exists --- Makefile | 4 ++-- integration/Makefile | 1 + vars.mk | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 956afbee..7a1e46ee 100644 --- a/Makefile +++ b/Makefile @@ -59,9 +59,9 @@ fmt: dev install: build $(UV) pip install dist/*.whl -uv.lock: dev +$(UV_LOCK): dev $(UV) lock -it: uv.lock +it: $(UV_LOCK) $(MAKE) -C ./integration lint: dev diff --git a/integration/Makefile b/integration/Makefile index 46cb4825..edc0ac50 100644 --- a/integration/Makefile +++ b/integration/Makefile @@ -71,6 +71,7 @@ preview: # Build Dockerfile build: + make -C .. $(UV_LOCK) docker build -t $(DOCKER_PROJECT_IMAGE_TAG) .. # Tear down resources. diff --git a/vars.mk b/vars.mk index 0f635f4d..9077852f 100644 --- a/vars.mk +++ b/vars.mk @@ -20,3 +20,5 @@ PYTHON ?= $(shell command -v python || command -v python3) UV ?= uv # uv defaults virtual environment to `$VIRTUAL_ENV` if set; otherwise .venv VIRTUAL_ENV ?= .venv + +UV_LOCK := uv.lock From 8d8c0ae2658864a7fba5140b62bdaf4a9aab3ed0 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 29 Oct 2024 17:02:39 -0400 Subject: [PATCH 42/42] Add uv to integration CI --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3eeb39f3..0b25bc7c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -66,6 +66,8 @@ jobs: run: echo "$CONNECT_LICENSE" > ./integration/license.lic env: CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }} + - uses: astral-sh/setup-uv@v3 + - run: uv python install - run: make -C ./integration ${{ matrix.CONNECT_VERSION }} - uses: actions/upload-artifact@v4 if: always()