Skip to content

Commit

Permalink
fix: support pip 18
Browse files Browse the repository at this point in the history
the `get_installed_distributions` method that was moved under `._internal`,
was moved again in pip 18 to `._internal.utils.misc`.
This PR tries the new location if the 2 existing options don't work.
  • Loading branch information
michael-go committed Oct 7, 2018
1 parent 67dade0 commit 11b26ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ node_js:
env:
- PIP_VER=9.0.3 PYTHON_VER=2.7
- PIP_VER=9.0.3 PYTHON_VER=3.6
# - PIP_VER=9.0.3 PYTHON_VER=3.7 # missing in Travis's old version of pyenv
- PIP_VER=10.0.0 PYTHON_VER=2.7
- PIP_VER=10.0.0 PYTHON_VER=3.6
# - PIP_VER=10.0.0 PYTHON_VER=3.7 # missing in Travis's old version of pyenv
- PIP_VER=18.1.0 PYTHON_VER=2.7
- PIP_VER=18.1.0 PYTHON_VER=3.6
cache:
directories:
- node_modules
Expand Down
11 changes: 8 additions & 3 deletions plug/pip_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
import pipfile

# pip >= 10.0.0 moved all APIs to the _internal package reflecting the fact
# that pip does not currently have any public APIs. This is a temporary fix.
# TODO: We need a workaround to using the get_installed_distributions method.
# that pip does not currently have any public APIs.
# pip >= 18.0.0 moved the internal API we use deeper to _internal.utils.misc
# TODO: This is a temporary fix that might not hold again for upcoming releases,
# we need a better approach for this.
try:
from pip import get_installed_distributions
except ImportError:
from pip._internal import get_installed_distributions
try :
from pip._internal import get_installed_distributions
except ImportError:
from pip._internal.utils.misc import get_installed_distributions


def create_tree_of_packages_dependencies(dist_tree, packages_names, req_file_path, allow_missing=False):
Expand Down

0 comments on commit 11b26ef

Please sign in to comment.