Skip to content

ENH: add install-tags filtering for wheel generation #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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