Skip to content

Fix PyInstaller temp directory accumulation on Windows#18

Closed
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-dll-download-issue
Closed

Fix PyInstaller temp directory accumulation on Windows#18
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-dll-download-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 30, 2025

PyInstaller's --runtime-tmpdir ./temp flag creates persistent _MEI* directories in the user's working directory that accumulate unbounded, consuming >10GB after repeated runs.

Changes

  • Removed --runtime-tmpdir ./temp from PyInstaller build command in scripts/build_binaries.py

PyInstaller now extracts to OS-managed temp directories (%TEMP% on Windows, /tmp on Linux) that are automatically cleaned up.

# Before
cmd = [
    "pyinstaller",
    "--onefile",
    "--runtime-tmpdir", "./temp",  # Creates persistent ./temp/_MEI* dirs
    "--name", binary_name,
    ...
]

# After
cmd = [
    "pyinstaller",
    "--onefile",
    "--name", binary_name,  # Uses OS temp dir by default
    ...
]
Original prompt

This section details on the original issue you should resolve

<issue_title>[bug] Running casbin-python-cli-windows-x86_64.exe in Windows causes downloading a lot of run-time DLLs</issue_title>
<issue_description>Running casbin-python-cli-windows-x86_64.exe in Windows causes downloading a lot of run-time DLLs like:

C:\github_repos\casdoor\temp>dir
 Volume in drive C has no label.
 Volume Serial Number is C82E-F3DE

 Directory of C:\github_repos\casdoor\temp

10/30/2025  10:32 AM    <DIR>          .
10/30/2025  12:03 AM    <DIR>          ..
10/30/2025  10:27 AM    <DIR>          _MEI104562
10/30/2025  10:22 AM    <DIR>          _MEI105002
10/30/2025  10:20 AM    <DIR>          _MEI155202
10/30/2025  10:24 AM    <DIR>          _MEI167442
10/30/2025  10:11 AM    <DIR>          _MEI33402
10/30/2025  10:22 AM    <DIR>          _MEI48402
               0 File(s)              0 bytes
               8 Dir(s)  31,406,051,328 bytes free
C:\github_repos\casdoor\temp>cd _MEI104562

C:\github_repos\casdoor\temp\_MEI104562>dir
 Volume in drive C has no label.
 Volume Serial Number is C82E-F3DE

 Directory of C:\github_repos\casdoor\temp\_MEI104562

