@@ -25,7 +25,7 @@ def _run_pip(args, additional_paths=None):
2525
2626 # Install the bundled software
2727 import pip
28- pip .main (args )
28+ return pip .main (args )
2929
3030
3131def version ():
@@ -53,6 +53,21 @@ def bootstrap(*, root=None, upgrade=False, user=False,
5353 Bootstrap pip into the current Python installation (or the given root
5454 directory).
5555
56+ Note that calling this function will alter both sys.path and os.environ.
57+ """
58+ # Discard the return value
59+ _bootstrap (root = root , upgrade = upgrade , user = user ,
60+ altinstall = altinstall , default_pip = default_pip ,
61+ verbosity = verbosity )
62+
63+
64+ def _bootstrap (* , root = None , upgrade = False , user = False ,
65+ altinstall = False , default_pip = False ,
66+ verbosity = 0 ):
67+ """
68+ Bootstrap pip into the current Python installation (or the given root
69+ directory). Returns pip command status code.
70+
5671 Note that calling this function will alter both sys.path and os.environ.
5772 """
5873 if altinstall and default_pip :
@@ -99,7 +114,7 @@ def bootstrap(*, root=None, upgrade=False, user=False,
99114 if verbosity :
100115 args += ["-" + "v" * verbosity ]
101116
102- _run_pip (args + [p [0 ] for p in _PROJECTS ], additional_paths )
117+ return _run_pip (args + [p [0 ] for p in _PROJECTS ], additional_paths )
103118
104119def _uninstall_helper (* , verbosity = 0 ):
105120 """Helper to support a clean default uninstall process on Windows
@@ -126,7 +141,7 @@ def _uninstall_helper(*, verbosity=0):
126141 if verbosity :
127142 args += ["-" + "v" * verbosity ]
128143
129- _run_pip (args + [p [0 ] for p in reversed (_PROJECTS )])
144+ return _run_pip (args + [p [0 ] for p in reversed (_PROJECTS )])
130145
131146
132147def _main (argv = None ):
@@ -180,7 +195,7 @@ def _main(argv=None):
180195
181196 args = parser .parse_args (argv )
182197
183- bootstrap (
198+ return _bootstrap (
184199 root = args .root ,
185200 upgrade = args .upgrade ,
186201 user = args .user ,
0 commit comments