about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/pyproj
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/pyproj')
-rw-r--r--nixpkgs/pkgs/development/python-modules/pyproj/001.proj.patch48
-rw-r--r--nixpkgs/pkgs/development/python-modules/pyproj/default.nix115
2 files changed, 163 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/pyproj/001.proj.patch b/nixpkgs/pkgs/development/python-modules/pyproj/001.proj.patch
new file mode 100644
index 000000000000..38061b61addf
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/pyproj/001.proj.patch
@@ -0,0 +1,48 @@
+diff --git a/pyproj/datadir.py b/pyproj/datadir.py
+index df625fee..a2beb06c 100644
+--- a/pyproj/datadir.py
++++ b/pyproj/datadir.py
+@@ -70,7 +70,7 @@ def get_data_dir() -> str:
+     global _VALIDATED_PROJ_DATA
+     if _VALIDATED_PROJ_DATA is not None:
+         return _VALIDATED_PROJ_DATA
+-    internal_datadir = Path(__file__).absolute().parent / "proj_dir" / "share" / "proj"
++    internal_datadir = Path("@proj@/share/proj")
+     proj_lib_dirs = os.environ.get("PROJ_DATA", os.environ.get("PROJ_LIB", ""))
+     prefix_datadir = Path(sys.prefix, "share", "proj")
+     conda_windows_prefix_datadir = Path(sys.prefix, "Library", "share", "proj")
+diff --git a/setup.py b/setup.py
+index 71fb52cd..7984a68a 100644
+--- a/setup.py
++++ b/setup.py
+@@ -13,7 +13,7 @@ from setuptools import Extension, setup
+ PROJ_MIN_VERSION = parse_version("8.2.0")
+ CURRENT_FILE_PATH = Path(__file__).absolute().parent
+ BASE_INTERNAL_PROJ_DIR = Path("proj_dir")
+-INTERNAL_PROJ_DIR = CURRENT_FILE_PATH / "pyproj" / BASE_INTERNAL_PROJ_DIR
++INTERNAL_PROJ_DIR = Path("@proj@")
+ PROJ_VERSION_SEARCH = re.compile(r".*Rel\.\s+(?P<version>\d+\.\d+\.\d+).*")
+ 
+ 
+@@ -163,7 +163,7 @@ def get_extension_modules():
+     # By default we'll try to get options PROJ_DIR or the local version of proj
+     proj_dir = get_proj_dir()
+     library_dirs = get_proj_libdirs(proj_dir)
+-    include_dirs = get_proj_incdirs(proj_dir)
++    include_dirs = get_proj_incdirs(Path("@projdev@"))
+ 
+     proj_version = get_proj_version(proj_dir)
+     check_proj_version(proj_version)
+diff --git a/test/test_cli.py b/test/test_cli.py
+index 7a696de7..1b9b777b 100644
+--- a/test/test_cli.py
++++ b/test/test_cli.py
+@@ -14,7 +14,7 @@ from pyproj.sync import _load_grid_geojson
+ from test.conftest import grids_available, proj_env, tmp_chdir
+ 
+ PYPROJ_CLI_ENDPONTS = pytest.mark.parametrize(
+-    "input_command", [["pyproj"], [sys.executable, "-m", "pyproj"]]
++    "input_command", [[sys.executable, "-m", "pyproj"]]
+ )
+ 
+ 
diff --git a/nixpkgs/pkgs/development/python-modules/pyproj/default.nix b/nixpkgs/pkgs/development/python-modules/pyproj/default.nix
new file mode 100644
index 000000000000..bb98e96e02a1
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/pyproj/default.nix
@@ -0,0 +1,115 @@
+{ lib
+, buildPythonPackage
+, fetchFromGitHub
+, python
+, proj
+, pythonOlder
+, substituteAll
+, cython
+, pytestCheckHook
+, mock
+, certifi
+, numpy
+, shapely
+, pandas
+, xarray
+}:
+
+buildPythonPackage rec {
+  pname = "pyproj";
+  version = "3.6.1";
+  format = "setuptools";
+  disabled = pythonOlder "3.9";
+
+  src = fetchFromGitHub {
+    owner = "pyproj4";
+    repo = "pyproj";
+    rev = "refs/tags/${version}";
+    hash = "sha256-ynAhu89VpvtQJRkIeVyffQHhd+OvWSiZzaI/7nd6fXA=";
+  };
+
+  # force pyproj to use ${proj}
+  patches = [
+    (substituteAll {
+      src = ./001.proj.patch;
+      proj = proj;
+      projdev = proj.dev;
+    })
+  ];
+
+  nativeBuildInputs = [ cython ];
+  buildInputs = [ proj ];
+
+  propagatedBuildInputs = [
+     certifi
+  ];
+
+  nativeCheckInputs = [
+    pytestCheckHook
+    mock
+    numpy
+    shapely
+    pandas
+    xarray
+  ];
+
+  preCheck = ''
+    # import from $out
+    rm -r pyproj
+  '';
+
+  disabledTestPaths = [
+    "test/test_doctest_wrapper.py"
+    "test/test_datadir.py"
+  ];
+
+  disabledTests = [
+    # The following tests try to access network and end up with a URLError
+    "test__load_grid_geojson_old_file"
+    "test_get_transform_grid_list"
+    "test_get_transform_grid_list__area_of_use"
+    "test_get_transform_grid_list__bbox__antimeridian"
+    "test_get_transform_grid_list__bbox__out_of_bounds"
+    "test_get_transform_grid_list__contains"
+    "test_get_transform_grid_list__file"
+    "test_get_transform_grid_list__source_id"
+    "test_sync__area_of_use__list"
+    "test_sync__bbox__list"
+    "test_sync__bbox__list__exclude_world_coverage"
+    "test_sync__download_grids"
+    "test_sync__file__list"
+    "test_sync__source_id__list"
+    "test_sync_download"
+    "test_sync_download__directory"
+    "test_sync_download__system_directory"
+    "test_transformer_group__download_grids"
+
+    # proj-data grid required
+    "test_azimuthal_equidistant"
+  ];
+
+  pythonImportsCheck = [
+    "pyproj"
+    "pyproj.crs"
+    "pyproj.transformer"
+    "pyproj.geod"
+    "pyproj.proj"
+    "pyproj.database"
+    "pyproj.list"
+    "pyproj.datadir"
+    "pyproj.network"
+    "pyproj.sync"
+    "pyproj.enums"
+    "pyproj.aoi"
+    "pyproj.exceptions"
+  ];
+
+  meta = with lib; {
+    description = "Python interface to PROJ library";
+    mainProgram = "pyproj";
+    homepage = "https://github.com/pyproj4/pyproj";
+    changelog = "https://github.com/pyproj4/pyproj/blob/${src.rev}/docs/history.rst";
+    license = licenses.mit;
+    maintainers = with maintainers; teams.geospatial.members ++ [ lsix dotlambda ];
+  };
+}