File tree Expand file tree Collapse file tree 2 files changed +55
-8
lines changed
Expand file tree Collapse file tree 2 files changed +55
-8
lines changed Original file line number Diff line number Diff line change @@ -334,14 +334,24 @@ def _pip_build(cls, base_path):
334334
335335 LOG .warning ("Starting pip build." )
336336 try :
337- completed_proc = subprocess_run ( # nosec
338- command ,
339- stdout = PIPE ,
340- stderr = PIPE ,
341- cwd = base_path ,
342- check = True ,
343- shell = True ,
344- )
337+ # On windows run pip command through the default shell (CMD)
338+ if os .name == "nt" :
339+ completed_proc = subprocess_run ( # nosec
340+ command ,
341+ stdout = PIPE ,
342+ stderr = PIPE ,
343+ cwd = base_path ,
344+ check = True ,
345+ shell = True ,
346+ )
347+ else :
348+ completed_proc = subprocess_run ( # nosec
349+ command ,
350+ stdout = PIPE ,
351+ stderr = PIPE ,
352+ cwd = base_path ,
353+ check = True ,
354+ )
345355 LOG .warning ("pip build finished." )
346356 except (FileNotFoundError , CalledProcessError ) as e :
347357 raise DownstreamError ("pip build failed" ) from e
Original file line number Diff line number Diff line change @@ -416,6 +416,43 @@ def test__build_pip(plugin):
416416 mock_pip .assert_called_once_with (sentinel .base_path )
417417
418418
419+ def test__build_pip_posix (plugin ):
420+ patch_os_name = patch ("rpdk.python.codegen.os.name" , "posix" )
421+ patch_subproc = patch ("rpdk.python.codegen.subprocess_run" )
422+
423+ # Path must be set outside simulated os.name
424+ temppath = Path (str (sentinel .base_path ))
425+ with patch_os_name , patch_subproc as mock_subproc :
426+ plugin ._pip_build (temppath )
427+
428+ mock_subproc .assert_called_once_with (
429+ plugin ._make_pip_command (temppath ),
430+ stdout = ANY ,
431+ stderr = ANY ,
432+ cwd = temppath ,
433+ check = ANY ,
434+ )
435+
436+
437+ def test__build_pip_windows (plugin ):
438+ patch_os_name = patch ("rpdk.python.codegen.os.name" , "nt" )
439+ patch_subproc = patch ("rpdk.python.codegen.subprocess_run" )
440+
441+ # Path must be set outside simulated os.name
442+ temppath = Path (str (sentinel .base_path ))
443+ with patch_os_name , patch_subproc as mock_subproc :
444+ plugin ._pip_build (temppath )
445+
446+ mock_subproc .assert_called_once_with (
447+ plugin ._make_pip_command (temppath ),
448+ stdout = ANY ,
449+ stderr = ANY ,
450+ cwd = temppath ,
451+ check = ANY ,
452+ shell = True ,
453+ )
454+
455+
419456def test__build_docker (plugin ):
420457 plugin ._use_docker = True
421458
You can’t perform that action at this time.
0 commit comments