diff --git a/pkgs/development/python-modules/geodatasets/default.nix b/pkgs/development/python-modules/geodatasets/default.nix new file mode 100644 index 000000000000..306c152dffa9 --- /dev/null +++ b/pkgs/development/python-modules/geodatasets/default.nix @@ -0,0 +1,54 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + pytestCheckHook, + pythonOlder, + + geopandas, + pooch, + pyogrio, + setuptools-scm, +}: + +buildPythonPackage rec { + pname = "geodatasets"; + version = "2023.12.0"; + pyproject = true; + disabled = pythonOlder "3.8"; + + src = fetchFromGitHub { + owner = "geopandas"; + repo = "geodatasets"; + rev = version; + hash = "sha256-yecAky3lCKcSgW4kkYTBNnyKyIWnGSBL600wVgGN8CE="; + }; + + build-system = [ setuptools-scm ]; + + propagatedBuildInputs = [ pooch ]; + + nativeCheckInputs = [ + geopandas + pyogrio + pytestCheckHook + ]; + + preCheck = '' + export HOME=$TMPDIR + ''; + + pytestFlagsArray = [ + # disable tests which require network access + "-m 'not request'" + ]; + + pythonImportsCheck = [ "geodatasets" ]; + + meta = { + description = "Spatial data examples"; + homepage = "https://geodatasets.readthedocs.io/"; + license = lib.licenses.bsd3; + maintainers = lib.teams.geospatial.members; + }; +} diff --git a/pkgs/development/python-modules/libpysal/default.nix b/pkgs/development/python-modules/libpysal/default.nix new file mode 100644 index 000000000000..af52f048cb96 --- /dev/null +++ b/pkgs/development/python-modules/libpysal/default.nix @@ -0,0 +1,86 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + pytestCheckHook, + pythonOlder, + + beautifulsoup4, + fiona, + geodatasets, + geopandas, + numpy, + packaging, + pandas, + platformdirs, + requests, + scikit-learn, + scipy, + setuptools-scm, + shapely, +}: + +buildPythonPackage rec { + pname = "libpysal"; + version = "4.10"; + pyproject = true; + disabled = pythonOlder "3.10"; + + src = fetchFromGitHub { + owner = "pysal"; + repo = "libpysal"; + rev = "v${version}"; + hash = "sha256-jzSkIFSIXc039KR4fS1HOI/Rj0mHwbArn2hD+zfAZDg="; + }; + + build-system = [ setuptools-scm ]; + + propagatedBuildInputs = [ + beautifulsoup4 + fiona + geopandas + numpy + packaging + pandas + platformdirs + requests + scikit-learn + scipy + shapely + ]; + + nativeCheckInputs = [ + geodatasets + pytestCheckHook + ]; + + preCheck = '' + export HOME=$TMPDIR + ''; + + # requires network access + disabledTestPaths = [ + "libpysal/cg/tests/test_geoJSON.py" + "libpysal/examples/tests/test_available.py" + "libpysal/graph/tests/test_base.py" + "libpysal/graph/tests/test_builders.py" + "libpysal/graph/tests/test_contiguity.py" + "libpysal/graph/tests/test_kernel.py" + "libpysal/graph/tests/test_matching.py" + "libpysal/graph/tests/test_plotting.py" + "libpysal/graph/tests/test_triangulation.py" + "libpysal/graph/tests/test_utils.py" + "libpysal/graph/tests/test_set_ops.py" + "libpysal/weights/tests/test_contiguity.py" + "libpysal/weights/tests/test_util.py" + ]; + + pythonImportsCheck = [ "libpysal" ]; + + meta = { + description = "A library of spatial analysis functions"; + homepage = "https://pysal.org/libpysal/"; + license = lib.licenses.bsd3; + maintainers = lib.teams.geospatial.members; + }; +} diff --git a/pkgs/development/python-modules/mapclassify/default.nix b/pkgs/development/python-modules/mapclassify/default.nix new file mode 100644 index 000000000000..0045daf1bd9f --- /dev/null +++ b/pkgs/development/python-modules/mapclassify/default.nix @@ -0,0 +1,58 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + pytestCheckHook, + pythonOlder, + + geopandas, + libpysal, + networkx, + numpy, + pandas, + scikit-learn, + scipy, + setuptools-scm, +}: + +buildPythonPackage rec { + pname = "mapclassify"; + version = "2.6.1"; + pyproject = true; + disabled = pythonOlder "3.9"; + + src = fetchFromGitHub { + owner = "pysal"; + repo = "mapclassify"; + rev = "v${version}"; + hash = "sha256-lb2Ui6zdx6MQBtBrL/Xj9k7cm6De8aLEuBLZDhPPDnE="; + }; + + build-system = [ setuptools-scm ]; + + propagatedBuildInputs = [ + networkx + numpy + pandas + scikit-learn + scipy + ]; + + nativeCheckInputs = [ + pytestCheckHook + geopandas + libpysal + ]; + + # requires network access + disabledTestPaths = [ "mapclassify/tests/test_greedy.py" ]; + + pythonImportsCheck = [ "mapclassify" ]; + + meta = { + description = "Classification Schemes for Choropleth Maps"; + homepage = "https://pysal.org/mapclassify/"; + license = lib.licenses.bsd3; + maintainers = lib.teams.geospatial.members; + }; +} diff --git a/pkgs/development/python-modules/pyogrio/default.nix b/pkgs/development/python-modules/pyogrio/default.nix new file mode 100644 index 000000000000..551fde29bafe --- /dev/null +++ b/pkgs/development/python-modules/pyogrio/default.nix @@ -0,0 +1,75 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + pytestCheckHook, + pythonOlder, + + certifi, + cython, + gdal, + numpy, + packaging, + setuptools, + versioneer, + wheel, +}: + +buildPythonPackage rec { + pname = "pyogrio"; + version = "0.8.0"; + pyproject = true; + disabled = pythonOlder "3.8"; + + src = fetchFromGitHub { + owner = "geopandas"; + repo = "pyogrio"; + rev = "v${version}"; + hash = "sha256-h4Rv5xOWSJSv0nLbosviz5EiF/IsZO5wzBel9YRd0Bg="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail "versioneer[toml]==0.28" "versioneer[toml]" + '' + lib.optionalString (!pythonOlder "3.12") '' + substituteInPlace setup.py \ + --replace-fail "distutils" "setuptools._distutils" + ''; + + nativeBuildInputs = [ + cython + gdal # for gdal-config + setuptools + versioneer + wheel + ] ++ versioneer.optional-dependencies.toml; + + buildInputs = [ gdal ]; + + propagatedBuildInputs = [ + certifi + numpy + packaging + ]; + + nativeCheckInputs = [ pytestCheckHook ]; + + preCheck = '' + python setup.py build_ext --inplace + ''; + + pytestFlagsArray = [ + # disable tests which require network access + "-m 'not network'" + ]; + + pythonImportsCheck = [ "pyogrio" ]; + + meta = { + description = "Vectorized spatial vector file format I/O using GDAL/OGR"; + homepage = "https://pyogrio.readthedocs.io/"; + changelog = "https://github.com/geopandas/pyogrio/blob/${src.rev}/CHANGES.md"; + license = lib.licenses.mit; + maintainers = lib.teams.geospatial.members; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index b0f21083b14d..34a33f42bf42 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4711,6 +4711,8 @@ self: super: with self; { geocoder = callPackage ../development/python-modules/geocoder { }; + geodatasets = callPackage ../development/python-modules/geodatasets { }; + geographiclib = callPackage ../development/python-modules/geographiclib { }; geoip2 = callPackage ../development/python-modules/geoip2 { }; @@ -6690,6 +6692,8 @@ self: super: with self; { libpyfoscam = callPackage ../development/python-modules/libpyfoscam { }; + libpysal = callPackage ../development/python-modules/libpysal { }; + libpyvivotek = callPackage ../development/python-modules/libpyvivotek { }; libpwquality = lib.pipe pkgs.libpwquality [ @@ -7170,6 +7174,8 @@ self: super: with self; { mapbox-earcut = callPackage ../development/python-modules/mapbox-earcut { }; + mapclassify = callPackage ../development/python-modules/mapclassify { }; + mariadb = callPackage ../development/python-modules/mariadb { }; marimo = callPackage ../development/python-modules/marimo { }; @@ -9996,6 +10002,8 @@ self: super: with self; { pynx584 = callPackage ../development/python-modules/pynx584 { }; + pyogrio = callPackage ../development/python-modules/pyogrio { }; + pyorthanc = callPackage ../development/python-modules/pyorthanc { }; pyoutbreaksnearme = callPackage ../development/python-modules/pyoutbreaksnearme { };