Skip to content

Commit 533cc7d

Browse files
committed
BUG: create the build directory before trying to write files in it
Do not try to write the cross file in the build directory before ensuring that the build directory exists. Add a test to make sure this does not break again. Fixes #406.
1 parent 55afbc0 commit 533cc7d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mesonpy/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ def __init__(
656656
raise ConfigError(f'Could not find ninja version {_NINJA_REQUIRED_VERSION} or newer.')
657657
self._env.setdefault('NINJA', self._ninja)
658658

659+
# make sure the build dir exists
660+
self._build_dir.mkdir(exist_ok=True, parents=True)
661+
self._install_dir.mkdir(exist_ok=True, parents=True)
662+
659663
# setuptools-like ARCHFLAGS environment variable support
660664
if sysconfig.get_platform().startswith('macosx-'):
661665
archflags = self._env.get('ARCHFLAGS', '').strip()
@@ -696,10 +700,6 @@ def __init__(
696700
for key, value in meson_args.items():
697701
self._meson_args[key].extend(value)
698702

699-
# make sure the build dir exists
700-
self._build_dir.mkdir(exist_ok=True, parents=True)
701-
self._install_dir.mkdir(exist_ok=True, parents=True)
702-
703703
# write the native file
704704
native_file_data = textwrap.dedent(f'''
705705
[binaries]

0 commit comments

Comments
 (0)