Skip to content

Commit

Permalink
fix windows test?
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Jan 24, 2024
1 parent ca368b9 commit 79a1d25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions conda_pip/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_env_python(prefix: Path) -> Path:
return prefix / "bin" / "python"


def get_env_site_packages(prefix: Path) -> Path:
def get_env_stdlib(prefix: Path) -> Path:
if str(prefix) == sys.prefix:
return Path(sysconfig.get_path("stdlib"))
return Path(check_output([get_env_python(prefix), "-c", "import sysconfig; print(sysconfig.get_paths()['stdlib'])"], text=True).strip())
Expand Down Expand Up @@ -139,8 +139,7 @@ def place_externally_managed(prefix: Path) -> Path:
some extra plugin hooks.
"""
# Get target env stdlib path
base_dir = check_output([get_env_python(prefix), "-c", "import sysconfig; print(sysconfig.get_paths()['stdlib'])"], text=True)
base_dir = base_dir.strip()
base_dir = get_env_stdlib(prefix)
externally_managed = Path(base_dir, "EXTERNALLY-MANAGED")
if externally_managed.exists():
return
Expand Down Expand Up @@ -180,7 +179,7 @@ def ensure_target_env_has_externally_managed(command: str):
# leave in place if pip is still installed
return
if os.name == "nt":
externally_managed = Path(target_prefix, "Lib", "site-packages", "EXTERNALLY-MANAGED")
externally_managed = Path(target_prefix, "Lib", "EXTERNALLY-MANAGED")
if externally_managed.exists():
logger.info("Removing %s", externally_managed)
externally_managed.unlink()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from conda.testing.integration import package_is_installed
from pytest_mock import MockerFixture

from conda_pip.main import get_env_python, get_env_site_packages
from conda_pip.main import get_env_python, get_env_stdlib


def test_pip_required_in_target_env(tmp_env: TmpEnvFixture, conda_cli: CondaCLIFixture, monkeypatch):
Expand Down Expand Up @@ -46,14 +46,14 @@ def test_externally_managed(tmp_env: TmpEnvFixture, conda_cli: CondaCLIFixture,
conda-pip places its own EXTERNALLY-MANAGED file when it is installed in an environment.
We also need to place it in _new_ environments created by conda.
"""
base_dir = get_env_site_packages(sys.prefix)
base_dir = get_env_stdlib(sys.prefix)
text = (base_dir / "EXTERNALLY-MANAGED").read_text().strip()
assert text.startswith("[externally-managed]")
assert "conda pip" in text

with tmp_env("python", "pip") as prefix:
conda_cli("pip", "-p", prefix, "--yes", "install", "requests", "--force-with-pip")
target_site_packages = get_env_site_packages(prefix)
target_site_packages = get_env_stdlib(prefix)
externally_managed_file = target_site_packages / "EXTERNALLY-MANAGED"
text = (externally_managed_file).read_text().strip()
assert text.startswith("[externally-managed]")
Expand Down

0 comments on commit 79a1d25

Please sign in to comment.