@@ -29,7 +29,7 @@ def _run_pip(args, additional_paths=None):
2929
3030 # Install the bundled software
3131 import pip
32- pip .main (args )
32+ return pip .main (args )
3333
3434
3535def version ():
@@ -58,6 +58,21 @@ def bootstrap(root=None, upgrade=False, user=False,
5858 Bootstrap pip into the current Python installation (or the given root
5959 directory).
6060
61+ Note that calling this function will alter both sys.path and os.environ.
62+ """
63+ # Discard the return value
64+ _bootstrap (root = root , upgrade = upgrade , user = user ,
65+ altinstall = altinstall , default_pip = default_pip ,
66+ verbosity = verbosity )
67+
68+
69+ def _bootstrap (root = None , upgrade = False , user = False ,
70+ altinstall = False , default_pip = True ,
71+ verbosity = 0 ):
72+ """
73+ Bootstrap pip into the current Python installation (or the given root
74+ directory). Returns pip command status code.
75+
6176 Note that calling this function will alter both sys.path and os.environ.
6277 """
6378 if altinstall and default_pip :
@@ -105,11 +120,10 @@ def bootstrap(root=None, upgrade=False, user=False,
105120 if verbosity :
106121 args += ["-" + "v" * verbosity ]
107122
108- _run_pip (args + [p [0 ] for p in _PROJECTS ], additional_paths )
123+ return _run_pip (args + [p [0 ] for p in _PROJECTS ], additional_paths )
109124 finally :
110125 shutil .rmtree (tmpdir , ignore_errors = True )
111126
112-
113127def _uninstall_helper (verbosity = 0 ):
114128 """Helper to support a clean default uninstall process on Windows
115129
@@ -135,7 +149,7 @@ def _uninstall_helper(verbosity=0):
135149 if verbosity :
136150 args += ["-" + "v" * verbosity ]
137151
138- _run_pip (args + [p [0 ] for p in reversed (_PROJECTS )])
152+ return _run_pip (args + [p [0 ] for p in reversed (_PROJECTS )])
139153
140154
141155def _main (argv = None ):
@@ -196,7 +210,7 @@ def _main(argv=None):
196210
197211 args = parser .parse_args (argv )
198212
199- bootstrap (
213+ return _bootstrap (
200214 root = args .root ,
201215 upgrade = args .upgrade ,
202216 user = args .user ,
0 commit comments