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
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
platform: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- # No pybind11-rdp wheel available for Python 3.14 on windows
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Python: 3.9, 3.10, 3.11, 3.12, 3.13, 3.14](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://www.python.org)
[![Python: 3.10, 3.11, 3.12, 3.13, 3.14](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://www.python.org)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/pyhgtmap)
![GitHub](https://img.shields.io/github/license/agrenott/pyhgtmap)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/agrenott/pyhgtmap/pythonpackage.yaml)
Expand Down
4 changes: 3 additions & 1 deletion pyhgtmap/NASASRTMUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def calc_bbox(area: str, corrx: float = 0.0, corry: float = 0.0) -> IntBBox:
"""Parse bounding box string and calculates the appropriate bounding box for the needed files"""
min_lon, min_lat, max_lon, max_lat = [
float(value) - inc
for value, inc in zip(area.split(":"), [corrx, corry, corrx, corry])
for value, inc in zip(
area.split(":"), [corrx, corry, corrx, corry], strict=True
)
]
if min_lon < 0:
bbox_min_lon = int(min_lon) if min_lon % 1 == 0 else int(min_lon) - 1
Expand Down
3 changes: 1 addition & 2 deletions pyhgtmap/hgt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

from collections.abc import Iterable
from collections.abc import Callable, Iterable
from math import isclose
from typing import Callable

from pyhgtmap import BBox, Coordinates

Expand Down
3 changes: 2 additions & 1 deletion pyhgtmap/hgt/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import logging
import multiprocessing
from typing import TYPE_CHECKING, Callable, cast
from typing import TYPE_CHECKING, cast

from pyhgtmap.hgt.file import HgtFile
from pyhgtmap.output.factory import get_osm_output

if TYPE_CHECKING:
from collections.abc import Callable
from multiprocessing.context import ForkProcess # type: ignore[attr-defined]
from multiprocessing.sharedctypes import Synchronized

Expand Down
4 changes: 3 additions & 1 deletion pyhgtmap/output/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Any, Callable, NamedTuple
from typing import TYPE_CHECKING, Any, NamedTuple

import numpy
from nptyping import NDArray, Structure

if TYPE_CHECKING:
from collections.abc import Callable

from pyhgtmap.hgt.tile import TileContours

logger = logging.getLogger(__name__)
Expand Down
4 changes: 3 additions & 1 deletion pyhgtmap/output/o5mUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import ast
import time
from typing import TYPE_CHECKING, Callable
from typing import TYPE_CHECKING

import pyhgtmap.output
from pyhgtmap import output
from pyhgtmap.varint import int2str, join, sint2str, writableInt, writableString

if TYPE_CHECKING:
from collections.abc import Callable

from pyhgtmap import BBox
from pyhgtmap.hgt.tile import TileContours

Expand Down
3 changes: 2 additions & 1 deletion pyhgtmap/output/osmUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import datetime
import time
from typing import TYPE_CHECKING, Callable
from typing import TYPE_CHECKING

import numpy

Expand All @@ -11,6 +11,7 @@
from pyhgtmap.varint import writableString

if TYPE_CHECKING:
from collections.abc import Callable
from io import IOBase

from pyhgtmap.hgt.tile import TileContours
Expand Down
4 changes: 3 additions & 1 deletion pyhgtmap/output/pbfUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import os
import time
from typing import TYPE_CHECKING, Callable
from typing import TYPE_CHECKING

import npyosmium
import npyosmium.io
Expand All @@ -15,6 +15,8 @@
import pyhgtmap.output

if TYPE_CHECKING:
from collections.abc import Callable

from pyhgtmap import BBox
from pyhgtmap.hgt.tile import TileContours

Expand Down
9 changes: 6 additions & 3 deletions pyhgtmap/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING

from class_registry import AutoRegister, ClassRegistry
from class_registry import ClassRegistry
from class_registry.base import AutoRegister

if TYPE_CHECKING:
import configargparse
Expand All @@ -23,7 +24,9 @@


# This registry will return a new instance for each get
SOURCES_TYPES_REGISTRY = ClassRegistry(attr_name="NICKNAME", unique=True)
SOURCES_TYPES_REGISTRY: ClassRegistry = ClassRegistry["Source"](
attr_name="NICKNAME", unique=True
)


class ArgparsePassword(argparse.Action):
Expand All @@ -36,7 +39,7 @@ def __call__(self, parser, namespace, values, option_string=None) -> None:
setattr(namespace, self.dest, values)


class Source(ABC, metaclass=AutoRegister(SOURCES_TYPES_REGISTRY)): # type: ignore[metaclass] # Mypy does not understand dynamically-computed metaclasses
class Source(AutoRegister(SOURCES_TYPES_REGISTRY), ABC): # type: ignore[misc] # Mypy does not understand dynamically-computed base classes
"""HGT source base class"""

# Source's 'nickname', used to identify it from the command line and
Expand Down
12 changes: 7 additions & 5 deletions pyhgtmap/sources/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
from itertools import chain
from typing import TYPE_CHECKING, cast

from class_registry import ClassRegistry, ClassRegistryInstanceCache
from class_registry.cache import ClassRegistryInstanceCache

from pyhgtmap.sources import SOURCES_TYPES_REGISTRY, Source

if TYPE_CHECKING:
from collections.abc import Generator, Iterator
from collections.abc import Generator, Iterable, Iterator

from class_registry import ClassRegistry

from pyhgtmap.configuration import Configuration

Expand All @@ -26,7 +28,7 @@ class Pool:

# Keep a reference on the source registry as the cached version
# do not expose all methods...
_inner_registry: ClassRegistry = SOURCES_TYPES_REGISTRY
_inner_registry: ClassRegistry[Source] = SOURCES_TYPES_REGISTRY

def __init__(
self, cache_dir_root: str, config_dir: str, configuration: Configuration
Expand Down Expand Up @@ -71,9 +73,9 @@ def __iter__(self) -> Iterator[Source]:
yield from cast("Iterator[Source]", self._cached_registry)

@classmethod
def registered_sources(cls) -> Generator[type[Source], None, None]:
def registered_sources(cls) -> Iterable[type[Source]]:
"""Returns a generator of registered sources types."""
return cls._inner_registry.values()
return cls._inner_registry.classes()


# Force import of all implementations to register them in the pool
Expand Down
108 changes: 53 additions & 55 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,52 @@ requires = ["hatchling", "hatch-vcs"]

[project]
authors = [
{ name = "Adrian Dempwolff", email = "phyghtmap@aldw.de" },
{ name = "Aurélien Grenotton", email = "agrenott@gmail.com" },
{ name = "Adrian Dempwolff", email = "phyghtmap@aldw.de" },
{ name = "Aurélien Grenotton", email = "agrenott@gmail.com" },
]
classifiers = [
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Topic :: Scientific/Engineering :: GIS",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Topic :: Scientific/Engineering :: GIS",
]
dependencies = [
"bs4>=0.0.1",
"colorlog>=6.7.0",
"configargparse>=1.7",
"contourpy>=1.0.7",
"httpx>=0.27.0",
"lxml>=4.9.2",
"matplotlib>=3.4.3",
"matplotlib>=3.10.0 ; python_version >= '3.13'",
"numpy>=1.24.2",
# Use recent numpy version for python >= 3.13, to avoid building numpy from source in the CI
"numpy>=2.3.0 ; python_version >= '3.13'",
"nptyping>=2.5.0 ; python_version < '3.13'",
"np2typing>=2.6.0 ; python_version >= '3.13'",
"npyosmium>=4.2.0",
# Pin phx-class-registry version to 4.x to keep python 3.9 support
# https://class-registry.readthedocs.io/en/latest/upgrading_to_v5.html
"phx-class-registry>=4.0.6, <5",
"pybind11-rdp>=0.1.3",
"PyDrive2>=1.20.0",
"scipy>=1.8.0",
"shapely>=2.0.1",
"bs4>=0.0.1",
"colorlog>=6.7.0",
"configargparse>=1.7",
"contourpy>=1.0.7",
"httpx>=0.27.0",
"lxml>=4.9.2",
"matplotlib>=3.4.3",
"matplotlib>=3.10.0 ; python_version >= '3.13'",
"numpy>=1.24.2",
# Use recent numpy version for python >= 3.13, to avoid building numpy from source in the CI
"numpy>=2.3.0 ; python_version >= '3.13'",
"nptyping>=2.5.0 ; python_version < '3.13'",
"np2typing>=2.6.0 ; python_version >= '3.13'",
"npyosmium>=4.2.0",
"phx-class-registry>=5.0.0",
"pybind11-rdp>=0.1.3",
"PyDrive2>=1.20.0",
"scipy>=1.8.0",
"shapely>=2.0.1",
]
description = "Creates OpenStreetMap suitable contour lines from NASA SRTM data"
dynamic = ["version"]
keywords = ["osm", "OpenStreetMap", "countour", "SRTM", "elevation"]
license = "GPL-2.0-or-later"
name = "pyhgtmap"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"

[project.optional-dependencies]
geotiff = [
# Do NOT pin GDAL version to ease installing it via OS package manager (due to many dependencies)
"GDAL",
# Do NOT pin GDAL version to ease installing it via OS package manager (due to many dependencies)
"GDAL",
]

[project.scripts]
Expand All @@ -71,40 +69,40 @@ installer = "uv"

# Use default env for all dev activities
dependencies = [
"pytest>=7.0.1 ; python_version < '3.13'",
"pytest>=8.4.0 ; python_version >= '3.13'",
"pytest-cov~=7.0.0",
"pytest_httpx>=0.30.0",
"pytest-mpl~=0.16.1",
"pytest-sugar>=0.9.7",
"pytest-xdist>=3.5.0",
"types-beautifulsoup4>=4",
"mypy>=1.0.1",
"mypy-extensions~=1.0.0",
"ruff>=0.6.4",
"uv",
"pip",
"setuptools",
"pytest>=7.0.1 ; python_version < '3.13'",
"pytest>=8.4.0 ; python_version >= '3.13'",
"pytest-cov~=7.0.0",
"pytest_httpx>=0.30.0",
"pytest-mpl~=0.16.1",
"pytest-sugar>=0.9.7",
"pytest-xdist>=3.5.0",
"types-beautifulsoup4>=4",
"mypy>=1.0.1",
"mypy-extensions~=1.0.0",
"ruff>=0.6.4",
"uv",
"pip",
"setuptools",
]

[tool.hatch.envs.default.scripts]
all = ["style", "typing", "test_cov"]
fmt = [
# Sort imports - https://docs.astral.sh/ruff/formatter/#sorting-imports
"ruff check --select I --fix {args:pyhgtmap tests tools}",
"ruff format {args:pyhgtmap tests tools}",
"style",
# Sort imports - https://docs.astral.sh/ruff/formatter/#sorting-imports
"ruff check --select I --fix {args:pyhgtmap tests tools}",
"ruff format {args:pyhgtmap tests tools}",
"style",
]
style = [
"ruff check {args:pyhgtmap tests tools}",
"ruff format --check --diff {args:pyhgtmap tests tools}",
"ruff check {args:pyhgtmap tests tools}",
"ruff format --check --diff {args:pyhgtmap tests tools}",
]
test = "pytest {args:tests}"
test_cov = ["pytest --mpl --cov --cov-report xml --cov-report term"]
typing = "mypy {args}"

[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
python = ["3.10", "3.11", "3.12", "3.13", "3.14"]

[tool.hatch.envs.geotiff]
# Env for optional geotiff dependencies
Expand Down
Loading
Loading