Skip to content

Commit

Permalink
BUG: Fix finding PROJ version with PROJ_LIB and PROJ 9.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 committed Sep 5, 2022
1 parent 9f3149e commit 5ab8985
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Latest
- BUG: Add support for `PROJ_DATA` environment variable (issue #1097)
- BUG: Ensure numpy masked arrays stay masked after projection (issue #1102)
- BLD: Don't specify runtime_library_dirs on Cygwin (pull #1120)
- BUG: Fix finding PROJ version with PROJ_LIB and PROJ 9.1+ (issue #1127)

3.3.1
-------
Expand Down
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import platform
import re
import shutil
import subprocess
import sys
Expand All @@ -13,6 +14,7 @@
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
PROJ_VERSION_SEARCH = re.compile(r".*Rel\.\s+(?P<version>\d+\.\d+\.\d+).*")


def get_proj_version(proj_dir: Path) -> str:
Expand All @@ -23,7 +25,13 @@ def get_proj_version(proj_dir: Path) -> str:
proj_ver = subprocess.check_output(str(proj), stderr=subprocess.STDOUT).decode(
"ascii"
)
return (proj_ver.split()[1]).strip(",")
match = PROJ_VERSION_SEARCH.search(proj_ver)
if not match:
raise RuntimeError(
"PROJ version unable to be determined. "
"Please set the PROJ_VERSION environment variable."
)
return match.groupdict()["version"]


def check_proj_version(proj_version: str) -> None:
Expand Down

0 comments on commit 5ab8985

Please sign in to comment.