11import pathlib
2- import subprocess
3- import shlex
42import shutil
53import sys
64import tempfile
108import tomli
119
1210from .config import SubprojectConfig
11+ from .util import run_cmd , run_pip
1312
1413
1514class Subproject :
@@ -43,36 +42,14 @@ def is_meson_project(self) -> bool:
4342 # Tasks
4443 #
4544
46- def _cmd (self , * args : str , cwd = None ):
47- print ("+" , shlex .join (args ))
48- subprocess .check_call (args , cwd = cwd )
49-
50- def _run_pip (self , * args : str , cwd = None ):
51- self ._cmd (
52- sys .executable , "-m" , "pip" , "--disable-pip-version-check" , * args , cwd = cwd
53- )
54-
55- def install_build_deps (
56- self , * , wheel_path : pathlib .Path , other_wheel_path : pathlib .Path
57- ):
58- self ._run_pip (
59- "install" ,
60- "--no-index" ,
61- "--find-links" ,
62- str (wheel_path ),
63- "--find-links" ,
64- str (other_wheel_path ),
65- * [str (req ) for req in self .build_requires ],
66- )
67-
6845 def develop (self ):
69- self . _run_pip ("install" , "-v" , "-e" , "." , "--no-build-isolation" , cwd = self .path )
46+ run_pip ("install" , "-v" , "-e" , "." , "--no-build-isolation" , cwd = self .path )
7047
7148 def uninstall (self ):
72- self . _run_pip ("uninstall" , "-y" , self .pyproject_name )
49+ run_pip ("uninstall" , "-y" , self .pyproject_name )
7350
7451 def update_init (self ):
75- self . _cmd (
52+ run_cmd (
7653 sys .executable ,
7754 "-m" ,
7855 "semiwrap" ,
@@ -88,17 +65,13 @@ def test(self, *, install_requirements=False):
8865 if install_requirements :
8966 requirements = tests_path / "requirements.txt"
9067 if requirements .exists ():
91- self ._cmd (
92- sys .executable ,
93- "-m" ,
94- "pip" ,
95- "--disable-pip-version-check" ,
68+ run_pip (
9669 "install" ,
9770 "-r" ,
9871 str (requirements ),
9972 )
10073
101- self . _cmd (
74+ run_cmd (
10275 sys .executable ,
10376 "run_tests.py" ,
10477 cwd = tests_path ,
@@ -120,7 +93,7 @@ def build_wheel(
12093
12194 with tempfile .TemporaryDirectory () as td :
12295 # I wonder if we should use hatch build instead?
123- self . _cmd (
96+ run_cmd (
12497 sys .executable ,
12598 "-m" ,
12699 "build" ,
@@ -138,7 +111,7 @@ def build_wheel(
138111
139112 if install :
140113 # Install the wheel
141- self . _run_pip (
114+ run_pip (
142115 "install" ,
143116 "--find-links" ,
144117 str (wheel_path ),
0 commit comments