Skip to content

Commit

Permalink
ENH: add install-tags filtering for wheel generation
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Urban <peter.urban@ugent.be>
Signed-off-by: Filipe Laíns <lains@riseup.net>
  • Loading branch information
FFY00 and peter-urban committed Feb 1, 2023
1 parent 207d812 commit a2e3fa3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
21 changes: 20 additions & 1 deletion mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from __future__ import annotations

import argparse
import collections
import contextlib
import functools
Expand Down Expand Up @@ -921,7 +922,25 @@ def _info(self, name: str) -> Dict[str, Any]:
@property
def _install_plan(self) -> Dict[str, Dict[str, Dict[str, str]]]:
"""Meson install_plan metadata."""
return self._info('intro-install_plan').copy()

# copy the install plan so we can modify it
install_plan = self._info('intro-install_plan').copy()

# parse install args for install tags (--tags)
parser = argparse.ArgumentParser()
parser.add_argument('--tags')
args, _ = parser.parse_known_args(self._meson_args['install'])

# filter the install_plan for files that do not fit the install tags
if args.tags:
install_tags = args.tags.split(',')

for files in install_plan.values():
for file, details in list(files.items()):
if details['tag'].strip() not in install_tags:
del files[file]

return install_plan

@property
def _copy_files(self) -> Dict[str, str]:
Expand Down
11 changes: 11 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,14 @@ def last_two_meson_args():
def test_unknown_user_args(package, tmp_path_session):
with pytest.raises(mesonpy.ConfigError):
mesonpy.Project(package_dir / f'unknown-user-args-{package}', tmp_path_session)


def test_install_tags(package_purelib_and_platlib, tmp_path_session):
project = mesonpy.Project(
package_purelib_and_platlib,
tmp_path_session,
meson_args={
'install': ['--tags', 'purelib'],
}
)
assert project.is_pure

0 comments on commit a2e3fa3

Please sign in to comment.