diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index fd746b0..9c4ff78 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - debian-version: ['11', '12'] + debian-version: ['11', '12', '13'] sqlalchemy-version: ['1.4'] include: - debian-version: '11' @@ -28,6 +28,10 @@ jobs: python-version: '3.11' postgres-version: '15' postgis-version: '3.3' + - debian-version: '13' + python-version: '3.13' + postgres-version: '17' + postgis-version: '3.5' name: Debian ${{ matrix.debian-version}} - SQLAlchemy ${{ matrix.sqlalchemy-version }} diff --git a/requirements.in b/requirements.in index 5f64597..2a4a1aa 100755 --- a/requirements.in +++ b/requirements.in @@ -7,3 +7,4 @@ sqlalchemy>=1.4,<2 utils-flask-sqlalchemy>=0.4.1 utils-flask-sqlalchemy-geo>=0.3.2 psycopg2 +backports.entry-points-selectable # could be removed we drop of py3.9 support diff --git a/src/ref_geo/__init__.py b/src/ref_geo/__init__.py index 062a035..047811d 100644 --- a/src/ref_geo/__init__.py +++ b/src/ref_geo/__init__.py @@ -1,7 +1,9 @@ import json import os from pathlib import Path -from pkg_resources import iter_entry_points + +# after drop support of py3.9, replace with from importlib.metadata import entry_point +from backports.entry_points_selectable import entry_points from flask import Flask, current_app, request from flask_migrate import Migrate @@ -18,9 +20,8 @@ def configure_alembic(alembic_config): alembic_config.set_main_option("sqlalchemy.url", current_app.config["SQLALCHEMY_DATABASE_URI"]) version_locations = alembic_config.get_main_option("version_locations", default="").split() - for entry_point in iter_entry_points("alembic", "migrations"): - _, migrations = str(entry_point).split("=", 1) - version_locations += [migrations.strip()] + for entry_point in entry_points(group="alembic", name="migrations"): + version_locations += [entry_point.value] alembic_config.set_main_option("version_locations", " ".join(version_locations)) return alembic_config diff --git a/src/ref_geo/migrations/alembic.ini b/src/ref_geo/migrations/alembic.ini index fc2c70e..d939da2 100644 --- a/src/ref_geo/migrations/alembic.ini +++ b/src/ref_geo/migrations/alembic.ini @@ -2,10 +2,14 @@ [alembic] # path to migration scripts +# Use forward slashes (/) also on windows to provide an os agnostic path script_location = ref_geo:migrations -# template used to generate migration files -# file_template = %%(rev)s_%%(slug)s +# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s +# Uncomment the line below if you want the files to be prepended with date and time +# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file +# for all available tokens +# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s # sys.path path, will be prepended to sys.path if present. # defaults to the current working directory. @@ -13,19 +17,18 @@ prepend_sys_path = . # timezone to use when rendering the date within the migration file # as well as the filename. -# If specified, requires the python-dateutil library that can be -# installed by adding `alembic[tz]` to the pip requirements -# string value is passed to dateutil.tz.gettz() +# If specified, requires the python>=3.9 or backports.zoneinfo library and tzdata library. +# Any required deps can installed by adding `alembic[tz]` to the pip requirements +# string value is passed to ZoneInfo() # leave blank for localtime # timezone = -# max length of characters to apply to the -# "slug" field +# max length of characters to apply to the "slug" field # truncate_slug_length = 40 # set to 'true' to run the environment during # the 'revision' command, regardless of autogenerate -revision_environment = true +# revision_environment = false # set to 'true' to allow .pyc and .pyo files without # a source .py file to be detected as revisions in the @@ -33,10 +36,10 @@ revision_environment = true # sourceless = false # version location specification; This defaults -# to alembic//versions. When using multiple version +# to test/versions. When using multiple version # directories, initial revisions must be specified with --version-path. # The path separator used here should be the separator specified by "version_path_separator" below. -# version_locations = %(here)s/bar:%(here)s/bat:alembic//versions +# version_locations = %(here)s/bar:%(here)s/bat:test/versions # version path separator; As mentioned above, this is the character used to split # version_locations. The default within new alembic.ini files is "os", which uses os.pathsep. @@ -46,8 +49,15 @@ revision_environment = true # version_path_separator = : # version_path_separator = ; version_path_separator = space +# version_path_separator = newline +# # Use os.pathsep. Default configuration used for new projects. -#version_path_separator = os +# version_path_separator = os + +# set to 'true' to search source files recursively +# in each "version_locations" directory +# new in Alembic version 1.10 +# recursive_version_locations = false # the output encoding used when revision files # are written from script.py.mako @@ -65,6 +75,12 @@ version_path_separator = space # black.entrypoint = black # black.options = -l 79 REVISION_SCRIPT_FILENAME +# lint with attempts to fix using "ruff" - use the exec runner, execute a binary +# hooks = ruff +# ruff.type = exec +# ruff.executable = %(here)s/.venv/bin/ruff +# ruff.options = check --fix REVISION_SCRIPT_FILENAME + # Logging configuration [loggers] keys = root,sqlalchemy,alembic @@ -76,12 +92,12 @@ keys = console keys = generic [logger_root] -level = WARN +level = WARNING handlers = console qualname = [logger_sqlalchemy] -level = WARN +level = WARNING handlers = qualname = sqlalchemy.engine diff --git a/src/ref_geo/migrations/env.py b/src/ref_geo/migrations/env.py index 9cd4aca..9f53eb1 100644 --- a/src/ref_geo/migrations/env.py +++ b/src/ref_geo/migrations/env.py @@ -1,5 +1,5 @@ import os -from pkg_resources import iter_entry_points +from backports.entry_points_selectable import entry_points from logging.config import fileConfig from sqlalchemy import engine_from_config @@ -15,14 +15,14 @@ if sqlalchemy_database_uri: config.set_main_option("sqlalchemy.url", sqlalchemy_database_uri) version_locations = set(config.get_main_option("version_locations", default="").split()) -for entry_point in iter_entry_points("alembic", "migrations"): - _, migrations = str(entry_point).split("=", 1) - version_locations.add(migrations.strip()) +for entry_point in entry_points(group="alembic", name="migrations"): + version_locations.add(entry_point.value) context.script.version_locations = list(version_locations) # Interpret the config file for Python logging. # This line sets up loggers basically. -fileConfig(config.config_file_name) +if config.config_file_name is not None: + fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support @@ -36,7 +36,7 @@ # ... etc. -def run_migrations_offline(): +def run_migrations_offline() -> None: """Run migrations in 'offline' mode. This configures the context with just a URL @@ -60,7 +60,7 @@ def run_migrations_offline(): context.run_migrations() -def run_migrations_online(): +def run_migrations_online() -> None: """Run migrations in 'online' mode. In this scenario we need to create an Engine @@ -68,7 +68,7 @@ def run_migrations_online(): """ connectable = engine_from_config( - config.get_section(config.config_ini_section), + config.get_section(config.config_ini_section, {}), prefix="sqlalchemy.", poolclass=pool.NullPool, ) diff --git a/src/ref_geo/migrations/versions/dea1645de8c0_ref_geo_point.py b/src/ref_geo/migrations/versions/dea1645de8c0_ref_geo_point.py index 9a5be56..6d30919 100644 --- a/src/ref_geo/migrations/versions/dea1645de8c0_ref_geo_point.py +++ b/src/ref_geo/migrations/versions/dea1645de8c0_ref_geo_point.py @@ -1,4 +1,4 @@ -""" Référentiel point, cor (area, linear, point) +"""Référentiel point, cor (area, linear, point) Revision ID: dea1645de8c0 Revises: f7374cd6e38d diff --git a/src/ref_geo/utils.py b/src/ref_geo/utils.py index b513c19..6555dba 100644 --- a/src/ref_geo/utils.py +++ b/src/ref_geo/utils.py @@ -1,6 +1,6 @@ """ - methodes pour ref_geo - - recupération du srid local +methodes pour ref_geo + - recupération du srid local """ from sqlalchemy import text