Skip to content

compat. python 3.13 #38

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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: 5 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }}

Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions src/ref_geo/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
42 changes: 29 additions & 13 deletions src/ref_geo/migrations/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,44 @@

[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.
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
# versions/ directory
# 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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
16 changes: 8 additions & 8 deletions src/ref_geo/migrations/env.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -60,15 +60,15 @@ 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
and associate a connection with the context.

"""
connectable = engine_from_config(
config.get_section(config.config_ini_section),
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/ref_geo/utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down