-
Notifications
You must be signed in to change notification settings - Fork 249
/
pip_common.py
65 lines (51 loc) · 2.08 KB
/
pip_common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
#
# This file is part of PyBuilder
#
# Copyright 2011-2015 PyBuilder Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pip._vendor.packaging.specifiers import SpecifierSet, InvalidSpecifier
from pip._vendor.packaging.version import Version, InvalidVersion
try:
from pip.commands.show import search_packages_info
except ImportError:
from pip._internal.commands.show import search_packages_info
try:
# This is the path for pip 7.x and beyond
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 imp import reload
from pip._vendor import pkg_resources
def pip_working_set_init():
reload(pkg_resources)
SpecifierSet = SpecifierSet
InvalidSpecifier = InvalidSpecifier
Version = Version
InvalidVersion = InvalidVersion
search_packages_info = search_packages_info
def _pip_disallows_insecure_packages_by_default():
import pip
# (2014-01-01) BACKWARD INCOMPATIBLE pip no longer will scrape insecure external urls by default
# nor will it install externally hosted files by default
# Also pip v1.1 for example has no __version__
return hasattr(pip, "__version__") and (pip.__version__ >= '1.5' or pip.__version__ >= '10.0')
def _pip_supports_constraints():
import pip
return hasattr(pip, "__version__") and (pip.__version__ >= '7.1' or pip.__version__ >= '10.0')
def _pip_version():
import pip
return getattr(pip, "__version__", None)
pip_version = _pip_version()