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

Upgrade tooling on the project. #1329

Merged
merged 3 commits into from
Dec 20, 2024
Merged
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
26 changes: 0 additions & 26 deletions .github/workflows/check-doc.yml

This file was deleted.

74 changes: 35 additions & 39 deletions .github/workflows/lint-and-tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint & unit tests
name: CI

on:
push:
@@ -11,18 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v4
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Run Lint
run: tox -e lint
run: make lint

test:
# Dependency on linting to avoid running our expensive matrix test for nothing
@@ -53,10 +47,11 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
dependencies: [normal]
database: [sqlite]
# Test other databases with only a few versions of Python (Debian bullseye has 3.9, bookworm has 3.11)
# Test other databases with only a few versions of Python
# (Debian bullseye has 3.9, bookworm has 3.11)
include:
- python-version: 3.9
dependencies: normal
@@ -71,9 +66,6 @@ jobs:
dependencies: normal
database: mariadb
# Try a few variants with the minimal versions supported
- python-version: 3.7
dependencies: minimal
database: sqlite
- python-version: 3.9
dependencies: minimal
database: sqlite
@@ -95,32 +87,36 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Change dependencies to minimal supported versions
run: sed -i -e 's/>=/==/g; s/~=.*==\(.*\)/==\1/g; s/~=/==/g;' pyproject.toml
# This sed comment installs the minimal supported version
# for all versions except for "requires-python"
# This is to detect that the minimum versions are really
# supported, in the CI
run: sed -i -e '/requires-python/!s/>=/==/g; /requires-python/!s/~=.*==\(.*\)/==\1/g; /requires-python/!s/~=/==/g;' pyproject.toml
if: matrix.dependencies == 'minimal'
almet marked this conversation as resolved.
Show resolved Hide resolved
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
# Run tox using the version of Python in `PATH`
- name: Run Tox with sqlite
run: tox -e py
if: matrix.database == 'sqlite'
env:
TESTING_SQLALCHEMY_DATABASE_URI: 'sqlite:///budget.db'
- name: Run Tox with postgresql
run: tox -e py
if: matrix.database == 'postgresql'
- name: Run tests
run: uv run --extra dev --extra database pytest .
env:
TESTING_SQLALCHEMY_DATABASE_URI: 'postgresql+psycopg2://postgres:ihatemoney@localhost:5432/ihatemoney_ci'
- name: Run Tox with mariadb
run: tox -e py
if: matrix.database == 'mariadb'
env:
TESTING_SQLALCHEMY_DATABASE_URI: 'mysql+pymysql://root:ihatemoney@localhost:3306/ihatemoney_ci'
# Setup the DATABASE_URI depending on the matrix we are using.
TESTING_SQLALCHEMY_DATABASE_URI: ${{
matrix.database == 'sqlite'
&& 'sqlite:///budget.db'
|| matrix.database == 'postgresql'
&& 'postgresql+psycopg2://postgres:ihatemoney@localhost:5432/ihatemoney_ci'
|| 'mysql+pymysql://root:ihatemoney@localhost:3306/ihatemoney_ci'
}}

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v4
with:
python-version: "3.11"
- name: Build docs
run: make build-docs
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,10 @@ This document describes changes between each past release.
## 6.2.0 (unreleased)

