Skip to content

Commit

Permalink
Merge pull request #39 from NeonGraal/add_config_path
Browse files Browse the repository at this point in the history
Add config path
  • Loading branch information
NeonGraal authored Apr 18, 2018
2 parents e3c8969 + b7c65c9 commit 955d8be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion script_venv/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 955d8be

Please sign in to comment.