Skip to content

Conversation

@Enfoirer
Copy link
Contributor

@Enfoirer Enfoirer commented Jan 3, 2026

Description

Fixes Windows path detection in UV installation method detection, resolving the "No module named pip" error for Windows users.

Fixes #149

Changes Made

Code Changes

  • pdd/auto_update.py: Add path separator normalization in detect_installation_method()
    • Normalize backslashes to forward slashes before pattern matching
    • Maintains backward compatibility with Unix paths

Test Changes

  • tests/test_auto_update.py: Add test_detect_uv_installation_windows()
    • Tests Windows paths with backslashes
    • Tests Windows paths with forward slashes (normalized)
    • Ensures cross-platform compatibility

Prompt Changes

  • pdd/prompts/auto_update_python.prompt: Updated via pdd update
    • Reflects cross-platform path detection requirement

Testing

Test Results

======================== 12 passed, 1 warning in 0.02s =========================
About the pytest warning:

This warning (Unknown config option: asyncio_default_fixture_loop_scope) is a pre-existing issue in the project's pytest configuration, not introduced by this PR.

Evidence:

  • Main branch (before changes): 11 passed, 1 warning
  • Feature branch (with fix): 12 passed, 1 warning

The warning exists in both branches. The only difference is one additional test for Windows path detection. All tests pass successfully and the warning does not affect functionality.

All auto_update tests pass including:

  • ✅ Existing Unix path detection tests
  • ✅ New Windows path detection test
  • ✅ Pip installation detection
  • ✅ UV upgrade workflow

Testing Environment

  • Platform: macOS 26
  • Python: 3.12
  • Testing approach: Unit tests with Windows path strings

Limitations

Windows environment verification needed: Tested on macOS using unit tests that simulate Windows paths. Real Windows + UV environment testing would be valuable.

Dev Unit Checklist

  • Code: Updated implementation
  • Tests: Added comprehensive test coverage
  • Prompt: Synced via pdd update
  • Example: N/A (bug fix, not new feature)

Regression Testing

  • All existing tests pass
  • No changes to public API
  • Backward compatible with Unix paths

Screenshots/Logs

N/A - Logic fix verified through unit tests

Related Issues

Fixes #149

Additional Notes

This fix follows PDD principles:

  • Tests act as permanent "mold walls" preventing regression
  • Prompt updated to reflect actual implementation
  • Code regeneration from prompt will preserve this fix

@gltanaka gltanaka requested a review from Copilot January 6, 2026 00:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the UV installation method detection on Windows by normalizing path separators before pattern matching. The issue occurred because Windows uses backslashes (\) in paths while the detection logic only looked for forward slashes (/).

Key Changes:

  • Normalized path separators in detect_installation_method() to handle both Unix and Windows paths
  • Added comprehensive test coverage for Windows path detection scenarios
  • Updated the prompt file to reflect cross-platform path detection requirements

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pdd/auto_update.py Normalized path separators in detect_installation_method() and improved docstrings/type hints throughout
tests/test_auto_update.py Added Windows path detection test (duplicated function definition)
pdd/prompts/auto_update_python.prompt Updated requirements to specify cross-platform path separator support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +210 to 228
def test_detect_uv_installation_windows():
"""Test detection of UV installation on Windows with backslash paths."""
# Test Windows UV tool paths with backslashes
assert detect_installation_method(
r"C:\Users\pmbri\AppData\Roaming\uv\tools\pdd-cli\Scripts\python.exe"
) == "uv"
assert detect_installation_method(
r"C:\Users\user\.local\share\uv\tools\pdd-cli\Scripts\python.exe"
) == "uv"
assert detect_installation_method(
r"D:\uv\tools\pdd-cli\bin\python.exe"
) == "uv"
# Test with forward slashes on Windows (some tools normalize paths)
assert detect_installation_method(
"C:/Users/user/AppData/Roaming/uv/tools/pdd-cli/Scripts/python.exe"
) == "uv"


def test_get_upgrade_command():
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The function test_detect_uv_installation_windows() is defined twice in this file (lines 210-226 and lines 248-259). This will cause the first definition to be silently overwritten by the second, and only one set of test cases will actually execute. Remove the duplicate definition at lines 248-259.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The suggested change have been made

