Skip to content

Commit

Permalink
Translate PIP_CONSTRAINT(S) into UV_CONSTRAINTS if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jan 16, 2025
1 parent e123ace commit f390073
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tox_uv/_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import json
import logging
import sys
from abc import ABC
from functools import cached_property
Expand Down Expand Up @@ -41,6 +42,7 @@
"system",
"only-system",
]
logger = logging.getLogger(__name__)


class UvVenv(Python, ABC):
Expand Down Expand Up @@ -178,6 +180,12 @@ def environment_variables(self) -> dict[str, str]:
env = super().environment_variables
env.pop("UV_PYTHON", None) # UV_PYTHON takes precedence over VIRTUAL_ENV
env["VIRTUAL_ENV"] = str(self.venv_dir)
for pip_var in ("PIP_CONSTRAINT", "PIP_CONSTRAINTS"):
if pip_var in env:
logger.warning(
"Found %s defined, you may want to also define UV_CONSTRAINT to match pip behavior.", pip_var
)
break
return env

def _default_pass_env(self) -> list[str]:
Expand Down

0 comments on commit f390073

Please sign in to comment.