From 658e8e3c87b40bc176c32c7cd354d4bf3db02f15 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 14 Sep 2017 11:14:45 -0400 Subject: [PATCH] move imports to right spot Signed-off-by: Kenneth Reitz --- pipenv/utils.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index cb18617d..d4086c4d 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -7,9 +7,15 @@ from collections import namedtuple import delegator import requests +import pip import parse import six +from piptools.resolver import Resolver +from piptools.repositories.pypi import PyPIRepository +from piptools.scripts.compile import get_pip_command +from piptools import logging + # List of version control systems we support. VCS_LIST = ('git', 'svn', 'hg', 'bzr') FILE_LIST = ('http://', 'https://', 'ftp://', 'file:///') @@ -42,6 +48,7 @@ def clean_pkg_version(version): class HackedPythonVersion(object): + """A Beautiful hack, which allows us to tell pip which version of Python we're using.""" def __init__(self, python): self.python = python self.original = sys.version_info @@ -49,13 +56,13 @@ class HackedPythonVersion(object): def __enter__(self): if self.python: # Create a new named tuple to place fake version info into. - sys.version_info = namedtuple('fake_version_info', ['major', 'minor', 'micro', 'releaselevel', 'serial']) + fake_version_info = namedtuple('fake_version_info', ['major', 'minor', 'micro', 'releaselevel', 'serial']) # Parse Python version. python = self.python.split('.') # Hack sys.version_info to contain our information instead... - sys.version_info = sys.version_info(int(python[0]), int(python[1]), int(python[2]), 'final', 0) + sys.version_info = fake_version_info(int(python[0]), int(python[1]), int(python[2]), 'final', 0) def __exit__(self, *args): # Restore original Python version information. @@ -69,17 +76,10 @@ def resolve_deps(deps, sources=None, verbose=False, python=False): with HackedPythonVersion(python): - import pip - class PipCommand(pip.basecommand.Command): """Needed for pip-tools.""" name = 'PipCommand' - from piptools.resolver import Resolver - from piptools.repositories.pypi import PyPIRepository - from piptools.scripts.compile import get_pip_command - from piptools import logging - constraints = [] for dep in deps: