Skip to content

Commit

Permalink
Need to reinitialize PIP workset in pip_utils
Browse files Browse the repository at this point in the history
fixes pybuilder#295, connected to pybuilder#295, connected to pybuilder#272, connected to pybuilder#293
  • Loading branch information
arcivanov committed Dec 6, 2015
1 parent f87070b commit 70e6ba9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/python/pybuilder/pip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
from pip._vendor.packaging.specifiers import SpecifierSet, InvalidSpecifier
from pip._vendor.packaging.version import Version, InvalidVersion
from pip.commands.show import search_packages_info
try:
# This is the path for pip 7.x
from pip._vendor.pkg_resources import _initialize_master_working_set
pip_working_set_init = _initialize_master_working_set
except ImportError:
# This is the path for pip 6.x
from pip._vendor import pkg_resources
pip_working_set_init = pkg_resources

from pybuilder.core import Dependency, RequirementsFile
from pybuilder.utils import execute_command, as_list
Expand Down Expand Up @@ -135,6 +143,7 @@ def normalize_dependency_package(mixed):

package_query = [normalized_package for normalized_package in
(normalize_dependency_package(p) for p in as_list(mixed)) if normalized_package]
pip_working_set_init()
search_packages_results = search_packages_info(package_query)
return dict(((result['name'].lower(), result['version']) for result in search_packages_results))

Expand Down

0 comments on commit 70e6ba9

Please sign in to comment.