Skip to content

Commit

Permalink
Merge pull request #1030 from snowman2/conda_windows
Browse files Browse the repository at this point in the history
BUG: get_data_dir support for conda Windows enviroments
  • Loading branch information
snowman2 committed Mar 6, 2022
2 parents 8f0e1f7 + 7d00218 commit a8d1c0d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ test_script:
- python -m pip install -r requirements-test.txt
- RD /S /Q pyproj\ # make sure src does not impact installed wheel
- python -c "import pyproj; pyproj.Proj('epsg:4269')"
- py.test --cov-report term-missing --cov=pyproj -v -s
- python -m pytest --cov-report term-missing --cov=pyproj -v -s
# cleanup for test dir
- rmdir /s /q dist\ 2>nul
- if %PROJSOURCE% == git rmdir /s /q wheelhouse\ 2>nul
Expand Down
1 change: 1 addition & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Latest
- BUG: Reorder deps in show_versions for setuptools issue (issue #1017)
- BUG: remove CustomConstructorCRS @abstractmethod decorator (pull #1018)
- BUG: Correct type annotation for AreaofUse.bounds (issue #1012)
- BUG: :func:`pyproj.datadir.get_data_dir` support for conda Windows (issue #1029)

3.3.0
-------
Expand Down
3 changes: 3 additions & 0 deletions pyproj/datadir.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def get_data_dir() -> str:
internal_datadir = Path(__file__).absolute().parent / "proj_dir" / "share" / "proj"
proj_lib_dirs = os.environ.get("PROJ_LIB", "")
prefix_datadir = Path(sys.prefix, "share", "proj")
conda_windows_prefix_datadir = Path(sys.prefix, "Library", "share", "proj")

def valid_data_dir(potential_data_dir):
if (
Expand All @@ -98,6 +99,8 @@ def valid_data_dirs(potential_data_dirs):
_VALIDATED_PROJ_DATA = proj_lib_dirs
elif valid_data_dir(prefix_datadir):
_VALIDATED_PROJ_DATA = str(prefix_datadir)
elif valid_data_dir(conda_windows_prefix_datadir):
_VALIDATED_PROJ_DATA = str(conda_windows_prefix_datadir)
else:
proj_exe = shutil.which("proj", path=sys.prefix)
if proj_exe is None:
Expand Down
10 changes: 10 additions & 0 deletions test/test_datadir.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ def test_get_data_dir__from_prefix(tmp_path):
assert get_data_dir() == str(proj_dir)


def test_get_data_dir__from_prefix__conda_windows(tmp_path):
with proj_env(), patch.dict(os.environ, {}, clear=True), patch(
"pyproj.datadir.Path.absolute", return_value=_INVALID_PATH
), patch("pyproj.datadir.sys.prefix", str(tmp_path)):
proj_dir = tmp_path / "Library" / "share" / "proj"
proj_dir.mkdir(parents=True)
create_projdb(proj_dir)
assert get_data_dir() == str(proj_dir)


def test_get_data_dir__from_path(tmp_path):
with proj_env(), patch.dict(os.environ, {}, clear=True), patch(
"pyproj.datadir.Path.absolute", return_value=_INVALID_PATH
Expand Down

0 comments on commit a8d1c0d

Please sign in to comment.