diff --git a/script_venv/venv.py b/script_venv/venv.py index ed8a232a..82878593 100644 --- a/script_venv/venv.py +++ b/script_venv/venv.py @@ -29,6 +29,12 @@ def abs_path(raw_path: Path) -> Path: return Path(abs_path).absolute() +def venv_path(cfg_path: Path, location: str) -> Path: + if cfg_path.name == '.config': + cfg_path = Path(*cfg_path.parts[:-1]) + return cfg_path / location if location else cfg_path + + class VEnvDependencies(object): # pragma: no cover def echo(self, msg: str): raise NotImplementedError() @@ -54,7 +60,7 @@ def __init__(self, name: str, deps: VEnvDependencies, self.config_path = config_path self.requirements = set(requirements or []) self.prerequisites = set(prerequisites or []) - self.env_path = (Path(config_path, location) if location else Path(config_path)) / '.sv' / name + self.env_path = venv_path(Path(config_path), location) / '.sv' / name self.abs_path = abs_path(self.env_path) def __str__(self) -> str: diff --git a/tests/test_config.py b/tests/test_config.py index 7b961a02..ab5c62d7 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -118,14 +118,14 @@ def test_venv_user(self, config_deps: Mock, config: VenvConfig) -> None: config.load() - assert '~' in str(config.venvs['pip.test']) + assert path.join('~', '.sv') in str(config.venvs['pip.test']) def test_venv_local(self, config_deps: Mock, config: VenvConfig) -> None: config_read(config_deps, {self.CWD_sv_cfg: "[pip.test]\nlocation = ~\n"}) config.load() - assert '~' in str(config.venvs['pip.test']) + assert path.join('~', '.sv') in str(config.venvs['pip.test']) class TestVenvConfigList(VenvConfigFixtures):