Skip to content

Commit a4e25b7

Browse files
committed
ENH: add .gitignore and .hgignore to build directory if empty
Fixes #650.
1 parent ca26c76 commit a4e25b7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mesonpy/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,10 @@ def __init__(
670670
# make sure the build dir exists
671671
self._build_dir.mkdir(exist_ok=True, parents=True)
672672

673+
# if the build dir is empty, add .gitignore and .hgignore files
674+
if not any(self._build_dir.iterdir()):
675+
_add_ignore_files(self._build_dir)
676+
673677
# setuptools-like ARCHFLAGS environment variable support
674678
if sysconfig.get_platform().startswith('macosx-'):
675679
archflags = os.environ.get('ARCHFLAGS', '').strip()
@@ -1112,11 +1116,7 @@ def build_editable(
11121116
if not config_settings:
11131117
config_settings = {}
11141118
if 'build-dir' not in config_settings and 'builddir' not in config_settings:
1115-
build_dir = pathlib.Path('build')
1116-
build_dir.mkdir(exist_ok=True)
1117-
if not next(build_dir.iterdir(), None):
1118-
_add_ignore_files(build_dir)
1119-
config_settings['build-dir'] = os.fspath(build_dir / str(mesonpy._tags.get_abi_tag()))
1119+
config_settings['build-dir'] = 'build/' + mesonpy._tags.get_abi_tag()
11201120

11211121
out = pathlib.Path(wheel_directory)
11221122
with _project(config_settings) as project:

0 commit comments

Comments
 (0)