What happened?
When using pixi run doc to create documentation in Windows, time-coding.rst is aborting with a failure because the file tries to delete test-datetimes1.nc while windows thinks it is open. We tried using gc.collect() to force garbage collection and del _, and a using a sleep timer to ensure that the processes were complete, but none of those worked.
Switching from xr.open_dataset() to xr.load_dataset() prevents the problem, but may not be appropriate in this situation.
What did you expect to happen?
Ideally the docs should build in any environment; however, expecting users Windows users to use WSL or another method when developing may be acceptable, if covered in the contributing guide.
Minimal Complete Verifiable Example
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "xarray[complete]@git+https://github.com/pydata/xarray.git@main",
# ]
# ///
#
# This script automatically imports the development branch of xarray to check for issues.
# Please delete this header if you have _not_ tested this script with `uv run`!
import xarray as xr
xr.show_versions()
# your reproducer code ...
Steps to reproduce
No response
MVCE confirmation
Relevant log output
sphinx.errors.ExtensionError: Cell raised uncaught exception:
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
File ~\python\xarray\.pixi\envs\doc\Lib\shutil.py:701, in _rmtree_unsafe(path, dir_fd, onexc)
700 try:
--> 701 os.unlink(fullname)
702 except FileNotFoundError:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\rwkoz\\AppData\\Local\\Temp\\tmptpg6hhgw\\test-datetimes1.nc'
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
Cell In[49], line 2
1 # Cleanup
----> 2 tempdir.cleanup()
File ~\python\xarray\.pixi\envs\doc\Lib\tempfile.py:975, in TemporaryDirectory.cleanup(self)
973 def cleanup(self):
974 if self._finalizer.detach() or _os.path.exists(self.name):
--> 975 self._rmtree(self.name, ignore_errors=self._ignore_cleanup_errors)
File ~\python\xarray\.pixi\envs\doc\Lib\tempfile.py:955, in TemporaryDirectory._rmtree(cls, name, ignore_errors, repeated)
952 if not ignore_errors:
953 raise
--> 955 _shutil.rmtree(name, onexc=onexc)
File ~\python\xarray\.pixi\envs\doc\Lib\shutil.py:852, in rmtree(path, ignore_errors, onerror, onexc, dir_fd)
849 exc_info = type(exc), exc, exc.__traceback__
850 return onerror(func, path, exc_info)
--> 852 _rmtree_impl(path, dir_fd, onexc)
File ~\python\xarray\.pixi\envs\doc\Lib\shutil.py:705, in _rmtree_unsafe(path, dir_fd, onexc)
703 continue
704 except OSError as err:
--> 705 onexc(os.unlink, fullname, err)
706 try:
707 os.rmdir(path)
File ~\python\xarray\.pixi\envs\doc\Lib\tempfile.py:930, in TemporaryDirectory._rmtree.<locals>.onexc(func, path, exc)
927 _resetperms(path)
929 try:
--> 930 _os.unlink(path)
931 except IsADirectoryError:
932 cls._rmtree(path, ignore_errors=ignore_errors)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\rwkoz\\AppData\\Local\\Temp\\tmptpg6hhgw\\test-datetimes1.nc'
Extension error:
Cell raised uncaught exception:
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
File ~\python\xarray\.pixi\envs\doc\Lib\shutil.py:701, in _rmtree_unsafe(path, dir_fd, onexc)
700 try:
--> 701 os.unlink(fullname)
702 except FileNotFoundError:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\rwkoz\\AppData\\Local\\Temp\\tmptpg6hhgw\\test-datetimes1.nc'
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
Cell In[49], line 2
1 # Cleanup
----> 2 tempdir.cleanup()
File ~\python\xarray\.pixi\envs\doc\Lib\tempfile.py:975, in TemporaryDirectory.cleanup(self)
973 def cleanup(self):
974 if self._finalizer.detach() or _os.path.exists(self.name):
--> 975 self._rmtree(self.name, ignore_errors=self._ignore_cleanup_errors)
File ~\python\xarray\.pixi\envs\doc\Lib\tempfile.py:955, in TemporaryDirectory._rmtree(cls, name, ignore_errors, repeated)
952 if not ignore_errors:
953 raise
--> 955 _shutil.rmtree(name, onexc=onexc)
File ~\python\xarray\.pixi\envs\doc\Lib\shutil.py:852, in rmtree(path, ignore_errors, onerror, onexc, dir_fd)
849 exc_info = type(exc), exc, exc.__traceback__
850 return onerror(func, path, exc_info)
--> 852 _rmtree_impl(path, dir_fd, onexc)
File ~\python\xarray\.pixi\envs\doc\Lib\shutil.py:705, in _rmtree_unsafe(path, dir_fd, onexc)
703 continue
704 except OSError as err:
--> 705 onexc(os.unlink, fullname, err)
706 try:
707 os.rmdir(path)
File ~\python\xarray\.pixi\envs\doc\Lib\tempfile.py:930, in TemporaryDirectory._rmtree.<locals>.onexc(func, path, exc)
927 _resetperms(path)
929 try:
--> 930 _os.unlink(path)
931 except IsADirectoryError:
932 cls._rmtree(path, ignore_errors=ignore_errors)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\rwkoz\\AppData\\Local\\Temp\\tmptpg6hhgw\\test-datetimes1.nc'
Anything else we need to know?
No response
Environment
Details
What happened?
When using
pixi run docto create documentation in Windows,time-coding.rstis aborting with a failure because the file tries to deletetest-datetimes1.ncwhile windows thinks it is open. We tried usinggc.collect()to force garbage collection anddel _, and a using a sleep timer to ensure that the processes were complete, but none of those worked.Switching from
xr.open_dataset()toxr.load_dataset()prevents the problem, but may not be appropriate in this situation.What did you expect to happen?
Ideally the docs should build in any environment; however, expecting users Windows users to use WSL or another method when developing may be acceptable, if covered in the contributing guide.
Minimal Complete Verifiable Example
Steps to reproduce
No response
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
Details