BUG: Download to the PROJ data directory with pyproj sync --system-directory #1673
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 95.81%. Comparing base (
cce793d) to head (da7f08e).:warning: Report is 10 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
@@ Coverage Diff @@
## main #1673 +/- ##
=======================================
Coverage 95.81% 95.81%
=======================================
Files 20 20
Lines 1886 1886
=======================================
Hits 1807 1807
Misses 79 79
</details>
:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.
<details><summary> :rocket: New features to boost your workflow: </summary>
</details>
Why is appending this tmp_path needed? As I revealed in my comments on the issues, I don't know how these functions are supposed to work.
get_data_dir() can return several directories joined by os.pathsep, from PROJ_DATA and append_data_dir(), and --system-directory should download into the first one. Appending tmp_path makes sure there are at least two here, so the test checks that sync takes the first directory and not the whole joined string. With a single directory it would also pass if the split were removed altogether
proj_env() puts the data directory back afterwards, so the extra directory doesn't leak into other tests
@snowman2 from what I can understand this makes sense to me. You obviously have more experience with this so I'd like you to take a last look before merging.
Confirmed:
>>> import os
>>> os.path.sep
'/'
>>> os.pathsep
':'
The path should be separated by :.
Thanks @alteralto 👍
djhoese
alteralto
- [x] Tests added
- [x] Fully documented, including
history.rstfor all changes andapi/*.rstfor new APIget_data_dir()returns one or more directories joined byos.pathsep, andpyproj sync --system-directorysplit it onos.path.sepinstead, as the issue says. The target directory became''on Linux and the drive letter on Windows, so the grid andfiles.geojsonwere written to the current directoryWith the 3.8.0 wheel on Linux (python:3.12-slim) and on Windows,
pyproj sync --file us_noaa_alaska --system-directoryput both files in the current directory, and with this change they go topyproj/proj_dir/share/proj. WithPROJ_DATA=/pd_a:/pd_bthey go to/pd_a, and ahgridshiftpipeline onus_noaa_alaska.tifthen finds the gridtest_sync_download__system_directorybuilt the expected directory with the samesplit(os.path.sep)[0], so it passed with the bug. It now appends a second data directory and checks that the download goes to the first one. It fails without the fix (directory='F:') and passes with it, together with the rest oftest_cli.pyandtest_sync.py