Repository navigation
Conversation
mkanat
force-pushed
the
disable-dll-manifests
branch
from
October 24, 2026 21:11
7109eb8 to
d13b03e
Compare
CPython's python_nt.rc and sqlite3.rc embed python.exe's manifest in python3XY.dll, python3.dll, sqlite3.dll, and every extension module as resource ID 2. Windows fails to load a DLL with an embedded manifest from a path near MAX_PATH, even with long paths enabled, so python.exe fails to start once its path is 247 characters or longer when the DLL is next to it. The executables keep their manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mkanat
marked this pull request as ready for review
October 24, 2026 21:16
Author
|
Oh, and I did validate that this solves the problem I ran into, on a local Windows Server 2025 VM. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The way that CPython compiles DLLs for Windows causes a (unnecessary) problem with long paths. I've filed an upstream issue, too (python/cpython#160624), but it seems worth fixing in PBS because it's just a simple build change that should have no consequences anywhere.
Problem
python.exefails to start withSTATUS_NAME_TOO_LONGonce its path is 247 characters or longer. It turns out, this is actually from DLL loading, not frompython.exeitself.It happens only because the DLLs contain an unnecessary manifest. The manifest doesn't do anything in a DLL. Windows only takes the supported OS versions and the Common Controls dependency from the EXE's manifest.
Extension modules like
_ctypesand_sslalso fail to import when the install itself is at a long path, for this same reason.History
DLLs used to need a manifest. With Visual C++ 2008, which Python 2.6 through 3.2 were built with, a DLL had to declare its dependency on the C runtime in an embedded manifest to find it. However, Visual C++ 2010 stopped using manifests to find the C runtime, so DLLs haven't needed one since.
python/cpython#67207 (bpo-23018) added the manifest to
python_nt.rcin 2015, at the same time as the one for python[w].exe, to declaresupportedOSso thatGetVersionwould stop reporting Windows 8 on newer versions.In 2016, python/cpython#71496 (bpo-27309) added the Common Controls dependency so that tkinter's native dialogs would get the right styles. From that change: "Windows needs to load a different version of a particular DLL for the entire process." However, that's only information that the process needs, not the DLLs.
python/cpython#71918 (bpo-27731) added
longPathAwarelater that year.Solution
This adds a patch that removes the manifest from both resource scripts, for every CPython version. The executables keep theirs.