- Add support for python 3.12 (#757)

- Remove support for python 3.7
- Replace the black linter by ruff
- Replace virtualenv and pip by uv
- Remove tox

## 6.1.5 (2024-03-19)

67 changes: 25 additions & 42 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,60 +1,40 @@
VIRTUALENV = python3 -m venv
SPHINX_BUILDDIR = docs/_build
VIRTUALENV = uv venv
VENV := $(shell realpath $${VIRTUAL_ENV-.venv})
PYTHON = $(VENV)/bin/python3
BIN := uv tool run
PIP := uv pip
PYTHON = $(BIN)/python3
DEV_STAMP = $(VENV)/.dev_env_installed.stamp
INSTALL_STAMP = $(VENV)/.install.stamp
TEMPDIR := $(shell mktemp -d)
ZOPFLIPNG := zopflipng
MAGICK_MOGRIFY := mogrify

.PHONY: all
all: install ## Alias for install
.PHONY: install
install: virtualenv pyproject.toml $(INSTALL_STAMP) ## Install dependencies
$(INSTALL_STAMP):
$(VENV)/bin/pip install -U pip
$(VENV)/bin/pip install -e .
touch $(INSTALL_STAMP)

.PHONY: virtualenv
virtualenv: $(PYTHON)
$(PYTHON):
$(VIRTUALENV) $(VENV)

.PHONY: install-dev
install-dev: virtualenv pyproject.toml $(INSTALL_STAMP) $(DEV_STAMP) ## Install development dependencies
$(DEV_STAMP): $(PYTHON)
$(VENV)/bin/pip install -Ue .[dev]
touch $(DEV_STAMP)

.PHONY: remove-install-stamp
remove-install-stamp:
rm $(INSTALL_STAMP)

.PHONY: update
update: remove-install-stamp install ## Update the dependencies

.PHONY: serve
serve: install build-translations ## Run the ihatemoney server
serve: build-translations ## Run the ihatemoney server
@echo 'Running ihatemoney on http://localhost:5000'
FLASK_DEBUG=1 FLASK_APP=ihatemoney.wsgi $(VENV)/bin/flask run --host=0.0.0.0
FLASK_DEBUG=1 FLASK_APP=ihatemoney.wsgi uv run flask run --host=0.0.0.0

.PHONY: test
test: install-dev ## Run the tests
$(VENV)/bin/tox
test:
uv run --extra dev --extra database pytest .

.PHONY: black
black: install-dev ## Run the tests
$(VENV)/bin/black --target-version=py37 .
.PHONY: lint
lint:
uv tool run ruff check .
uv tool run vermin --no-tips --violations -t=3.8- .

.PHONY: isort
isort: install-dev ## Run the tests
$(VENV)/bin/isort .
.PHONY: format
format:
uv tool run ruff format .

.PHONY: release
release: install-dev ## Release a new version (see https://ihatemoney.readthedocs.io/en/latest/contributing.html#how-to-release)
$(VENV)/bin/fullrelease
release: # Release a new version (see https://ihatemoney.readthedocs.io/en/latest/contributing.html#how-to-release)
uv run --extra dev fullreleas

.PHONY: compress-showcase
compress-showcase:
@@ -72,27 +52,30 @@ compress-assets: compress-showcase ## Compress static assets

.PHONY: build-translations
build-translations: ## Build the translations
$(VENV)/bin/pybabel compile -d ihatemoney/translations
uv run --extra dev pybabel compile -d ihatemoney/translations

.PHONY: extract-translations
extract-translations: ## Extract new translations from source code
$(VENV)/bin/pybabel extract --add-comments "I18N:" --strip-comments --omit-header --no-location --mapping-file ihatemoney/babel.cfg -o ihatemoney/messages.pot ihatemoney
$(VENV)/bin/pybabel update -i ihatemoney/messages.pot -d ihatemoney/translations/
uv run --extra dev pybabel extract --add-comments "I18N:" --strip-comments --omit-header --no-location --mapping-file ihatemoney/babel.cfg -o ihatemoney/messages.pot ihatemoney
uv run --extra dev pybabel update -i ihatemoney/messages.pot -d ihatemoney/translations/

.PHONY: create-database-revision
create-database-revision: ## Create a new database revision
@read -p "Please enter a message describing this revision: " rev_message; \
$(PYTHON) -m ihatemoney.manage db migrate -d ihatemoney/migrations -m "$${rev_message}"
uv run python -m ihatemoney.manage db migrate -d ihatemoney/migrations -m "$${rev_message}"

.PHONY: create-empty-database-revision
create-empty-database-revision: ## Create an empty database revision
@read -p "Please enter a message describing this revision: " rev_message; \
$(PYTHON) -m ihatemoney.manage db revision -d ihatemoney/migrations -m "$${rev_message}"
uv run python -m ihatemoney.manage db revision -d ihatemoney/migrations -m "$${rev_message}"

.PHONY: clean
clean: ## Destroy the virtual environment
rm -rf .venv

build-docs:
uv run --extra doc sphinx-build -a -n -b html -d docs/_build/doctrees docs docs/_build/html

.PHONY: help
help: ## Show the help indications
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ highly encouraged to do so.

## Requirements

- **Python**: version 3.7 to 3.12.
- **Python**: version 3.8 to 3.12.
- **Backends**: SQLite, PostgreSQL, MariaDB (version 10.3.2 or above),
Memory.

2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
@@ -183,7 +183,7 @@ We are using [black](https://black.readthedocs.io/en/stable/) and
Python files in this project. Be sure to run it locally on your files.
To do so, just run:

make black isort
make lint

You can also integrate them with your dev environment (as a
*format-on-save* hook, for instance).
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ Some Paas (Platform-as-a-Service), provide a documentation or even a quick insta

«Ihatemoney» depends on:

- **Python**: any version from 3.7 to 3.12 will work.
- **Python**: any version from 3.8 to 3.12 will work.
- **A database backend**: choose among SQLite, PostgreSQL, MariaDB (>=
10.3.2).
- **Virtual environment** (recommended): [python3-venv]{.title-ref}
1 change: 0 additions & 1 deletion ihatemoney/forms.py
Original file line number Diff line number Diff line change
@@ -90,7 +90,6 @@ def get_billform_for(project, set_default=True, **kwargs):


class CommaDecimalField(DecimalField):

"""A class to deal with comma in Decimal Field"""

def process_formdata(self, value):
2 changes: 1 addition & 1 deletion ihatemoney/run.py
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ def validate_configuration(app):
if "MAIL_DEFAULT_SENDER" not in app.config:
app.config["MAIL_DEFAULT_SENDER"] = default_settings.DEFAULT_MAIL_SENDER

if type(app.config["MAIL_DEFAULT_SENDER"]) == tuple:
if type(app.config["MAIL_DEFAULT_SENDER"]) is tuple:
(name, address) = app.config["MAIL_DEFAULT_SENDER"]
app.config["MAIL_DEFAULT_SENDER"] = f"{name} <{address}>"
warnings.warn(
1 change: 0 additions & 1 deletion ihatemoney/tests/api_test.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@


class TestAPI(IhatemoneyTestCase):

"""Tests the API"""

def api_create(
391 changes: 172 additions & 219 deletions ihatemoney/tests/budget_test.py

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions ihatemoney/utils.py
Original file line number Diff line number Diff line change
@@ -84,7 +84,6 @@ def flash_email_error(error_message, category="danger"):


class Redirect303(HTTPException, RoutingException):

"""Raise if the map requests a redirect. This is for example the case if
`strict_slashes` are activated and an url that requires a trailing slash.
@@ -102,7 +101,6 @@ def get_response(self, environ):


class PrefixedWSGI(object):

"""
Wrap the application in this middleware and configure the
front-end server to add these headers, to let you quietly bind
1 change: 1 addition & 0 deletions ihatemoney/web.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
some shortcuts to make your life better when coding (see `pull_project`
and `add_project_id` for a quick overview)
"""

import datetime
from functools import wraps
import hashlib
29 changes: 14 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ build-backend = "hatchling.build"
[project]
name = "ihatemoney"
version = "6.2.0.dev0"
requires-python = ">=3.8"
description = "A simple shared budget manager web application."
readme = "README.md"
license = {file = "LICENSE"}
@@ -15,7 +16,6 @@ keywords = ["web", "budget"]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
@@ -30,46 +30,41 @@ dependencies = [
"cachetools>=4.1,<5",
"debts>=0.5,<1",
"email_validator>=1.0,<3",
"Flask>=2,<3",
"Flask-Babel>=1.0,<4",
"Flask-Cors>=3.0.8,<4",
"Flask-Limiter>=2.6,<3",
"Flask-Mail>=0.9.1,<1",
"Flask-Migrate>=2.5.3,<5", # Not following semantic versioning (e.g. https://github.com/miguelgrinberg/flask-migrate/commit/1af28ba273de6c88544623b8dc02dd539340294b)
"Flask-Migrate>=2.5.3,<5", # Not following semantic versioning (e.g. https://github.com/miguelgrinberg/flask-migrate/commit/1af28ba273de6c88544623b8dc02dd539340294b)
"Flask-RESTful>=0.3.9,<1",
"Flask-SQLAlchemy>=2.4,<3",
"Flask-Talisman>=0.8,<2",
"Flask-WTF>=0.14.3,<2",
"WTForms>=2.3.3,<3.2",
"Flask>=2,<3",
"Werkzeug>=2,<3",
"itsdangerous>=2,<3",
"Jinja2>=3,<4",
"python-dateutil",
"qrcode>=7.1,<8",
"requests>=2.25,<3",
"SQLAlchemy-Continuum>=1.3.12,<2",
"SQLAlchemy>=1.3.0,<1.5", # New 1.4 changes API, see #728
"python-dateutil",
]
"SQLAlchemy>=1.3.0,<1.5",
"SQLAlchemy-Continuum>=1.3.12,<2", # New 1.4 changes API, see #728
"Werkzeug>=2,<3",
"WTForms>=2.3.3,<3.2",]

[project.optional-dependencies]
database = [
# Python 3.11 support starts in 2.9.2
"psycopg2-binary>=2.9.2,<3",
"psycopg2-binary>=2.9.2,<2.9.9",
"PyMySQL>=0.9,<1.1",
]

dev = [
"black==23.3.0",
"ruff==0.6.8",
"flake8==5.0.4",
"isort==5.11.5",
"vermin==1.5.2",
"pytest>=6.2.5",
"pytest-flask>=1.2.0",
"pytest-libfaketime>=0.1.2",
"tox>=3.14.6",
"zest.releaser>=6.20.1",
]

doc = [
"Sphinx>=7.0.1,<8",
"docutils==0.20.1",
@@ -107,3 +102,7 @@ include = [
"README.md",
"SECURITY.md",
]


[tool.ruff]
exclude = ["ihatemoney/migrations"]
41 changes: 0 additions & 41 deletions tox.ini

This file was deleted.

1,809 changes: 1,809 additions & 0 deletions uv.lock

Large diffs are not rendered by default.