Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: get_data_dir support for conda Windows enviroments #1030

Merged
merged 2 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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