Skip to content

Enhance _setup_certifi_env to use virtual environment's certifi #1654

@coderabbitai

Description

@coderabbitai

Enhancement Request

Current Behavior

The _setup_certifi_env function in builder/penv_setup.py currently imports certifi directly from the host system and uses certifi.where() to get the certificate path.

Proposed Enhancement

Modify the function to:

  1. Accept an optional python_exe parameter
  2. First attempt to get the certifi path from the virtual environment using the provided Python executable
  3. Fall back to the host system's certifi if the virtual environment approach fails
  4. Provide better error handling throughout the process

Technical Benefits

  • Ensures certificate handling is consistent with the virtual environment setup
  • Reduces dependency on host system packages
  • Aligns with the project's goal of isolating the Python environment
  • Provides more robust error handling

Reference

Current Implementation

def _setup_certifi_env(env):
    """Setup certifi environment variables with optional SCons integration."""
    try:
        import certifi
    except ImportError:
        print("Info: certifi not available; skipping CA environment setup.")
        return
    
    cert_path = certifi.where()
    # ... sets environment variables

Proposed Enhancement

The enhancement would modify the function signature to accept a python_exe parameter and attempt to get certifi from the virtual environment first, with graceful fallback to the host system approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions