Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Implements automated Python environment setup during deepwork install as specified in PLAN.md. Users can now choose between uv, system Python, or skip environment creation, with configuration persisted in .deepwork/config.yml.

Changes

Core Infrastructure

  • src/deepwork/utils/python_env.py: New PythonEnvironment class managing venv creation, package installation, and existing environment detection
  • Supports three modes: uv (recommended), system (uses python3 from PATH), skip (manual management)

CLI Integration

  • src/deepwork/cli/install.py: Added --python-manager option and interactive prompt
  • Automatic detection of existing virtual environments (.venv, venv, .virtualenv)
  • Python config stored in .deepwork/config.yml with backward compatibility
  • Automatic .gitignore management: Creates or updates project's .gitignore to include .venv when virtual environment is created
    • Handles existing .gitignore files by appending
    • Prevents duplication if .venv already present
    • Ensures created virtual environments are properly ignored by git
  • Automatic pyproject.toml creation: Runs uv init --no-workspace when using uv manager to create Python project structure
    • Only creates pyproject.toml if it doesn't already exist
    • Preserves existing pyproject.toml files without modification
    • Sets up proper dependency management for Python projects

Config Schema Extension

python:
  manager: uv          # "uv" | "system" | "skip"
  version: "3.11"
  venv_path: .venv

Usage

# Interactive prompt (default)
deepwork install

# Skip Python setup
deepwork install --python-manager skip

# Use uv (recommended)
deepwork install --python-manager uv

# Use system Python
deepwork install --python-manager system

Existing projects without the python config section continue to work unchanged.



💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Created PythonEnvironment class for managing virtual environments
- Added support for uv, system Python, and skip options
- Added --python-manager CLI flag to install command
- Implemented interactive prompt for Python setup
- Added detection of existing virtual environments
- Updated config.yml schema to include python section
- Added comprehensive unit and integration tests
- Updated existing tests to work with new Python manager option

Co-authored-by: ncrmro <8276365+ncrmro@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement content from PLAN.md Implement Python environment management during install Jan 23, 2026
Copilot AI requested a review from ncrmro January 23, 2026 21:25
@ncrmro
Copy link
Collaborator

ncrmro commented Jan 27, 2026

@copilot this should actually create the .venv and ensure its gitignored (and that uv works and is availalbe)

- Created _ensure_venv_in_gitignore() function to manage project .gitignore
- Automatically creates or updates .gitignore to include .venv when venv is created
- Handles existing .gitignore files gracefully by appending
- Prevents duplication if .venv already exists in .gitignore
- Added 3 new integration tests to verify gitignore handling
- All 40 integration tests pass
- All 14 unit tests for python_env pass

Co-authored-by: ncrmro <8276365+ncrmro@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot this should actually create the .venv and ensure its gitignored (and that uv works and is availalbe)

Done in e00aa43. The implementation now:

  1. Creates the .venv directory when using uv or system manager
  2. Automatically creates or updates the project's .gitignore to include .venv
  3. Handles existing .gitignore files by appending (preserves existing content)
  4. Prevents duplication if .venv is already in .gitignore
  5. Verifies uv is available before attempting to use it (throws RuntimeError with helpful message if not found)

Added 3 new integration tests to verify the gitignore behavior. All 40 integration tests pass.

@ncrmro
Copy link
Collaborator

ncrmro commented Jan 27, 2026

@copilot this is also needs to run uv init --no-workspace to ensure there is a pyproject.toml

- Modified _setup_with_uv() to run uv init --no-workspace before creating venv
- Only runs uv init if pyproject.toml doesn't already exist
- Preserves existing pyproject.toml files without modification
- Updated unit test to verify uv init is called appropriately
- Added new unit test for when pyproject.toml already exists
- Added 2 new integration tests to verify pyproject.toml handling
- All 15 unit tests pass
- All 42 integration tests pass

Co-authored-by: ncrmro <8276365+ncrmro@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot this is also needs to run uv init --no-workspace to ensure there is a pyproject.toml

Done in 4130a98. The implementation now runs uv init --no-workspace before creating the virtual environment when using the uv manager.

Key behaviors:

  • Only runs uv init if pyproject.toml doesn't already exist
  • Preserves existing pyproject.toml files without modification
  • Creates a basic Python project structure with proper dependency management

Added 3 new tests (1 unit + 2 integration) to verify pyproject.toml handling. All 42 integration tests and 15 unit tests pass.

@ncrmro ncrmro requested a review from nhorton January 28, 2026 18:50
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