Skip to content

Commit

Permalink
Merge pull request #242 from PyAr/vcs-also-in-reqs
Browse files Browse the repository at this point in the history
Support multiword dependencies.
  • Loading branch information
gilgamezh committed Apr 9, 2017
2 parents 5e93f73 + 8706491 commit b670539
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions fades/pipmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,26 @@ def __init__(self, env_bin_path, pip_installed=False, options=None):
def install(self, dependency):
"""Install a new dependency."""
if not self.said_hi:
logger.info("Hi! This is fades %s, automatically managing your dependencies", __version__)
logger.info(
"Hi! This is fades %s, automatically managing your dependencies", __version__)
self.said_hi = True

if not self.pip_installed:
logger.info("Need to install a dependency with pip, but no builtin, "
"doing it manually (just wait a little, all should go well)")
self._brute_force_install_pip()

# split to pass several tokens on multiword dependency (this is very specific for '-e' on
# external requirements, but implemented generically; note that this does not apply for
# normal reqs, because even if it originally is 'foo > 1.2', after parsing it loses the
# internal spaces)
str_dep = str(dependency)
args = [self.pip_exe, "install", str_dep]
args = [self.pip_exe, "install"] + str_dep.split()

if self.options:
for option in self.options:
args.extend(option.split())
logger.info("Installing dependency: %s", str_dep)
logger.info("Installing dependency: %r", str_dep)
try:
helpers.logged_exec(args)
except helpers.ExecutionError as error:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_pipmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def test_install(self):
mgr.install('foo')
mock.assert_called_with(['/usr/bin/pip', 'install', 'foo'])

def test_install_multiword_dependency(self):
mgr = PipManager('/usr/bin', pip_installed=True)
with patch.object(helpers, 'logged_exec') as mock:
mgr.install('foo bar')
mock.assert_called_with(['/usr/bin/pip', 'install', 'foo', 'bar'])

def test_install_with_options(self):
mgr = PipManager('/usr/bin', pip_installed=True, options=['--bar baz'])
with patch.object(helpers, 'logged_exec') as mock:
Expand Down

0 comments on commit b670539

Please sign in to comment.