10/30/2025  10:27 AM    <DIR>          .
10/30/2025  10:32 AM    <DIR>          ..
10/30/2025  10:27 AM            22,072 api-ms-win-core-console-l1-1-0.dll
10/30/2025  10:27 AM            22,056 api-ms-win-core-datetime-l1-1-0.dll
10/30/2025  10:27 AM            21,944 api-ms-win-core-debug-l1-1-0.dll
10/30/2025  10:27 AM            22,096 api-ms-win-core-errorhandling-l1-1-0.dll
10/30/2025  10:27 AM            22,072 api-ms-win-core-fibers-l1-1-0.dll
10/30/2025  10:27 AM            22,072 api-ms-win-core-fibers-l1-1-1.dll
10/30/2025  10:27 AM            26,152 api-ms-win-core-file-l1-1-0.dll
10/30/2025  10:27 AM            22,056 api-ms-win-core-file-l1-2-0.dll
10/30/2025  10:27 AM            21,960 api-ms-win-core-file-l2-1-0.dll
10/30/2025  10:27 AM            21,944 api-ms-win-core-handle-l1-1-0.dll
10/30/2025  10:27 AM            22,072 api-ms-win-core-heap-l1-1-0.dll
10/30/2025  10:27 AM            22,072 api-ms-win-core-interlocked-l1-1-0.dll
10/30/2025  10:27 AM            22,080 api-ms-win-core-kernel32-legacy-l1-1-1.dll
10/30/2025  10:27 AM            22,056 api-ms-win-core-libraryloader-l1-1-0.dll
10/30/2025  10:27 AM            22,080 api-ms-win-core-localization-l1-2-0.dll
10/30/2025  10:27 AM            22,056 api-ms-win-core-memory-l1-1-0.dll
10/30/2025  10:27 AM            22,096 api-ms-win-core-namedpipe-l1-1-0.dll
10/30/2025  10:27 AM            21,968 api-ms-win-core-processenvironment-l1-1-0.dll
10/30/2025  10:27 AM            22,096 api-ms-win-core-processthreads-l1-1-0.dll
10/30/2025  10:27 AM            22,072 api-ms-win-core-processthreads-l1-1-1.dll
10/30/2025  10:27 AM            22,080 api-ms-win-core-profile-l1-1-0.dll
10/30/2025  10:27 AM            21,960 api-ms-win-core-rtlsupport-l1-1-0.dll
10/30/2025  10:27 AM            22,056 api-ms-win-core-string-l1-1-0.dll
10/30/2025  10:27 AM            22,056 api-ms-win-core-synch-l1-1-0.dll
10/30/2025  10:27 AM            22,080 api-ms-win-core-synch-l1-2-0.dll
10/30/2025  10:27 AM            22,072 api-ms-win-core-sysinfo-l1-1-0.dll
10/30/2025  10:27 AM            22,080 api-ms-win-core-sysinfo-l1-2-0.dll
10/30/2025  10:27 AM            22,056 api-ms-win-core-timezone-l1-1-0.dll
10/30/2025  10:27 AM            21,944 api-ms-win-core-util-l1-1-0.dll
10/30/2025  10:27 AM            22,056 api-ms-win-crt-conio-l1-1-0.dll
10/30/2025  10:27 AM            26,056 api-ms-win-crt-convert-l1-1-0.dll
10/30/2025  10:27 AM            22,080 api-ms-win-crt-environment-l1-1-0.dll
10/30/2025  10:27 AM            22,056 api-ms-win-crt-filesystem-l1-1-0.dll
10/30/2025  10:27 AM            22,096 api-ms-win-crt-heap-l1-1-0.dll
10/30/2025  10:27 AM            22,080 api-ms-win-crt-locale-l1-1-0.dll
10/30/2025  10:27 AM            30,248 api-ms-win-crt-math-l1-1-0.dll
10/30/2025  10:27 AM            22,096 api-ms-win-crt-process-l1-1-0.dll
10/30/2025  10:27 AM            26,152 api-ms-win-crt-runtime-l1-1-0.dll
10/30/2025  10:27 AM            26,168 api-ms-win-crt-stdio-l1-1-0.dll
10/30/2025  10:27 AM            26,176 api-ms-win-crt-string-l1-1-0.dll
10/30/2025  10:27 AM            22,096 api-ms-win-crt-time-l1-1-0.dll
10/30/2025  10:27 AM            21,952 api-ms-win-crt-utility-l1-1-0.dll
10/30/2025  10:27 AM         1,443,565 base_library.zip
10/30/2025  10:27 AM    <DIR>          casbin
10/30/2025  10:27 AM         5,191,960 libcrypto-3.dll
10/30/2025  10:27 AM           787,224 libssl-3.dll
10/30/2025  10:27 AM    <DIR>          pycasbin-2.3.0.dist-info
10/30/2025  10:27 AM         5,800,216 python311.dll
10/30/2025  10:27 AM            30,488 select.pyd
10/30/2025  10:27 AM           119,192 VCRUNTIME140.dll
10/30/2025  10:27 AM            84,760 _bz2.pyd
10/30/2025  10:27 AM       ...

</details>

- Fixes casbin/casbin-python-cli#17

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@hsluoyz hsluoyz marked this pull request as ready for review October 30, 2025 02:41
…ctories

Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix DLLs downloading issue for casbin-python-cli on Windows Fix PyInstaller temp directory accumulation on Windows Oct 30, 2025
Copilot AI requested a review from hsluoyz October 30, 2025 02:47
@hsluoyz hsluoyz closed this Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants