Preface¶
When running Python in DSH’s Windows sandbox, temporary directory-related behaviors may be restricted, and pytest’s tmp_path / tmpdir tests will also be affected. DSH’s plugin mechanism allows such localized compatibility issues to be handled on existing runtime paths.
dsh-python-tempfile-shim is such a temporary plugin: before DSH’s upstream fix is released, it automatically injects a CPython tempfile shim for restricted shell commands, making Python and pytest temporary directories usable.
What is this¶
dsh-python-tempfile-shim is a DeepSeek Harness (DSH) temporary plugin maintained by AngelosZou and licensed under MIT.
It is not published to npm and requires cloning from a local source for installation. The plugin’s goal is focused: to make Python (including pytest) usable with temporary directories within the DSH Windows sandbox.
It does not replace Python nor modify the global Python environment. It injects PYTHONPATH into the restricted command execution path via DSH’s plugin mechanism and comes with a sitecustomize.py that makes os.mkdir ignore the mode parameter, causing new directories to inherit the parent directory’s ACL.
Core Features¶
- Temporary plugin: Used to work around a Windows sandbox compatibility issue before DSH’s upstream fix is released.
- Automatic injection: Patches the shell executor’s
resolve()to make all restricted commands (workspace-write/read-only) inheritPYTHONPATH=<plugin assets dir>. - Included shim:
assets/sitecustomize.pymakesos.mkdirignore the mode parameter, causing new directories to inherit the parent directory’s ACL. - Covers common entry points:
python,pytest,pip,tox,nox,venv, and child Python processes take effect automatically. - Does not change sandbox boundaries: Maintains zero elevation.
- Platform scope: Only applicable to Windows; on other platforms,
apply()registers nothing. - Diagnostic entry: Registers the
python-tempfile-shimskill for diagnosis and reporting.
Installation and Activation¶
Before installation, read SECURITY.md in the repository and check the source code against the MIT license. The plugin runs with the permissions of the current DSH process; only install local sources you trust.
- Clone the repository locally from GitHub:
git clone https://github.com/AngelosZou/dsh-python-tempfile-shim.git
- Add to DSH plugins using the local repository path:
dsh plugin --profile web add link:<local repository path>
The <local repository path> in the second command is the local repository path you cloned in the previous step.
- Restart DSH to activate the plugin.
To uninstall, remove the plugin in the DSH settings page and then restart DSH.
Note: Do not install assets/sitecustomize.py to the global site-packages or machine-level PYTHONPATH. 0o700 is CPython’s privacy hardening; this behavior should be preserved when running outside the sandbox.
Typical Usage¶
After installation and restart, run Python or pytest normally via pwsh. For pytest tests using tmp_path / tmpdir, they pass without special parameters.
If a parent Python process spawns a child Python process, the shim continues to work via the inherited PYTHONPATH.
Run smoke tests in the local repository:
npm test
The test covers the resolve-patch contract, prompt-section, and skill registration.
Suitable Scenarios and Notes¶
Suitable for the following scenarios:
- Running Python using
workspace-writeorread-onlyrestricted commands in the DSH Windows sandbox. - Running pytest in DSH, especially tests that depend on
tmp_path/tmpdir. - Temporarily working around this compatibility issue before DSH’s upstream fix is released.
Note:
- Only addresses DSH sandbox issues specific to Windows.
- Does not inject the shim when running with
danger-full-accessor outside the sandbox. - Do not treat this as a global Python fix; do not install it to global site-packages or machine-level
PYTHONPATH. - This plugin should be uninstalled after the upstream fix is released.
- The DSH community directory is an independent site and should not be interpreted as an official app store.
Conclusion¶
The value of dsh-python-tempfile-shim lies in its locality and automation: it does not change sandbox boundaries, maintains zero elevation, and only restores the usability of Python temporary directories under the DSH Windows sandbox. After the upstream fix is released, simply remove the plugin.
Related Links:
- GitHub: https://github.com/AngelosZou/dsh-python-tempfile-shim
- Community Directory Page: Verified materials do not provide a specific URL, so it is not listed here.