Skip to content

gh-148690: Build Windows freethreaded binaries into separate directory and include python3t.dll on GIL-enabled#149218

Open
zooba wants to merge 24 commits intopython:mainfrom
zooba:gh-148690
Open

gh-148690: Build Windows freethreaded binaries into separate directory and include python3t.dll on GIL-enabled#149218
zooba wants to merge 24 commits intopython:mainfrom
zooba:gh-148690

Conversation

@zooba
Copy link
Copy Markdown
Member

@zooba zooba commented May 1, 2026

Based heavily on @encukou's work in #148912, split into a separate PR because I'm going to need my own branch for testing release process stuff.

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 1, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32497182 | 📁 Comparing 90681fc against main (f4f82f0)

  🔍 Preview build  

24 files changed · ± 24 modified

± Modified

@zooba zooba requested a review from vsajip as a code owner May 1, 2026 11:39
Copy link
Copy Markdown
Member

@encukou encukou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking this on!

Comment thread PCbuild/_testcapi.vcxproj Outdated
Comment thread PCbuild/readme.txt Outdated
@zooba
Copy link
Copy Markdown
Member Author

zooba commented May 1, 2026

I have a test release build running at https://dev.azure.com/Python/cpython/_build/results?buildId=169826&view=results If anyone wants to grab the results (look on the artifacts page for msi, embed, nuget, and pymanager_bundle) and post success/failure, that'd be great (cc @ngoldbaum )

@zooba
Copy link
Copy Markdown
Member Author

zooba commented May 1, 2026

So far, I know that the PyManager packages are missing the python3t.dll (because I got the version check in PC/layout correct, but we haven't rev'd to that version yet, so it's "wrong" for testing). So far, I think the rest is looking good.

@ngoldbaum
Copy link
Copy Markdown
Contributor

ngoldbaum commented May 1, 2026

Thanks for the ping! Unfortunately I have very limited time with my Windows PC today. I might be able to set up a VM using my ARM Macbook later on my plane, we'll see.

After some quick inspection, I do see one possible issue with the GIL-enabled pymanager build:

PS C:\Users\goldbaum\Downloads\pymanager_bundle\pymanager_bundle\python-3.15.0a8-amd64> dir


    Directory: C:\Users\goldbaum\Downloads\pymanager_bundle\pymanager_bundle\python-3.15.0a8-amd64


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          5/1/2026   6:57 AM                DLLs
d-----          5/1/2026   6:57 AM                Doc
d-----          5/1/2026   6:57 AM                include
d-----          5/1/2026   6:57 AM                Lib
d-----          5/1/2026   6:57 AM                libs
d-----          5/1/2026   6:57 AM                tcl
-a----          5/1/2026   6:57 AM          35407 LICENSE.txt
-a----          5/1/2026   6:57 AM          92160 python.exe
-a----          5/1/2026   6:57 AM          61440 python3.dll
-a----          5/1/2026   6:57 AM        7900160 python315.dll
-a----          5/1/2026   6:57 AM          90624 pythonw.exe
-a----          5/1/2026   6:57 AM         120400 vcruntime140.dll
-a----          5/1/2026   6:57 AM          49776 vcruntime140_1.dll
-a----          5/1/2026   6:57 AM           3915 __install__.json

Shouldn't there be a python3t.dll next to python3.dll or in an abi3t_compat subfolder that re-exports symbols from python315.dll? FWIW I'm not able import an abi3.abi3t wheel with the pymanager build:

>>> import limited
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import limited
  File "C:\Users\goldbaum\Downloads\pymanager_bundle\pymanager_bundle\python-3.15.0a8-amd64\Lib\site-packages\limited\__init__.py", line 1, in <module>
    from .limited import *
ImportError: DLL load failed while importing limited: The specified module could not be found.

I've attached the wheel file I built, renamed with a .zip extension so github lets me upload it here. It exports a single function named add that takes integer arguments you can call to check everything is working.

limited_api-1.2.3-cp315-abi3.abi3t-win_amd64.whl.zip

I also did some brief testing with the msi installer along the lines of what I did in the other PR earlier this week and don't see any issues.

@ngoldbaum
Copy link
Copy Markdown
Contributor

oh I see you also caught that, great!

@zooba
Copy link
Copy Markdown
Member Author

zooba commented May 1, 2026

Okay, I think this is the change now. We'll see if Canonical is back online for the tests, but this should be it on the Windows side. I'm still testing the updates to the release pipeline to make sure it still works for earlier versions, but that's a separate PR (python/release-tools#373)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For any other reviewers, here's the total diff between python3dll.vcxproj and python3tdll.vcxproj:

diff --git a/PCbuild/python3dll.vcxproj b/PCbuild/python3tdll.vcxproj
index 3d8ac1b2353..796712cca31 100644
--- a/PCbuild/python3dll.vcxproj
+++ b/PCbuild/python3tdll.vcxproj
@@ -67,15 +67,15 @@
     </ProjectConfiguration>
   </ItemGroup>
   <PropertyGroup Label="Globals">
-    <ProjectGuid>{885D4898-D08D-4091-9C40-C700CFE3FC5A}</ProjectGuid>
-    <RootNamespace>python3dll</RootNamespace>
+    <ProjectGuid>{947BB5F5-6025-4A4F-8182-1B175469F8D2}</ProjectGuid>
+    <RootNamespace>python3tdll</RootNamespace>
     <Keyword>Win32Proj</Keyword>
     <SupportPGO>false</SupportPGO>
   </PropertyGroup>
   <Import Project="python.props" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Label="Configuration">
-    <TargetName>python3</TargetName>
+    <TargetName>python3t</TargetName>
     <ConfigurationType>DynamicLibrary</ConfigurationType>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -107,4 +107,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>

Copy link
Copy Markdown
Member

@zware zware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see nothing that gives me pause here, but I'm not confident enough in my understanding to give it a green checkmark :)

@zooba zooba added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 1, 2026
@bedevere-bot
Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @zooba for commit de2da65 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F149218%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 1, 2026
@zooba
Copy link
Copy Markdown
Member Author

zooba commented May 1, 2026

A buildbot run ought to flush out any of the remaining edge cases we have to worry about. Anything else will just have to be found in the beta, I guess.

If someone else wants to merge when it passes, feel free. I probably won't see any results until after the weekend, which is getting very close to release.

<ClCompile Include="..\Python\dynload_win.c" />
<ClCompile Include="..\Python\dynload_win.c">
<PreprocessorDefinitions Condition="$(DisableGil) != 'true'">PY3_DLLNAME=L"$(Py3DllName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>ABI3T_DLLNAME=L"$(Abi3tDllName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<PreprocessorDefinitions>ABI3T_DLLNAME=L"$(Abi3tDllName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="$(DisableGil) != 'true'>ABI3T_DLLNAME=L"$(Abi3tDllName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>

See also comment in dynload_win.c:

 * ABI3T_DLLNAME is undefined for free-threaded builds, and so this function is
 * a no-op (we assume that _Py_CheckPython3 has already been called).

@chris-eibl
Copy link
Copy Markdown
Member

Thanks @zooba , @encukou and @ngoldbaum!

I've tried the most recent artifacts from https://dev.azure.com/Python/cpython/_build/results?buildId=169835&view=artifacts&pathAsName=false&type=publishedArtifacts

  • pymanager_amd64
  • pymanager_amd64_t
  • msi

and installed Nathan's limited_api-1.2.3-cp315-abi3.abi3t-win_amd64.whl. Everything fine except the ft case in the intermingled msi layout.

But using the resulting python315t.dll from a custom build with the fix I've suggested above, it works for me, too 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants