Skip to content
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

mesonbuild::wrap::wrap.py::199 -- subproject command fails when using wrap & custom subprojects_dir setting due to hardcoded dir name #14049

Open
abdallahsoliman opened this issue Dec 27, 2024 · 0 comments

Comments

@abdallahsoliman
Copy link

Describe the bug

When using wrap file for a nested subproject, and a non-default setting for subprojects_dir (subprojects_dir != 'subprojects'), unexpected failure occurs when calling subproject related command (e.g: meson subprojects purge). The error is as follows:

❯ meson subprojects purge --confirm

ERROR: wrap-redirect filename must be in the form foo/subprojects/bar.wrap

This is due to mesonbuild/wrap/wrap.py::199, which contains a hard-coded check for the subproject directory name:

if p != 'subprojects':
    raise WrapException('wrap-redirect filename must be in the form foo/subprojects/bar.wrap')

To Reproduce

The following project structure & content files is sufficient to reproduce the error:
foo.zip

Project Structure:

foo
├── meson.build
└── module
    └── bar
        ├── meson.build
        └── module
            ├── argparse.wrap
            └── packagefiles
                └── argparse
                    └── meson.build

6 directories, 4 files

File Contents:

# ./meson.build
project(
    'foo',
    ['c', 'cpp'],
    subproject_dir: 'module',
    meson_version: '>=1.6'
)

subproject('bar')
# ./module/bar/meson.build
project(
    'bar',
    ['c', 'cpp'],
    subproject_dir: 'module',
    meson_version: '>=1.6'
)

argparse_dep = subproject('argparse')
# ./module/bar/module/packagefiles/argparse/meson.build
project(
    'argparse',
    ['c', 'cpp'],
    subproject_dir: 'module',
    meson_version: '>=1.6'
)

argparse_dep = include_directories('include')
# ./module/bar/module/argparse.wrap
[wrap-git]
url=https://github.com/p-ranav/argparse.git
revision=v3.1
depth=1
patch_directory = argparse

[provide]
dependency_names = argparse

Commands:

meson setup build
meson subprojects purge --confirm

Workaround:

Applying the following patch to mesonbuild/wrap/wrap.py will allow the command to work as expected. However, please keep in mind that thorough testing was not performed to confirm there are no side-effects. This patch was intended to mitigate the immediate issue.

# mesonbuild_wrap.py.patch
199,200c199,201
<                     if p != 'subprojects':
<                         raise WrapException('wrap-redirect filename must be in the form foo/subprojects/bar.wrap')
---
>                     subprojects_dir_name = os.path.basename(subprojects_dir)
>                     if p != subprojects_dir_name:
>                         raise WrapException(f'wrap-redirect filename must be in the form foo/{subprojects_dir_name}/bar.wrap')
patch $(dirname $(python -c "import mesonbuild; print(mesonbuild.__file__)"))/wrap/wrap.py mesonbuild_wrap.py.patch
meson subprojects purge --confirm

After applying the patch, the command works as expected.

Expected behavior

The following error should only occur if the subprojects_dir name does not match what it was configured to. If subprojects_dir is not the default value 'subprojects' it does not seem appropriate to check the subprojects directory name against the default value.

❯ meson subprojects purge --confirm

ERROR: wrap-redirect filename must be in the form foo/subprojects/bar.wrap

system parameters

  • Native Build
  • Ubuntu 24.04
  • Python 3.12 (virtualenv)
  • Meson 1.6.1
  • Ninja 1.11.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant