|
69 | 69 | system_which,
|
70 | 70 | )
|
71 | 71 | from pipenv.utils.toml import cleanup_toml, convert_toml_outline_tables
|
| 72 | +from pipenv.utils.virtualenv import virtualenv_scripts_dir |
72 | 73 | from pipenv.vendor import plette, tomlkit
|
73 | 74 |
|
74 | 75 | try:
|
@@ -412,10 +413,11 @@ def is_venv_in_project(self) -> bool:
|
412 | 413 | def virtualenv_exists(self) -> bool:
|
413 | 414 | venv_path = Path(self.virtualenv_location)
|
414 | 415 | if venv_path.exists():
|
| 416 | + |
415 | 417 | if os.name == "nt":
|
416 |
| - activate_path = venv_path / "Scripts" / "activate.bat" |
| 418 | + activate_path = self.scripts_dir / "activate.bat" |
417 | 419 | else:
|
418 |
| - activate_path = venv_path / "bin" / "activate" |
| 420 | + activate_path = self.scripts_dir / "activate" |
419 | 421 | return activate_path.is_file()
|
420 | 422 |
|
421 | 423 | return False
|
@@ -612,6 +614,10 @@ def virtualenv_src_location(self) -> Path:
|
612 | 614 | loc.mkdir(parents=True, exist_ok=True)
|
613 | 615 | return loc
|
614 | 616 |
|
| 617 | + @property |
| 618 | + def virtualenv_scripts_location(self) -> Path: |
| 619 | + return virtualenv_scripts_dir(self.virtualenv.location) |
| 620 | + |
615 | 621 | @property
|
616 | 622 | def download_location(self) -> Path:
|
617 | 623 | if self._download_location is None:
|
@@ -1422,10 +1428,9 @@ def proper_case_section(self, section):
|
1422 | 1428 | def finders(self):
|
1423 | 1429 | from .vendor.pythonfinder import Finder
|
1424 | 1430 |
|
1425 |
| - scripts_dirname = "Scripts" if os.name == "nt" else "bin" |
1426 |
| - scripts_dir = Path(self.virtualenv_location) / scripts_dirname |
1427 | 1431 | finders = [
|
1428 |
| - Finder(path=str(scripts_dir), global_search=gs, system=False) |
| 1432 | + Finder(path=str(self.virtualenv_scripts_location), global_search=gs, |
| 1433 | + system=False) |
1429 | 1434 | for gs in (False, True)
|
1430 | 1435 | ]
|
1431 | 1436 | return finders
|
@@ -1463,12 +1468,14 @@ def _which(self, command, location=None, allow_global=False):
|
1463 | 1468 | is_python = command in ("python", Path(sys.executable).name, version_str)
|
1464 | 1469 |
|
1465 | 1470 | if not allow_global:
|
| 1471 | + scripts_location = virtualenv_scripts_dir(location_path) |
| 1472 | + |
1466 | 1473 | if os.name == "nt":
|
1467 |
| - p = find_windows_executable(str(location_path / "Scripts"), command) |
| 1474 | + p = find_windows_executable(str(scripts_location), command) |
1468 | 1475 | # Convert to Path object if it's a string
|
1469 | 1476 | p = Path(p) if isinstance(p, str) else p
|
1470 | 1477 | else:
|
1471 |
| - p = location_path / "bin" / command |
| 1478 | + p = scripts_location / command |
1472 | 1479 | elif is_python:
|
1473 | 1480 | p = Path(sys.executable)
|
1474 | 1481 | else:
|
|
0 commit comments