Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
pypy
Commits
17694ed47a34
Commit
e46f8dcd
authored
Oct 27, 2019
by
Matti Picus
Browse files
backport ensurepip from 3.6
parent
eba4da103b3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib-python/2.7/ensurepip/__init__.py
View file @
17694ed4
...
...
@@ -4,7 +4,6 @@ from __future__ import print_function
import
os
import
os.path
import
pkgutil
import
shutil
import
sys
import
tempfile
...
...
@@ -28,8 +27,8 @@ def _run_pip(args, additional_paths=None):
sys
.
path
=
additional_paths
+
sys
.
path
# Install the bundled software
import
pip
pip
.
main
(
args
)
import
pip
._internal
return
pip
.
_internal
.
main
(
args
)
def
version
():
...
...
@@ -38,7 +37,6 @@ def version():
"""
return
_PIP_VERSION
def
_disable_pip_configuration_settings
():
# We deliberately ignore all pip environment variables
# when invoking pip
...
...
@@ -52,12 +50,27 @@ def _disable_pip_configuration_settings():
def
bootstrap
(
root
=
None
,
upgrade
=
False
,
user
=
False
,
altinstall
=
False
,
default_pip
=
Tru
e
,
altinstall
=
False
,
default_pip
=
Fals
e
,
verbosity
=
0
):
"""
Bootstrap pip into the current Python installation (or the given root
directory).
Note that calling this function will alter both sys.path and os.environ.
"""
# Discard the return value
_bootstrap
(
root
=
root
,
upgrade
=
upgrade
,
user
=
user
,
altinstall
=
altinstall
,
default_pip
=
default_pip
,
verbosity
=
verbosity
)
def
_bootstrap
(
root
=
None
,
upgrade
=
False
,
user
=
False
,
altinstall
=
False
,
default_pip
=
False
,
verbosity
=
0
):
"""
Bootstrap pip into the current Python installation (or the given root
directory). Returns pip command status code.
Note that calling this function will alter both sys.path and os.environ.
"""
if
altinstall
and
default_pip
:
...
...
@@ -78,8 +91,7 @@ def bootstrap(root=None, upgrade=False, user=False,
# omit pip and easy_install
os
.
environ
[
"ENSUREPIP_OPTIONS"
]
=
"install"
tmpdir
=
tempfile
.
mkdtemp
()
try
:
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
# Put our bundled wheels into a temporary directory and construct the
# additional paths that need added to sys.path
additional_paths
=
[]
...
...
@@ -105,10 +117,7 @@ def bootstrap(root=None, upgrade=False, user=False,
if
verbosity
:
args
+=
[
"-"
+
"v"
*
verbosity
]
_run_pip
(
args
+
[
p
[
0
]
for
p
in
_PROJECTS
],
additional_paths
)
finally
:
shutil
.
rmtree
(
tmpdir
,
ignore_errors
=
True
)
return
_run_pip
(
args
+
[
p
[
0
]
for
p
in
_PROJECTS
],
additional_paths
)
def
_uninstall_helper
(
verbosity
=
0
):
"""Helper to support a clean default uninstall process on Windows
...
...
@@ -135,7 +144,7 @@ def _uninstall_helper(verbosity=0):
if
verbosity
:
args
+=
[
"-"
+
"v"
*
verbosity
]
_run_pip
(
args
+
[
p
[
0
]
for
p
in
reversed
(
_PROJECTS
)])
return
_run_pip
(
args
+
[
p
[
0
]
for
p
in
reversed
(
_PROJECTS
)])
def
_main
(
argv
=
None
):
...
...
@@ -176,27 +185,20 @@ def _main(argv=None):
"--altinstall"
,
action
=
"store_true"
,
default
=
False
,
help
=
(
"Make an alternate install, installing only the X.Y versioned"
"scripts (Default: pipX, pipX.Y, easy_install-X.Y)"
),
help
=
(
"Make an alternate install, installing only the X.Y versioned
"
"scripts (Default: pipX, pipX.Y, easy_install-X.Y)
.
"
),
)
parser
.
add_argument
(
"--default-pip"
,
action
=
"store_true"
,
default
=
True
,
dest
=
"default_pip"
,
help
=
argparse
.
SUPPRESS
,
)
parser
.
add_argument
(
"--no-default-pip"
,
action
=
"store_false"
,
dest
=
"default_pip"
,
help
=
(
"Make a non default install, installing only the X and X.Y "
"versioned scripts."
),
default
=
False
,
help
=
(
"Make a default pip install, installing the unqualified pip "
"and easy_install in addition to the versioned scripts."
),
)
args
=
parser
.
parse_args
(
argv
)
bootstrap
(
return
_
bootstrap
(
root
=
args
.
root
,
upgrade
=
args
.
upgrade
,
user
=
args
.
user
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment