Skip to content

build: honour --use-system-libuv on MSVC, document the option - #188

Merged
Vizonex merged 4 commits into
Vizonex:mainfrom
evnchn:feat/use-system-libuv
Nov 5, 2026
Merged

Vizonex merged 4 commits into
Vizonex:mainfrom
evnchn:feat/use-system-libuv

Conversation

@evnchn

@evnchn evnchn commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

What do these changes do?

They make --use-system-libuv work on MSVC builds. So far the flag only took effect on MinGW (since #65). On MSVC the vendored libuv was always compiled in. With the flag, the MSVC build no longer compiles the vendored sources, drops the vendor/libuv include paths and links against an installed uv.lib instead.

I kept it inside the existing build_extensions branch rather than starting the bigger setup.py cleanup you described in #39, so the change stays small (+12/-6 in setup.py).

Are there changes in behavior for the user?

Not unless they pass the flag. With it, MSVC finds uv.h and uv.lib through the usual INCLUDE and LIB variables, and uv.dll has to be found when winloop is imported. Python 3.8+ no longer searches PATH for an extension's DLLs, so users (or a conda-forge recipe) need to call os.add_dll_directory first. The flag doesn't do that for them, so I added a short README section about it.

Is it a substantial burden for the maintainers to support this?

I don't think so. It is one extra branch, and the default build does not change.

Related issue number

Part of #39: the MSVC side of the conda-forge Windows case.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist (no unit test, checked with CI builds, see below)
  • Documentation reflects the changes
How I checked it (windows-latest, Python 3.12, libuv 1.53.0 from vcpkg)

🤖 Generated with Claude Code

evnchn and others added 4 commits November 1, 2026 03:03
The build_ext option already links against a system libuv instead of the
bundled copy, but the README never mentions it. Add a short note with the
command, verified on macOS arm64 with Homebrew libuv 1.53.0: the extension
builds, otool shows it linked to libuv.1.dylib, and a TCP echo runs on the
winloop loop.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Say the linker is asked for uv by name rather than guaranteed to link
dynamically, note the MinGW default, and note that non-MinGW Windows
builds always use the bundled libuv.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The MSVC path compiled the vendored libuv sources and ignored the flag.
With the flag set, skip the vendored sources and vendored include dirs,
and link uv.lib; MSVC finds uv.h and uv.lib through INCLUDE and LIB.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Found while verifying the MSVC flag in CI: the import failed with
DLL load failed until the libuv bin directory was added with
os.add_dll_directory, because Python 3.8+ ignores PATH for extension
dependencies.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>

@Vizonex Vizonex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

For now this seems like a good solution. Know that 3.14t and 3.15t has a freezing bug that is being fixed (Currently I'm looking at a writing a new C-API for _asyncio to replace winloop.loop.Future and still provide cdef class extensions).

@Vizonex Vizonex closed this Nov 5, 2026
@Vizonex

Vizonex commented Nov 5, 2026

Copy link
Copy Markdown
Owner

whoops, I'm trying to reopen give me a sec.

@Vizonex Vizonex reopened this Nov 5, 2026
@Vizonex
Vizonex merged commit f353b73 into Vizonex:main Nov 5, 2026
55 of 57 checks passed
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.

2 participants