From 5d5ef772d3123b8aaf382c6b77b25359182b4ae1 Mon Sep 17 00:00:00 2001 From: George Pickering <9803299+bigpick@users.noreply.github.com> Date: Mon, 5 May 2025 17:40:15 -0400 Subject: [PATCH 1/4] feat: switch from poetry to ruff --- makefiles/Makefile.python.in | 19 ++++++------------- scripts/publish/python.sh | 6 +++--- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/makefiles/Makefile.python.in b/makefiles/Makefile.python.in index 836105d..cb7d209 100644 --- a/makefiles/Makefile.python.in +++ b/makefiles/Makefile.python.in @@ -46,23 +46,18 @@ show-venv:: | check-venv @echo "++ $@" @echo "$(VIRTUAL_ENV)" -install-poetry:: +set-pyproject-vers:: check-venv @echo "++ $@" - # will install poetry in this venv - pip install --quiet --upgrade poetry + uv version $(VERSION) -set-pyproject-vers:: check-venv install-poetry - @echo "++ $@" - poetry version $(VERSION) - -install-deps:: check-venv install-poetry +install-deps:: check-venv @echo "++ $@" # will install deps in this venv - poetry install --no-ansi + uv sync --frozen --dev show-installed-deps:: @echo "++ $@" - poetry show + uv tree --locked --all-groups check: test lint type-check @echo "++ $@" @@ -80,12 +75,10 @@ test-integration:: check-venv install-deps package:: check-venv set-pyproject-vers install-deps test-all @echo "++ $@" - poetry build --no-ansi - poetry version 0.0.0 &>/dev/null + uv build --frozen publish:: check-venv package @echo "++ $@" - poetry config repositories.testpypi https://test.pypi.org/legacy/ . $(ROOT_DIR)/plox-common/scripts/publish/python.sh && publish extra-docker-args: diff --git a/scripts/publish/python.sh b/scripts/publish/python.sh index 230d41f..ab479b6 100755 --- a/scripts/publish/python.sh +++ b/scripts/publish/python.sh @@ -8,13 +8,13 @@ script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) publish(){ - if [[ "${GITHUB_ACTIONS:-}" == "" || "$(is_part_of_active_pr)" == "n" ]]; then - poetry publish ${PYPI_ALIAS} -vv + if [[ "${GITHUB_ACTIONS:-}" != "" || "$(is_part_of_active_pr)" == "n" ]]; then + uv publish --index pypi -vv return fi if [[ "$(is_label_present publish-test-build)" == "y" ]]; then - poetry publish ${PYPI_ALIAS} -vv + uv publish --index testpypi -vv else echo "Detected part of PR but did not detect 'publish-test-build' PR label" echo "To publish a test version of this packge, add the 'publish-test-build' label" From 05da80987219b1005dec7ad45203ebc560f9d34c Mon Sep 17 00:00:00 2001 From: George Pickering <9803299+bigpick@users.noreply.github.com> Date: Mon, 5 May 2025 17:42:16 -0400 Subject: [PATCH 2/4] fix: remove --frozen from build --- makefiles/Makefile.python.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefiles/Makefile.python.in b/makefiles/Makefile.python.in index cb7d209..ac1e5fe 100644 --- a/makefiles/Makefile.python.in +++ b/makefiles/Makefile.python.in @@ -75,7 +75,7 @@ test-integration:: check-venv install-deps package:: check-venv set-pyproject-vers install-deps test-all @echo "++ $@" - uv build --frozen + uv build publish:: check-venv package @echo "++ $@" From d84862debc0f476c8ebfcf4fbafa7e13401bddb6 Mon Sep 17 00:00:00 2001 From: George Pickering <9803299+bigpick@users.noreply.github.com> Date: Tue, 6 May 2025 07:37:42 -0400 Subject: [PATCH 3/4] fix: publish scripts --- scripts/common.sh | 9 +++++++++ scripts/publish/python.sh | 10 ++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/common.sh b/scripts/common.sh index 63146fa..71f3155 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -27,6 +27,15 @@ print_func_banner(){ local funcname="${1}" printf "============================ Inside: %s ============================\n" "${funcname}" >&2; } +is_default_branch(){ + print_func_banner "${FUNCNAME[0]}" + if [[ "${BRANCH_NAME}" == "${DEAFULT_BRANCH}" ]]; then + echo "y" + else + echo "n" + fi +} + ### # Check whether the current commit/branch is part of a pull request. ### diff --git a/scripts/publish/python.sh b/scripts/publish/python.sh index ab479b6..d8e7185 100755 --- a/scripts/publish/python.sh +++ b/scripts/publish/python.sh @@ -8,16 +8,18 @@ script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) publish(){ - if [[ "${GITHUB_ACTIONS:-}" != "" || "$(is_part_of_active_pr)" == "n" ]]; then + if [[ "${GITHUB_ACTIONS:-}" == "" || "$(is_default_branch)" == "y" ]]; then uv publish --index pypi -vv return + else + print_info "${BRANCH_NAME} != default (${DEFAULT_BRANCH}), not publishing" fi if [[ "$(is_label_present publish-test-build)" == "y" ]]; then uv publish --index testpypi -vv else - echo "Detected part of PR but did not detect 'publish-test-build' PR label" - echo "To publish a test version of this packge, add the 'publish-test-build' label" - echo "and re-run the publish check." + print_info "Detected part of PR but did not detect 'publish-test-build' PR label" + print_info "To publish a test version of this packge, add the 'publish-test-build' label" + print_info "and re-run the publish check." fi } From 57d1d4aef94096c15dcee6c0e6fa2b6aceb867d7 Mon Sep 17 00:00:00 2001 From: George Pickering <9803299+bigpick@users.noreply.github.com> Date: Tue, 6 May 2025 07:40:52 -0400 Subject: [PATCH 4/4] fix: publish scripts --- scripts/misc/get-pypi-pub-target | 26 -------------------------- scripts/publish/python.sh | 10 ++++++++-- 2 files changed, 8 insertions(+), 28 deletions(-) delete mode 100755 scripts/misc/get-pypi-pub-target diff --git a/scripts/misc/get-pypi-pub-target b/scripts/misc/get-pypi-pub-target deleted file mode 100755 index a887a55..0000000 --- a/scripts/misc/get-pypi-pub-target +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -# exit early if not in github actions CI -if [[ "${GITHUB_ACTIONS:-}" == "" ]]; then - echo "-r testpypi" - exit 0 -fi - -if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then - branch="${GITHUB_REF##*/}" - if [[ "${branch}" == "main" || "${branch}" == "master" ]]; then - # post-PR merge, publish to official - exit 0 - else - echo "-r testpypi" - fi -elif [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then - echo "-r testpypi" -else - echo "Invalid branch" - exit 1 -fi - -exit 0 diff --git a/scripts/publish/python.sh b/scripts/publish/python.sh index d8e7185..2a1294e 100755 --- a/scripts/publish/python.sh +++ b/scripts/publish/python.sh @@ -8,11 +8,17 @@ script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) publish(){ - if [[ "${GITHUB_ACTIONS:-}" == "" || "$(is_default_branch)" == "y" ]]; then + # allow local publishing to testpypi + if [[ "${GITHUB_ACTIONS:-}" == "" ]]; then + uv publish --index testpypi -vv + return 0 + fi + + if [[ "$(is_default_branch)" == "y" ]]; then uv publish --index pypi -vv return else - print_info "${BRANCH_NAME} != default (${DEFAULT_BRANCH}), not publishing" + print_info "${BRANCH_NAME} != default (${DEFAULT_BRANCH}), not publishing to main" fi if [[ "$(is_label_present publish-test-build)" == "y" ]]; then