nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

package.nix (5352B)


      1 {
      2   lib,
      3   fetchFromGitHub,
      4   makeWrapper,
      5   writeShellScript,
      6   python3Packages,
      7   cogeo-mosaic,
      8   geojson-pydantic,
      9   rio-cogeo,
     10   rio-stac,
     11   starlette-cramjam,
     12 }:
     13 let
     14   pname = "titiler";
     15   version = "2.2.1";
     16 
     17   src = fetchFromGitHub {
     18     owner = "developmentseed";
     19     repo = "titiler";
     20     tag = version;
     21     hash = "sha256-n/sCN+9KgNpsTGEVaU0ViiVRVOyDoxU00mLvoHTUYvg=";
     22   };
     23 
     24   meta = {
     25     description = "A modern dynamic tile server built on top of FastAPI and Rasterio/GDAL";
     26     homepage = "https://developmentseed.org/titiler/";
     27     license = lib.licenses.mit;
     28     maintainers = [ lib.maintainers.sikmir ];
     29   };
     30 
     31   titiler-core = python3Packages.buildPythonPackage (finalAttrs: {
     32     inherit version src meta;
     33     pname = "${pname}.core";
     34     sourceRoot = "${src.name}/src/titiler/core";
     35     pyproject = true;
     36 
     37     build-system = with python3Packages; [ hatchling ];
     38 
     39     pythonRelaxDeps = true;
     40 
     41     dependencies = with python3Packages; [
     42       fastapi
     43       starlette
     44       geojson-pydantic
     45       jinja2
     46       numpy
     47       pydantic
     48       rasterio
     49       rio-tiler
     50       morecantile
     51       simplejson
     52     ];
     53 
     54     optional-dependencies = {
     55       telemetry = with python3Packages; [
     56         opentelemetry-api
     57         opentelemetry-sdk
     58         opentelemetry-instrumentation-fastapi
     59         opentelemetry-instrumentation-logging
     60         opentelemetry-exporter-otlp
     61       ];
     62     };
     63 
     64     nativeCheckInputs = with python3Packages; [
     65       pytestCheckHook
     66       pytest-cov-stub
     67       pytest-asyncio
     68       httpx2
     69     ]
     70     ++ lib.flatten (builtins.attrValues finalAttrs.passthru.optional-dependencies);
     71 
     72     pytestFlags = [ "-pno:cacheprovider" ];
     73   });
     74 
     75   titiler-extensions = python3Packages.buildPythonPackage (finalAttrs: {
     76     inherit version src meta;
     77     pname = "${pname}.extensions";
     78     sourceRoot = "${src.name}/src/titiler/extensions";
     79     pyproject = true;
     80 
     81     build-system = with python3Packages; [ hatchling ];
     82 
     83     dependencies = [ titiler-core ];
     84 
     85     optional-dependencies = {
     86       cogeo = [ rio-cogeo ];
     87       stac = [ python3Packages.rio-stac ];
     88     };
     89 
     90     nativeCheckInputs =
     91       with python3Packages;
     92       [
     93         httpx2
     94         owslib
     95         pystac
     96         pytestCheckHook
     97         pytest-asyncio
     98         pytest-cov-stub
     99       ]
    100       ++ lib.flatten (builtins.attrValues finalAttrs.passthru.optional-dependencies);
    101 
    102     disabledTests = [
    103       "test_stacExtension" # requires network
    104     ];
    105   });
    106 
    107   titiler-mosaic = python3Packages.buildPythonPackage (finalAttrs: {
    108     inherit version src meta;
    109     pname = "${pname}.mosaic";
    110     sourceRoot = "${src.name}/src/titiler/mosaic";
    111     pyproject = true;
    112 
    113     build-system = with python3Packages; [ hatchling ];
    114 
    115     dependencies = [
    116       titiler-core
    117     ];
    118 
    119     optional-dependencies = {
    120       mosaicjson = [ cogeo-mosaic ];
    121     };
    122 
    123     nativeCheckInputs =
    124       with python3Packages;
    125       [
    126         httpx2
    127         owslib
    128         pytestCheckHook
    129         pytest-asyncio
    130         pytest-cov-stub
    131       ]
    132       ++ lib.flatten (builtins.attrValues finalAttrs.passthru.optional-dependencies);
    133   });
    134 
    135   titiler-xarray = python3Packages.buildPythonPackage (finalAttrs: {
    136     inherit version src meta;
    137     pname = "${pname}.xarray";
    138     sourceRoot = "${src.name}/src/titiler/xarray";
    139     pyproject = true;
    140 
    141     build-system = with python3Packages; [ hatchling ];
    142 
    143     dependencies = with python3Packages; [
    144       titiler-core
    145       xarray
    146       rioxarray
    147       obstore
    148       zarr
    149       starlette-cramjam
    150       pydantic-settings
    151       httpx2
    152     ];
    153 
    154     optional-dependencies = {
    155       fs = with python3Packages; [
    156         h5netcdf
    157         h5py
    158         fsspec
    159         s3fs
    160         aiohttp
    161         gcsfs
    162         requests
    163       ];
    164     };
    165 
    166     nativeCheckInputs =
    167       with python3Packages;
    168       [
    169         pytestCheckHook
    170       ]
    171       ++ lib.flatten (builtins.attrValues finalAttrs.passthru.optional-dependencies);
    172 
    173     disabledTests = [
    174       "test_io_fs_open_dataset"
    175       "test_io_open_zarr"
    176     ];
    177   });
    178 in
    179 python3Packages.buildPythonPackage (finalAttrs: {
    180   inherit
    181     pname
    182     version
    183     src
    184     meta
    185     ;
    186   sourceRoot = "${src.name}/src/titiler/application";
    187   pyproject = true;
    188 
    189   build-system = with python3Packages; [ hatchling ];
    190 
    191   nativeBuildInputs = [ makeWrapper ];
    192 
    193   dependencies = with python3Packages; [
    194     pydantic-settings
    195     starlette-cramjam
    196     titiler-core
    197     titiler-core.optional-dependencies.telemetry
    198     titiler-extensions
    199     titiler-extensions.optional-dependencies.cogeo
    200     titiler-extensions.optional-dependencies.stac
    201     titiler-mosaic
    202     titiler-mosaic.optional-dependencies.mosaicjson
    203     titiler-xarray
    204     titiler-xarray.optional-dependencies.fs
    205   ];
    206 
    207   nativeCheckInputs = with python3Packages; [
    208     boto3
    209     brotlipy
    210     pytestCheckHook
    211     pytest-asyncio
    212     pytest-cov-stub
    213   ];
    214 
    215   disabledTests = [
    216     "test_mosaic_auth_error" # requires network
    217   ];
    218 
    219   dontCheckPythonMetadata = true;
    220 
    221   postInstall =
    222     let
    223       start_script = writeShellScript "titiler-serve" ''
    224         ${lib.getExe python3Packages.uvicorn} "$@" titiler.application.main:app;
    225       '';
    226     in
    227     ''
    228       makeWrapper ${start_script} $out/bin/titiler-serve \
    229         --prefix PYTHONPATH : "$out/${python3Packages.python.sitePackages}" \
    230         --prefix PYTHONPATH : "${python3Packages.makePythonPath finalAttrs.passthru.dependencies}";
    231     '';
    232 })