66import zipfile
77
88import pkginfo
9- import pip ._internal .main as pip
109
1110import pkg_resources
1211
@@ -127,17 +126,16 @@ def main():
127126 # There is no good library to parse this file so we do some rudimentary try-except on the individual lines
128127 requirements = {}
129128 req_file = open (args .requirements , "r" )
130- for r in req_file :
129+ for r in req_file . readlines () :
131130 try :
132- req = Requirement .parse (r )
131+ req = pkg_resources . Requirement .parse (r )
133132 requirements [req .name ] = req
134133 except :
135134 # At this point we log and continue. It is assumed pip will fail if the file is actually incorrect
136135 print ("Failed to parse requirement %s" % r )
137136
138- # Assumes any errors are logged by pip so do nothing
139- if pip .main (["wheel" , "-r" , args .requirements ]):
140- sys .exit (1 )
137+ # Assumes any errors are logged by pip so do nothing. This command will fail if pip fails
138+ subprocess .check_output ([sys .executable , "-m" , "pip" , "wheel" , "-r" , args .requirements ])
141139
142140 for whl_file in glob .glob ("*.whl" ):
143141 whl_dir = str (whl_file ).lower ().split ("-" )[0 ]
@@ -151,10 +149,7 @@ def main():
151149 os .remove (whl_file )
152150
153151 targets = "," .join (
154- [
155- '"%s//%s:pkg"' % (args .repo , sanitise_package (package ))
156- for package in requirements
157- ]
152+ ['"%s//%s:pkg"' % (args .repo , sanitise_package (package )) for package in requirements ]
158153 )
159154
160155 with open ("requirements.bzl" , "w" ) as f :
0 commit comments