assert isinstance(pip_shell, bool)
assert isinstance(pip_shell, bool)

#test for Windows paths with backslashes
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

Comments should start with a capital letter and have a space after the #. Change to # Test for Windows paths with backslashes.

Suggested change
#test for Windows paths with backslashes
# Test for Windows paths with backslashes

Copilot uses AI. Check for mistakes.
@gltanaka
Copy link
Contributor

gltanaka commented Jan 6, 2026

  1. cap
  2. make regression and make sync-regression
  3. Make sure test created actually detects bug (pdd bug issue)
  4. fix warnings
  5. test coverage pytest coverage (make coverage)
  6. address github issue

@Enfoirer Enfoirer force-pushed the fix/windows-uv-path-detection branch from 5b0c732 to 24f232d Compare January 9, 2026 04:56
Add test case for Windows paths with backslashes in UV installation
detection to demonstrate the bug where Windows users encounter
"No module named pip" error during auto-update.
@Enfoirer Enfoirer force-pushed the fix/windows-uv-path-detection branch 2 times, most recently from a39a9a9 to 6ef3c6c Compare January 9, 2026 09:17
@Enfoirer
Copy link
Contributor Author

Enfoirer commented Jan 9, 2026

Test Results Update

Hi! I've completed all requested validations for this PR. Here are the results:


1. Regression Tests

make regression

  • All tests passed
  • No regressions introduced by the fix

make sync-regression

  • Successfully completed
  • Note: Ran in serial mode (SYNC_PARALLEL=0) due to macOS Bash 3.2 compatibility

2. Bug Detection Validation

Verified that test_detect_uv_installation_windows correctly detects the bug:

Before fix (without path normalization):
FAILED tests/test_auto_update.py::test_detect_uv_installation_windows
AssertionError: assert 'pip' == 'uv'

  • Windows path C:\Users\...\uv\tools\... was incorrectly detected as pip

After fix (with path normalization):
PASSED tests/test_auto_update.py::test_detect_uv_installation_windows

  • Windows paths now correctly detected as uv

This confirms the test reproduces the original bug and validates the fix works as intended.


3. Warnings Fixed

Issue: pytest warning Unknown config option: asyncio_default_fixture_loop_scope

Fix: Installed dev dependencies (pip install -e ".[dev]") which includes pytest-asyncio

Result: All warnings resolved


4. Test Coverage

pdd/auto_update.py 81 lines 13 missed 84% coverage
Missing lines: 62, 125-129, 201-206, 210, 219

Critical finding:

  • Lines 32-37 (the Windows path normalization fix) are 100% covered
  • The test_detect_uv_installation_windows test fully exercises the bug fix
  • Uncovered lines are actual upgrade execution code (require real installation environment)

Coverage Summary:

  • Overall coverage: 84% for auto_update.py
  • Bug fix coverage: 100%

Additional Improvements

  • Removed duplicate test_detect_uv_installation_windows() function that was overriding the complete test
  • Rebased to latest upstream/main

Copy link
Contributor

Choose a reason for hiding this comment

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

you need to remove this prompt change here and put it in pdd_cap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already done. The prompt change is now in pdd_cap.

Normalize path separators to handle both Unix (/) and Windows (\) paths
when detecting UV installation method. This fixes the "No module named pip"
error that Windows users encounter during auto-update.

The fix adds path normalization in detect_installation_method() by
converting backslashes to forward slashes before checking for UV path
markers, ensuring cross-platform compatibility.
Fixed issue where two identical test functions existed in the same file.
The duplicate function (lines 248-259) was overriding the more complete
version (lines 210-226), which included additional test cases.
@Enfoirer Enfoirer force-pushed the fix/windows-uv-path-detection branch from 6ef3c6c to 550a738 Compare January 10, 2026 03:10
@Enfoirer Enfoirer requested a review from gltanaka January 10, 2026 03:25
@gltanaka gltanaka merged commit 2a1a95a into promptdriven:main Jan 10, 2026
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.

pdd upgrade not working from the prompt

3 participants