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

import('pkgconfig').generate() generates wrong Meson introspection data #609

Open
FFY00 opened this issue Mar 28, 2024 · 9 comments
Open
Labels
dependency-bug A bug experienced by users of meson-python caused by a dependency, rather than in code in this repo

Comments

@FFY00
Copy link
Member

FFY00 commented Mar 28, 2024

Reproducible: #608

$ PYTHONPATH=../../.. python -m build -nw* Getting build dependencies for wheel...
* Getting build dependencies for wheel...
* Building wheel...
+ meson setup /home/anubis/git/mesonpy/tests/packages/python-data /home/anubis/git/mesonpy/tests/packages/python-data/.mesonpy-nc4ceydg -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/home/anubis/git/mesonpy/tests/packages/python-data/.mesonpy-nc4ceydg/meson-python-native-file.ini
The Meson build system
Version: 1.4.0
Source dir: /home/anubis/git/mesonpy/tests/packages/python-data
Build dir: /home/anubis/git/mesonpy/tests/packages/python-data/.mesonpy-nc4ceydg
Build type: native build
Project name: python-data
Project version: 1.0.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python found: YES (/usr/bin/python)
Build targets in project: 0

python-data 1.0.0

  User defined options
    Native files: /home/anubis/git/mesonpy/tests/packages/python-data/.mesonpy-nc4ceydg/meson-python-native-file.ini
    buildtype   : release
    b_ndebug    : if-release
    b_vscrt     : md

Found ninja-1.11.1 at /usr/bin/ninja
+ /usr/bin/ninja
ninja: no work to do.

meson-python: error: Could not map installation path to an equivalent wheel directory: '/usr/lib/python3.11/site-packages/python_data/data.txt'

ERROR Backend subprocess exited when trying to invoke build_wheel

install_data here is just an example, I know I can use py.install_sources, but that is not viable in various different scenarios. In my case, I ran into it when using import('pkgconfig').generate(..., install_dir: py.get_path('purelib') / ...).

@FFY00 FFY00 added the bug Something isn't working label Mar 28, 2024
@dnicolodi
Copy link
Member

You need to use py.get_install_dir(pure: true) not py.get_path('purelib').

@FFY00 FFY00 closed this as completed Mar 28, 2024
@FFY00 FFY00 removed the bug Something isn't working label Mar 28, 2024
@FFY00
Copy link
Member Author

FFY00 commented May 29, 2024

I am running into this issue again.

project('example', 'c', version: '1.0.0')

lib = library('example', 'lib.c', install: true)

py = import('python').find_installation()
py.install_sources('example/__init__.py', subdir: 'example')
py.install_sources('example/pkgconf/__init__.py', subdir: 'example/pkgconf')

pkg = import('pkgconfig')
pkg.generate(lib, install_dir: py.get_install_dir(pure: true) / 'example' / 'pkgconf')

It seems some targets, like configure_file work, but import('pkgconfig').generate(...) doesn't seem to.

@FFY00 FFY00 reopened this May 29, 2024
@FFY00 FFY00 added the bug Something isn't working label May 29, 2024
@rgommers
Copy link
Contributor

I think it's worth going through all the more advanced/niche Meson target types and checking how they land in intro-install_plan.json. I think it is going to happen again in the future that something either isn't mapped at all, or isn't mapped correctly. Right now I know of:

  • import('pkgconfig').generate(...) (this example) ending up with an absolute path
  • install_symlink isn't mapped at all

I bet if we look at other things that aren't normally included in wheels (e.g., jar) they won't be handled correctly by default. In most cases explicitly setting install_path should provide a reasonable workaround.

@rgommers
Copy link
Contributor

So: not really a bug, more a missing feature.

@dnicolodi
Copy link
Member

  • install_symlink isn't mapped at all

Wheels cannot contain symlinks AFAIK.

@dnicolodi
Copy link
Member

  • import('pkgconfig').generate(...) (this example) ending up with an absolute path

This would be a bug in Meson.

@rgommers
Copy link
Contributor

Wheels cannot contain symlinks AFAIK.

Yet:) Being heavily discussed right now. Either way, silently omitting them is probably not the ideal way of handling this now. Also intro-install_plan.json probably shouldn't be considered something that is exclusively for meson-python, so I expect it to be complete regarding all install targets.

@dnicolodi
Copy link
Member

intro-install_plan.json cannot be complete by design: Meson allows to install the same file in multiple locations but the intro-install_plan.json is a mapping from source location to installation location, thus it cannot describe a source file being installed in multiple places. See mesonbuild/meson#11539 and mesonbuild/meson#12001

@rgommers
Copy link
Contributor

Sure, but that doesn't quite apply to this situation. It could be as complete as possible as the metadata encoding scheme allows for.

I'd suggest to consider these Meson bugs, and once they're included in intro-install_plan.json then we have to figure out how to do something reasonable with them in mesonpython. For .pc files there's also gh-240, so those we do have to figure something out for.

@dnicolodi dnicolodi added dependency-bug A bug experienced by users of meson-python caused by a dependency, rather than in code in this repo and removed bug Something isn't working labels Aug 17, 2024
@dnicolodi dnicolodi changed the title Cannot install data to a Python directory without using py.install_sources import('pkgconfig').generate() is not compatible with installing the result into a Python package Oct 23, 2024
@dnicolodi dnicolodi changed the title import('pkgconfig').generate() is not compatible with installing the result into a Python package import('pkgconfig').generate() generates wrong Meson introspection data Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency-bug A bug experienced by users of meson-python caused by a dependency, rather than in code in this repo
Projects
None yet
Development

No branches or pull requests

3 participants