Skip to content

Commit

Permalink
fix: compatability with pip v10.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
orsagie committed Apr 17, 2018
1 parent 85d3f44 commit d55bc84
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ node_js:
- "6"
- "4"
- "0.12"
env:
- PIP_VER=9.0.3
- PIP_VER=10.0.0
cache:
directories:
- node_modules
Expand All @@ -16,6 +19,7 @@ before_script:
- pip install virtualenv --user `whoami`
- virtualenv ./env
- source ./env/bin/activate
- pip install pip==$PIP_VER
script: npm test
jobs:
include:
Expand Down
Empty file added hJPb
Empty file.
10 changes: 8 additions & 2 deletions plug/pip_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
import json
import re
import argparse
import pip
import utils
import requirements

# 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.
try:
from pip import get_installed_distributions
except ImportError:
from pip._internal import get_installed_distributions

def create_tree_of_packages_dependencies(dist_tree, packages_names, req_file_path, allow_missing=False):
"""Create packages dependencies tree
Expand Down Expand Up @@ -119,7 +125,7 @@ def get_requirements_list(requirements_file):

def create_dependencies_tree_by_req_file_path(requirements_file_path, allow_missing=False):
# get all installed packages
pkgs = pip.get_installed_distributions(local_only=False, skip=[])
pkgs = get_installed_distributions(local_only=False, skip=[])

# get all installed packages's distribution object
dist_index = utils.build_dist_index(pkgs)
Expand Down
2 changes: 1 addition & 1 deletion test/workspaces/pip-app-with-options/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--allow-external=nose
--require-hashes
MarkupSafe==1.0 --hash=sha256:a6be69091dac236ea9c6bc7d012beab42010fa914c459791d627dad4910eb665 \
--hash=sha256:abcd \
--hash=sha256:0123 # a comment
Expand Down

0 comments on commit d55bc84

Please sign in to comment.