@@ -122,7 +122,7 @@ def check(self, requirements, extra_pip_args):
122
122
existing_requirements = f .read ()
123
123
124
124
# Re-lock the requirements
125
- command = [self ._venv_bin ( "pip-compile" ), "--no-header" , "--annotation-style" , "line" , requirements , "-o" , "-" ]
125
+ command = [self ._find_pip_compile ( ), "--no-header" , "--annotation-style" , "line" , requirements , "-o" , "-" ]
126
126
if extra_pip_args :
127
127
command += ["--pip-args" , " " .join (extra_pip_args )]
128
128
@@ -156,7 +156,7 @@ def lock(self, package_name, input_requirements, no_overwrite, extra_pip_args):
156
156
logger .info ("Lock file already exists, not overwriting" )
157
157
return
158
158
159
- pip_compile = self ._venv_bin ( "pip-compile" )
159
+ pip_compile = self ._find_pip_compile ( )
160
160
command = [pip_compile , "--no-header" , "--annotation-style" , "line" , input_requirements ]
161
161
162
162
if os .path .normpath (input_requirements ) == os .path .normpath (output_requirements ):
@@ -194,6 +194,15 @@ def _venv_bin(self, binary_name):
194
194
return os .path .abspath (os .path .join (self .path , "local" , "bin" , binary_name ))
195
195
raise RuntimeError ("Binary {} not found in venv" .format (binary_name ))
196
196
197
+ def _find_pip_compile (self ):
198
+ try :
199
+ return self ._venv_bin ("pip-compile" )
200
+ except RuntimeError as exc :
201
+ global_pip_compile = shutil .which ("pip-compile" )
202
+ if global_pip_compile is None :
203
+ raise RuntimeError ("pip-compile not found found in Venv or global PATH" ) from exc
204
+ return global_pip_compile
205
+
197
206
def _check_module (self , python_executable , module ):
198
207
try :
199
208
with open (os .devnull , "w" ) as devnull :
0 commit comments