From cb22a129eae8c8e800e603c38bf1fe04d420fbde Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 23 Jan 2017 17:04:33 -0500 Subject: [PATCH] use source from Pipfile #34 --- pipenv/cli.py | 8 +++++--- pipenv/project.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 783ee7f8..01c4535b 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -128,7 +128,8 @@ def do_install_dependencies(dev=False, only=False, bare=False, allow_global=Fals if not bare: click.echo('Installing {0}...'.format(crayons.green(package_name))) - c = delegator.run('{0} install "{1}"'.format(which_pip(allow_global=allow_global), package_name),) + # pip install: + c = delegator.run('{0} install "{1}" --index-url {2}'.format(which_pip(allow_global=allow_global), package_name, project.source['url'])) if not bare: click.echo(crayons.blue(c.out)) @@ -170,7 +171,7 @@ def do_lock(dev=False): # Load the Pipfile and generate a lockfile. p = pipfile.load(project.pipfile_location) - lockfile = json.loads(p.lock()) + lockfile = json.loads(p.freeze()) # Pip freeze development dependencies. c = delegator.run('{0} freeze'.format(which_pip())) @@ -370,7 +371,8 @@ def install(package_name=False, more_packages=False, r=False, dev=False, system= click.echo('Installing {0}...'.format(crayons.green(package_name))) - c = delegator.run('{0} install "{1}"'.format(which_pip(allow_global=system), package_name)) + # pip install: + c = delegator.run('{0} install "{1}" -i {2}'.format(which_pip(allow_global=system), package_name, project.source['url'])) click.echo(crayons.blue(c.out)) # Ensure that package was successfully installed. diff --git a/pipenv/project.py b/pipenv/project.py index 15f35db8..6402f567 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -35,6 +35,11 @@ class Project(object): except RuntimeError: return None + @property + def parsed_pipfile(self): + with open(self.pipfile_location, 'r') as f: + return toml.load(f) + @property def lockfile_location(self): return '{0}.lock'.format(self.pipfile_location) @@ -48,6 +53,13 @@ class Project(object): with open('Pipfile', 'w') as f: f.write(toml.dumps(data)) + @property + def source(self): + if 'source' in self.parsed_pipfile: + return self.parsed_pipfile['source'][0] + else: + return [{u'url': u'https://pypi.org/', u'verify_ssl': True}][0] + @staticmethod def remove_package_from_pipfile(package_name, dev=False): pipfile_path = pipfile.Pipfile.find()