Skip to content

Build changes for Windows free-threaded builds #112984

Description

@zooba

We should use a different $(IntDir) and $(OutDir) for free threaded builds so that it's faster to switch between them and so they can be built in parallel.

The output filename should be python{major}.{minor}t.exe and python{major}{minor}t.dll. Debug builds are python{major}.{minor}t_d.exe and python{major}{minor}t_d.dll.

The ABI tag becomes .cp{major}{minor}t-{plat}

All stdlib .pyd files get an ABI tag.

The python.bat is updated as normal (overwriting the last yesgil build).

The installer should not include a python.exe, to avoid causing PATH conflicts, but Nuget, embeddable and Store packages should include a copy/alias.

PEP 514 registration (a.k.a. sys.winver) should use {major}.{minor}t-{plat}.

Tests that rely on the executable name should use sys.executable wherever possible, and hopefully there's a support variable already for the rest.

All of these only take effect when $(DisableGil) == 'true' (which is set by build.bat --disable-gil, but the build variable is canonical).

Linked PRs

Activity

  1. self-assigned this
    on Dec 12, 2023
  2. zooba commented on Dec 14, 2023

    @zooba
    MemberAuthor

    Deliberately not updating sys.version, sys.thread_info or the opening prompt of the REPL in this PR, because those affect all platforms and other people will want to argue about them.

  3. added 2 commits that reference this issue on Dec 14, 2023
  4. zooba commented on Dec 20, 2023

    @zooba
    MemberAuthor

    So I've added an installer option in this PR

    Normal first page:
    image

    Where you go after clicking "Customize":
    image

    The page with the new option (last checkbox):
    image

    It's labelled "Download" because the files will be on python.org and downloaded on demand, so if you don't have internet access you won't get them. The installer already has a /layout option to pre-download all its optional components, so it's nothing new here.

    After install, there's a python3.13t.exe and pythonw3.13t.exe installed alongside the usual python.exe/pythonw.exe. Right now, they're already registered as normal, which means py.exe -3.13t will select it while py.exe -3.13 gets the usual version. There's also a "Python 3.13 (64-bit, free-threaded)" shortcut added to the start menu.

    Unfortunately, py.exe -3 will select the free-threaded one, which I don't like but don't really have a great way to solve it - the easiest way is to make it so you need something like py.exe -V:PythonFreeThreaded/3.13 to get the free-threaded build, which has the advantage that py.exe -V:PythonFreeThreaded/ will get the latest free-threaded build available, but a disadvantage is that shebang parsing won't be able to select it (without writing special case code in the launcher, which I'd rather not do if it can be avoided). On balance, I think it's probably best to change the company name to PythonFreeThreaded or something like that - open to suggestions!

    Right now, venv will create python3.13t.exe in the new environment. I'm tempted to say it should create python.exe instead, as that will make it easier to use. It probably requires more significant changes to venv though, so I'd rather do it later. Different venvlauncher implementations are needed because they "know" the name of the real executable will be, so we already do a sneaky rename. (Possibly that's being done wrong in the current PR...)

    I haven't yet created a Nuget package or embeddable distro for the files. I'm leaning toward python-freethreaded and pythonarm64-freethreaded packages on Nuget. This will really help out people running on CI, as they'll be able to easily get a set of binaries independent from what the CI image contains and without having to run an installer as part of their job. We could also just put a zip file of the binaries on python.org, but I fear it would clutter the list of downloads (which is already considered cluttered). No separate embeddable distro at this stage, people can build it easily enough if they want it.

  5. zooba commented on Dec 20, 2023

    @zooba
    MemberAuthor

    Today's updates:

  6. vsajip commented on Dec 21, 2023

    @vsajip
    Member

    There's quite a lot of venv-related change - is there any discussion or design documentation anywhere? For example, about the venvlauncher executable - what is the need/rationale for it, as it appears to be new in this PR?

  7. zooba commented on Dec 21, 2023

    @zooba
    MemberAuthor

    The venvlauncher.c is just launcher.c boiled down to just the venv parts, and none of the py.exe parts. The only change is that the executable embeds the expected Python executable name at compile time, as we can't just assume it'll be python[_d].exe anymore.

    The changes to venv\__init__.py should just streamline things for Windows. We need to more carefully pick the right redirector, and we can't rely on the name being python.exe anymore, and trying to handle the symlink->copy fallback per-file was already pretty rough as we aren't copying the regular executables.

    The design is the same as it was before, it's mainly just refactoring how we get there.

  8. encukou commented on Jan 4, 2024

    @encukou
    Member

    Do you plan to provide freethreaded debug (td) binaries?
    That does start a combinatorial explosion of builds, but I figure that people will need all the debugger help they can get. (And they'll want to run benchmarks so building only dt isn't appropriate.)

  9. zooba commented on Jan 4, 2024

    @zooba
    MemberAuthor

    They're included with the installer is the current PR. No option, you just get a python3.13t_d.exe along with the python3.13t.exe. If size becomes an issue then they'll be the first thing to go, but I think they only add about 5MB to the installer package (which is only downloaded when the option is selected during install).

    I'm not convinced the debug binaries are that helpful anyway, compared to just building it yourself. If you're in a position where they are helpful, you almost certainly have the build tools already (or know that you're doing something weird and ought to have the build tools).

  10. 5 remaining items

  11. added 2 commits that reference this issue on Jan 22, 2024
  12. zooba commented on Jan 22, 2024

    @zooba
    MemberAuthor

    @itamaro Yes, nogil tests now need to pass --disable-gil to rt.bat in order to get the correct executable name. I'm not sure where best to put that, I don't maintain any buildbots.

  13. itamaro commented on Jan 22, 2024

    @itamaro
    Contributor

    @itamaro Yes, nogil tests now need to pass --disable-gil to rt.bat in order to get the correct executable name. I'm not sure where best to put that, I don't maintain any buildbots.

    the builder is configured here. is the solution to add testFlags = ["--disable-gil"]? (I'm guessing these flags are passed down to rt.bat?)

  14. itamaro commented on Jan 22, 2024

    @itamaro
    Contributor

    we'll see if python/buildmaster-config#458 fixes it

  15. added a commit that references this issue on Jan 22, 2024
  16. added a commit that references this issue on Jan 23, 2024
  17. zooba commented on Feb 1, 2024

    @zooba
    MemberAuthor

    I don't see any need to keep this open, so closing. Feel free to reopen if there's a reason.

  18. added 3 commits that reference this issue on Feb 11, 2024
  19. added 3 commits that reference this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions