pyramids-mesh 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ """Mesh file-format drivers for the pyramids stack.
2
+
3
+ `pyramids-mesh` reads and writes the file formats of hydrodynamic and hydraulic
4
+ mesh models — 2DM, Selafin, DFSU, XMDF, PLY and the rest of MDAL's driver table —
5
+ as `pyramids.netcdf.ugrid` objects. `pyramids.netcdf.ugrid` owns the UGRID data
6
+ model (`Mesh2d`, `Network1d`, `UgridDataset`), its NetCDF I/O, and every operation
7
+ that follows from a topology already in hand — connectivity and graph algorithms,
8
+ regridding and sampling, gap filling, mesh-to-vector conversion, and construction
9
+ from a raster or a polygon layer. What it cannot do is open other people's mesh
10
+ files; that is this package's job, and its only job.
11
+
12
+ Drivers are discovered by `pyramids-gis` through the `pyramids.mesh_drivers`
13
+ entry-point group, so `UgridDataset.read_file("model.slf")` resolves to a driver
14
+ here once this package is installed. Dependency-backed drivers sit behind extras
15
+ (`[dhi]`) and are skipped at discovery when their extra
16
+ is absent. See ADR-0005 for the scope decision.
17
+
18
+ The package root deliberately re-exports nothing: it carries `__version__` and the
19
+ import contract that activates the vendored osgeo bindings, and that is all. Installing
20
+ the package is the whole integration, so nothing here needs importing. A driver class is
21
+ still reachable by its module path (`pyramids_mesh.drivers.sms.TwoDmDriver`, which is how
22
+ its entry point names it) for the rare case of wanting one directly.
23
+
24
+ Examples:
25
+ - The root carries the installed version and nothing else. `__all__` is empty
26
+ because there is deliberately nothing to re-export:
27
+
28
+ >>> import pyramids_mesh
29
+ >>> pyramids_mesh.__version__.split(".")[0].isdigit()
30
+ True
31
+ >>> pyramids_mesh.__all__
32
+ []
33
+
34
+ - A driver is reached by its module path, not from the root, and reports the
35
+ suffixes it claims:
36
+
37
+ >>> from pyramids_mesh.drivers.sms import TwoDmDriver
38
+ >>> TwoDmDriver.name
39
+ '2dm'
40
+ >>> TwoDmDriver.suffixes
41
+ ('.2dm',)
42
+ """
43
+
44
+ # Import pyramids FIRST — before anything else, and keep it first. pyramids-gis
45
+ # bundles GDAL's osgeo SWIG bindings and native libs inside its platform wheel
46
+ # and activates them on import (puts `_vendor/osgeo` on sys.path, sets
47
+ # GDAL_DATA / PROJ_DATA, registers the Windows DLL directory). Any module here
48
+ # that does `from osgeo import gdal` at load time needs this line to have run
49
+ # first, or that import fails wherever no separate GDAL is installed.
50
+ import pyramids # noqa: F401
51
+
52
+ try:
53
+ from importlib.metadata import PackageNotFoundError # type: ignore
54
+ from importlib.metadata import version
55
+ except ImportError: # pragma: no cover
56
+ from importlib_metadata import PackageNotFoundError # type: ignore
57
+ from importlib_metadata import version
58
+
59
+
60
+ # The distribution name, not `__name__`: the import name is `pyramids_mesh` and
61
+ # the distribution is `pyramids-mesh`. importlib.metadata normalizes `_` to `-`
62
+ # so either spelling resolves today, but the metadata lookup is a distribution
63
+ # lookup — spell it the way the metadata does.
64
+ try:
65
+ __version__ = version("pyramids-mesh")
66
+ except PackageNotFoundError: # pragma: no cover
67
+ __version__ = "unknown"
68
+
69
+
70
+ __all__: list[str] = []