Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -eo pipefail
shopt -s inherit_errexit

watch_file venv/bin/activate
watch_file .venv/bin/activate

if [[ -f "venv/bin/activate" ]]; then
source venv/bin/activate
if [[ -f ".venv/bin/activate" ]]; then
source .venv/bin/activate
fi
35 changes: 22 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
name: Publish
name: "Publish"

on:
release:
types: [published]
push:
tags:
- v*

jobs:
publish:
run:
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: x64
- run: make build
- run: venv-tools/bin/twine upload dist/*
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
- name: Checkout
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install Python 3.13
run: uv python install 3.13
- name: Build
run: uv build
- name: Publish
run: uv publish
7 changes: 5 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ jobs:
]
include:
- python-version: '3.9'
post-venv: 'venv/bin/pip install "urllib3<2" "requests<=2.30" "types-requests<=2.30"'
post-venv: '.venv/bin/pip install "urllib3<2" "requests<=2.30" "types-requests<=2.30"'
name: Python ${{ matrix.python-version }} ${{ matrix.post-venv }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install uv
uses: astral-sh/setup-uv@v7
- run: make venv
- if: ${{ matrix.post-venv }}
run: ${{ matrix.post-venv }}
- run: make test
- run: make lint
- run: make check
- run: make format-check
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/venv-tools
/venv
/.venv
__pycache__/
/dist
44 changes: 17 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,31 @@
venv: pyproject.toml poetry.lock venv-tools
rm -rf venv
python3 -m venv venv
VIRTUAL_ENV=venv venv-tools/bin/poetry install
DEFAULT_GOAL := ci

venv-tools: requirements.tools.txt
rm -rf venv-tools
python3 -m venv venv-tools
venv-tools/bin/pip install -r requirements.tools.txt
.PHONY: ci
ci: check format-check test

.PHONY: venv
venv:
uv sync

.PHONY: clean
clean:
rm -rf venv
rm -rf venv-tools
rm -rf .venv
rm -rf dist

.PHONY: test
test: venv
venv/bin/pytest -vv

.PHONY: build
build: venv-tools
rm -rf dist
venv-tools/bin/poetry build
uv run pytest

.PHONY: format
format: venv-tools
venv-tools/bin/ruff check --fix --unsafe-fixes
venv-tools/bin/ruff format
uv run ruff check --fix --unsafe-fixes
uv run ruff format

.PHONY: format-check
format-check: venv-tools
venv-tools/bin/ruff check
venv-tools/bin/ruff format --check

.PHONY: lint
lint: mypy format-check
format-check:
uv run ruff check
uv run ruff format --check

.PHONY: mypy
mypy: venv
venv/bin/mypy flareio tests
.PHONY: check
check: venv
uv run mypy src/flareio tests
3 changes: 0 additions & 3 deletions poetry.toml

This file was deleted.

27 changes: 17 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[tool.poetry]
[project]
name = "flareio"
version = "1.2.0"
description = "Python SDK for the flare.io API."
authors = ["Alexandre Viau <alexandre.viau@flare.io>"]
authors = [
{ name = "Alexandre Viau", email="alexandre.viau@flare.io>" }
]
readme = "README.md"
repository = "https://github.com/Flared/python-flareio"
license = "MIT"
requires-python = ">=3.9"
keywords = [
"flare",
"sdk",
Expand All @@ -24,19 +27,23 @@ packages = [
{ include = "flareio" },
]

[tool.poetry.dependencies]
[dependencies]
python = ">=3.8"
requests = ">=2"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["uv_build>=0.9.28,<0.10.0"]
build-backend = "uv_build"

[tool.poetry.group.dev.dependencies]
pytest = "8.3.2"
mypy = "^1.11.1"
requests-mock = "^1.12.1"
types-requests = "^2.32.0.20240712"
[dependency-groups]
dev = [
"pytest>=8.3.2",
"mypy>=1.11.1",
"ruff>=0.15.0",
"requests-mock>=1.12.1",
"types-requests>=2.32.0.20240712",
"pip>=26",
]

[tool.ruff.lint]
extend-select = [
Expand Down
3 changes: 0 additions & 3 deletions requirements.tools.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
76 changes: 39 additions & 37 deletions tools/bump-version
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,47 @@

set -eo pipefail

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="$( cd ${DIR}/.. && pwd )"

fail() {
echo "$@" 1>&2;
exit 1
}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="$( cd ${DIR}/.. && pwd )"

current_version=$(poetry version -s)
echo "Current version: ${current_version}"

# Must run on main.
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ ${current_branch} != "main" ]]
then
fail "error: Must be on main to release; git checkout main"
fi

# Must provide version.
version=${1}
if [[ -z "${version}" ]]
then
fail "error: expected 1 argument 'version'"
fi

if ! (python -c "from packaging import version; assert version.parse('${version}') > version.parse('${current_version}')" 2> /dev/null)
then
fail "error: version must be greater than ${current_version}"
fi

read -p "Release ${version}? [y/n]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
poetry version "${version}"

git reset -- ${ROOT_DIR}
git add "${ROOT_DIR}/pyproject.toml"
git commit -m "version: release ${version}"
git push

echo "Release at https://github.com/Flared/python-flareio/releases/new?tag=v${version}&target=main&title=v${version}"
fi
main() {
local current_branch=
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ ${current_branch} != "main" ]]; then
fail "error: Must be on main to release; git checkout main"
fi

local current_version=
current_version=$(uv version --short)
echo "Current version is ${current_version}"

local new_version="${1}"
if [[ -z "${new_version}" ]]; then
fail "Please specify the new version!"
fi

if ! (python -c "from packaging import version; assert version.parse('${new_version}') > version.parse('${current_version}')" 2> /dev/null); then
fail "error: version must be greater than ${current_version}"
fi

read -p "Release ${version}? [y/n]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
uv version ${new_version}

git reset -- ${ROOT_DIR}
git add "${ROOT_DIR}/pyproject.toml"
git add "${ROOT_DIR}/uv.lock"
git commit -m "version: release ${new_version}"
git push

echo "Release at https://github.com/Flared/python-flareio/releases/new?tag=v${new_version}&target=main&title=v${new_version}"
fi
}

main $@
Loading