File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env python3
22
3- import sys
3+ import site
4+ from typing import List
45from pip ._internal .req .constructors import install_req_from_line
56from pip ._internal .utils .virtualenv import running_under_virtualenv
67
78
8- def main () -> int :
9- if len (sys .argv ) < 2 :
10- print ("Usage: check-pip-pkg-installed-version.py requirement [requirements]" )
11- return 2
12-
9+ def main (req_strs : List [str ]) -> int :
1310 return_code = 0
1411 pkg_installed = []
1512
1613 try :
17- for arg in sys . argv [ 1 :] :
18- req = install_req_from_line (arg )
14+ for req_str in req_strs :
15+ req = install_req_from_line (req_str )
1916
2017 req .check_if_exists (not running_under_virtualenv ())
2118
@@ -34,4 +31,14 @@ def main() -> int:
3431
3532
3633if __name__ == "__main__" :
37- sys .exit (main ())
34+ import argparse
35+ import sys
36+
37+ parser = argparse .ArgumentParser (
38+ description = "Check if a set of pip package is installed, meeting a requirement string."
39+ )
40+ parser .add_argument ("req_strs" , nargs = "+" )
41+
42+ args = parser .parse_args ()
43+
44+ sys .exit (main (** vars (args )))
You can’t perform that action at this time.
0 commit comments