Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions pdd/python_env_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import sys
import shutil
from pathlib import Path
from typing import Optional


def detect_host_python_executable() -> str:
Expand Down Expand Up @@ -122,15 +121,21 @@ def get_environment_type() -> str:
Returns:
str: Type of environment ('conda', 'venv', 'poetry', 'pipenv', 'system', 'unknown')
"""
if os.environ.get('CONDA_PREFIX'):
env = os.environ
if 'CONDA_PREFIX' in env:
return 'conda'
elif os.environ.get('POETRY_ACTIVE'):
elif 'POETRY_ACTIVE' in env:
return 'poetry'
elif os.environ.get('PIPENV_ACTIVE'):
elif 'PIPENV_ACTIVE' in env:
return 'pipenv'
elif os.environ.get('VIRTUAL_ENV'):
elif 'VIRTUAL_ENV' in env:
return 'venv'
elif is_in_virtual_environment():
elif (
'VIRTUAL_ENV' in env or
'CONDA_PREFIX' in env or
'POETRY_ACTIVE' in env or
'PIPENV_ACTIVE' in env
):
return 'unknown'
else:
return 'system'
Expand Down