Use PurePosixPath instead of PosixPath for platform-independent compatibility (Windows fix)
Hi,
I encountered an issue when running earthaccess on Windows. When trying to create a virtual xarray.Dataset using virtualizarr, I received the following error:
UnsupportedOperation: cannot instantiate ‘PosixPath’ on your system
Here’s the minimal code that triggered the issue:
import earthaccess
earthaccess.login()
results = earthaccess.search_data(
count=2,
temporal=("2023"),
short_name="SWOT_L2_LR_SSH_Expert_2.0"
)
vds = earthaccess.open_virtual_dataset(results[0], access="indirect", load=False)
After investigating, I found that replacing PosixPath with PurePosixPath in your manifest.py file fixed the issue. This allows the code to run correctly on Windows.
If cross-platform compatibility is a goal, switching to PurePosixPath may be a simple fix to improve support for Windows users.
Thanks for your work on this great library!
Thanks for reporting this!
Note this comment just before the line that throws your error:
https://github.com/zarr-developers/VirtualiZarr/blob/3bf9f8524a3e8206962dfea82b25267fa7a2db38/virtualizarr/manifests/manifest.py#L73
So this was a deliberate limit on the scope when it was written.
If we want to support windows machines then we need to ensure windows filepaths work throughout the stack, particularly in both obstore and icechunk. We also should add CI tests to virtualizarr's test suite that run on windows machines.
I think generalizing this line to PurePosixPath might make sense, but also https://github.com/zarr-developers/VirtualiZarr/issues/685 might obviate any need to use a Path class at all, and we should think through support for windows in general before just removing this check.