-
Notifications
You must be signed in to change notification settings - Fork 85
ENH: allow to specify editable-verbose in pyproject.toml #838
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
Open
dnicolodi
wants to merge
1
commit into
mesonbuild:main
Choose a base branch
from
dnicolodi:editable-verbose-pyproject
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -603,6 +603,7 @@ def _string_or_path(value: Any, name: str) -> str: | |
| 'exclude': _strings, | ||
| 'include': _strings, | ||
| }), | ||
| 'editable-verbose': _bool, | ||
| }) | ||
|
|
||
| table = pyproject.get('tool', {}).get('meson-python', {}) | ||
|
|
@@ -617,16 +618,24 @@ def _string(value: Any, name: str) -> str: | |
| raise ConfigError(f'Only one value for "{name}" can be specified') | ||
| return value | ||
|
|
||
| def _bool(value: Any, name: str) -> bool: | ||
| return True | ||
| def _empty_or_bool(value: Any, name: str) -> bool: | ||
| if isinstance(value, bool): | ||
| return value | ||
| if isinstance(value, str): | ||
| if value == 'false' or value == '0': | ||
| return False | ||
| # For bakward compatibility, treat a missing value as True. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: bakward -> backward |
||
| if value == '' or value == 'true' or value == '1': | ||
| return True | ||
| raise ConfigError(f'Invalid value for "{name}": {value!r}') | ||
|
|
||
| def _string_or_strings(value: Any, name: str) -> List[str]: | ||
| return list([value,] if isinstance(value, str) else value) | ||
|
|
||
| options = { | ||
| 'builddir': _string, | ||
| 'build-dir': _string, | ||
| 'editable-verbose': _bool, | ||
| 'editable-verbose': _empty_or_bool, | ||
| 'dist-args': _string_or_strings, | ||
| 'setup-args': _string_or_strings, | ||
| 'compile-args': _string_or_strings, | ||
|
|
@@ -667,11 +676,10 @@ def __init__( | |
| source_dir: Path, | ||
| build_dir: Path, | ||
| meson_args: Optional[MesonArgs] = None, | ||
| editable_verbose: bool = False, | ||
| editable_verbose: Optional[bool] = None, | ||
| ) -> None: | ||
| self._source_dir = pathlib.Path(source_dir).absolute() | ||
| self._build_dir = pathlib.Path(build_dir).absolute() | ||
| self._editable_verbose = editable_verbose | ||
| self._meson_native_file = self._build_dir / 'meson-python-native-file.ini' | ||
| self._meson_cross_file = self._build_dir / 'meson-python-cross-file.ini' | ||
| self._meson_args: MesonArgs = collections.defaultdict(list) | ||
|
|
@@ -685,6 +693,12 @@ def __init__( | |
| for key, value in pyproject_config.get('args', {}).items(): | ||
| self._meson_args[key].extend(value) | ||
|
|
||
| # editable-verbose setting from build options takes precedence over | ||
| # setting in pyproject.toml | ||
| if editable_verbose is None: | ||
| editable_verbose = bool(pyproject_config.get('editable-verbose')) | ||
| self._editable_verbose = editable_verbose | ||
|
|
||
| # meson arguments from the command line take precedence over | ||
| # arguments from the configuration file thus are added later | ||
| if meson_args: | ||
|
|
@@ -1114,7 +1128,7 @@ def _project(config_settings: Optional[Dict[Any, Any]] = None) -> Iterator[Proje | |
| meson_args = typing.cast('MesonArgs', {name: settings.get(f'{name}-args', []) for name in _MESON_ARGS_KEYS}) | ||
| source_dir = os.path.curdir | ||
| build_dir = settings.get('build-dir') | ||
| editable_verbose = bool(settings.get('editable-verbose')) | ||
| editable_verbose = settings.get('editable-verbose') | ||
|
|
||
| with contextlib.ExitStack() as ctx: | ||
| if build_dir is None: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is slightly awkward. Not a big deal, I'm fine if you prefer this one - but perhaps consider
_optional_bool?