Windows: make lint/typecheck/test/docs/pr fail after setup_dev.ps1

Open
#1,595 4 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@LevelVoid is already working on this.

Since Nov 15, 2026.

  • #1609 by @LevelVoid — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
testing, tooling

Research direction

Start with the failing Makefile targets, scripts/audit_paths.py, libp2p/transport/tcp/tcp.py, and the two interop conftest.py files named in the report. Reproduce failures from Git Bash after running scripts/setup_dev.ps1, then check how Windows CI scopes tox and pytest. Done means the listed contributor targets either work on Windows or have documented, supported workarounds; the issue spans several tools and platform-specific behaviors.

Written by the indexing model from the issue text.

Description

Summary

After a successful Windows bootstrap with scripts/setup_dev.ps1 (#1578 / #1577), the usual contributor Makefile workflow does not pass on native Windows (Git Bash + GnuWin32/Chocolatey make).

This issue tracks making local Windows make parity closer to Linux/macOS (or documenting durable workarounds). Windows CI already avoids full make pr by running tox core / demos / utils / wheel only.

Related: #1578, #1577, docs update in eaf38d60.

Environment (repro)

  • OS: Windows 11 (10.0.26200)
  • Commit: eaf38d60 (fix/setup-dev-scripts)
  • Shell: Git Bash ("C:\Program Files\Git\bin\bash.exe" -l)
  • Python: 3.13.17 from uv in .venv
  • make: GNU Make 3.81 (C:\Program Files (x86)\GnuWin32\bin\make)
  • Setup: pwsh -File .\scripts\setup_dev.ps1 succeeded (exit 0)

Matrix

Target Exit Result
make clean 0 OK (rm / find via Git Bash)
make fix 0 OK (ruff check --fix)
make lint 2 Fail (mypy-local, pyrefly-local, path-audit)
make typecheck 2 Fail (mypy-local on SO_REUSEPORT)
make test 2 Fail at collection (fcntl in interop conftests)
make docs 2 Fail (nested make path with spaces/())
make pr 2 Fail (depends on clean+fix+lint+typecheck+test)

CI-scoped smoke (not a Makefile target):

python -m pytest tests/core tests/examples tests/utils -n auto -m "not serial_only" --maxfail=5
→ 2737 passed, 10 skipped, 5 failed (TLS: RuntimeError: Could not load libssl on Windows)

Failures and why

1. make lint / make typecheck — SO_REUSEPORT
libp2p\transport\tcp\tcp.py:59: error: Module has no attribute "SO_REUSEPORT"  [attr-defined]

Runtime already catches AttributeError/OSError, but mypy/pyrefly type the socket module on Windows where the constant is absent.

Suggested fix: getattr(stdlib_socket, "SO_REUSEPORT", None) / hasattr guard that typecheckers understand, or a platform-aware # type: ignore[attr-defined].

2. make lint — pyrefly + Store python3 stub
Failed to query interpreter at C:\Users\luca\AppData\Local\Microsoft\WindowsApps\python3.exe
Python was not found; ... disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases.

Pyrefly probes the Microsoft Store alias even when .venv is active.

Suggested fix: configure pyrefly/python path to .venv\Scripts\python.exe; document disabling App execution aliases; prefer uv-managed interpreters in tool config.

3. make lint — pyrefly fcntl on interop conftests
tests\interop\go_libp2p\conftest.py: ... No attribute `flock` in module `fcntl`
tests\interop\nim_libp2p\conftest.py: ... No attribute `flock` / `LOCK_EX` / `LOCK_NB`

fcntl is Unix-only. Typechecking these files on Windows fails.

Suggested fix: lazy/TYPE_CHECKING imports; pytest.importorskip / platform skip before import; exclude interop from Windows typecheck paths.

4. make lint — path-audit emoji on cp1252
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f50d'
scripts/audit_paths.py print("🔍 Scanning...")

Default Windows console encoding is often cp1252.

Suggested fix: ASCII-only log messages, or force UTF-8 (PYTHONUTF8=1 / sys.stdout.reconfigure(encoding="utf-8")) in the script/hook.

5. make test — interop collection imports fcntl
tests/interop/go_libp2p/conftest.py:8: import fcntl
ModuleNotFoundError: No module named 'fcntl'

Same for tests/interop/nim_libp2p/conftest.py. Pytest collection of tests/ loads those conftests and aborts before core tests run. Windows CI never collects tests/interop.

Suggested fix: defer fcntl behind a Windows-friendly lock (msvcrt / portalocker / skip module on win32); and/or change Makefile test on Windows to match CI (tests/core, tests/examples, tests/utils) / --ignore=tests/interop.

6. make docs — recursive make path with spaces
C:/Program Files (x86)/GnuWin32/bin/make -C docs clean
/usr/bin/sh: -c: line 1: syntax error near unexpected token `('

$(MAKE) expands to an unquoted path containing spaces and parentheses.

Suggested fix: quote $(MAKE) invocations; recommend a make whose path has no spaces (Chocolatey / MSYS2); or document WSL for docs builds.

7. Secondary: TLS tests need libssl on this guest
RuntimeError: Could not load libssl on Windows

Seen when running the CI-scoped pytest suite. Likely missing OpenSSL DLLs for the uv CPython build / environment (WinBoat), not necessarily a Makefile bug. Worth confirming on a stock Windows CI image / developer laptop with OpenSSL available.

Proposed workstreams

  1. Quick wins: ASCII audit_paths.py; quote $(MAKE) in docs targets; SO_REUSEPORT typing guard.
  2. Interop Windows safety: don't import fcntl at module import time; skip/ignore interop on win32 collection.
  3. Makefile Windows profile (optional): make test-windows / detect OS=Windows_NT and mirror CI paths; document that full make pr remains Linux/macOS/WSL.
  4. Tooling: pin typecheckers to .venv interpreter; document disabling Store python aliases.
  5. TLS/OpenSSL: document Windows OpenSSL requirement for TLS tests if reproducible outside this VM.

Workaround (today)

From PowerShell / Git Bash with .venv active:

python -m ruff check --fix
python -m pytest tests/core tests/examples tests/utils -n auto -m "not serial_only"

Prefer WSL or Linux/macOS for full make pr / docs until the items above land.

Acceptance ideas

  • make lint and make typecheck succeed on Windows (or clearly skip Windows-inapplicable hooks)
  • make test either ignores Unix-only interop on Windows or uses a Windows-safe lock
  • make docs works with a spaced make path or documents a supported toolchain
  • contributing docs stay aligned with actual Windows CI scope
Dominant language
Python
Stars
629
Forks
261
Avg merge
2d 3h
Merged PRs (30d)
30

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libp2p/py-libp2p

All issues in libp2p/py-libp2p

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.