Skip to content

Commit 0d3580d

Browse files
committed
MAINT: remove one level of indirection in executing meson
1 parent 0e7ad91 commit 0d3580d

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

mesonpy/__init__.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -775,17 +775,13 @@ def _get_config_key(self, key: str) -> Any:
775775
value = value.get(part, {})
776776
return value
777777

778-
def _proc(self, *args: str) -> None:
778+
def _run(self, cmd: Sequence[str]) -> None:
779779
"""Invoke a subprocess."""
780-
print('{cyan}{bold}+ {}{reset}'.format(' '.join(args), **_STYLES))
781-
r = subprocess.run(list(args), env=self._env, cwd=self._build_dir)
780+
print('{cyan}{bold}+ {}{reset}'.format(' '.join(cmd), **_STYLES))
781+
r = subprocess.run(cmd, env=self._env, cwd=self._build_dir)
782782
if r.returncode != 0:
783783
raise SystemExit(r.returncode)
784784

785-
def _meson(self, *args: str) -> None:
786-
"""Invoke Meson."""
787-
return self._proc('meson', *args)
788-
789785
def _configure(self, reconfigure: bool = False) -> None:
790786
"""Configure Meson project."""
791787
sys_paths = mesonpy._introspection.SYSCONFIG_PATHS
@@ -812,7 +808,7 @@ def _configure(self, reconfigure: bool = False) -> None:
812808
if reconfigure:
813809
setup_args.insert(0, '--reconfigure')
814810

815-
self._meson('setup', *setup_args)
811+
self._run(['meson', 'setup', *setup_args])
816812

817813
def _validate_metadata(self) -> None:
818814
"""Check the pyproject.toml metadata and see if there are any issues."""
@@ -877,7 +873,7 @@ def build_commands(self, install_dir: Optional[pathlib.Path] = None) -> Sequence
877873
def build(self) -> None:
878874
"""Trigger the Meson build."""
879875
for cmd in self.build_commands():
880-
self._meson(*cmd[1:])
876+
self._run(cmd)
881877

882878
@classmethod
883879
@contextlib.contextmanager
@@ -1012,7 +1008,7 @@ def pep621(self) -> bool:
10121008
def sdist(self, directory: Path) -> pathlib.Path:
10131009
"""Generates a sdist (source distribution) in the specified directory."""
10141010
# generate meson dist file
1015-
self._meson('dist', '--allow-dirty', '--no-tests', '--formats', 'gztar', *self._meson_args['dist'],)
1011+
self._run(['meson', 'dist', '--allow-dirty', '--no-tests', '--formats', 'gztar', *self._meson_args['dist']])
10161012

10171013
# move meson dist file to output path
10181014
dist_name = f'{self.name}-{self.version}'

0 commit comments

Comments
 (0)