Looking for recommended structure for separate C++ library and extension builds #661
-
Hi, I love meson, and I'm excited to start using it with Python! I am trying to adopt Today, I have:
I'd like to preserve the ability to build a C++ library with Meson independent of a Python installation, but it'd also be awesome to be able to trigger a C++ build during Python installation to avoid tracking a separate system dependency. I did this previously in It'd be even cooler to move the In short; any suggestions on how to make this work in mesonpy? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
First, please note that the current organization of your repository is not compatible with distributing it as a source distribution using
There isn't only one way in which you can achieve this. Which one is more suited to your project depends on the level of integration you want for the C++ and Python parts of the project. If the C++ library is thought to also be used independently of the Python wrappers, what makes the most sense is probably to have the C++ library be an independent project from the Python wrappers. You can then use the C++ project as a subproject of the Python wrappers project. In this case I would move the If you want to keep the sources of the C++ and Python parts tightly coupled, you can keep the current project organization, but you need to have a With a option('python', type: 'feature', value: 'auto') or option('python', type: 'feature', value: 'disabled') if you don't want to build the Python wrappers by default, a top level project(...)
subdir('cpp')
python = import('python').find_installation(required: get_option('python'))
if python.found()
subdir('python')
endif Then you can add [tool.meson-python.args]
setup = ['-Dpython=enabled'] to |
Beta Was this translation helpful? Give feedback.
-
Thank you @dnicolodi for the direct, detailed, and quick answer. This is extremely helpful context. I'll work on following your proposed "tightly coupled" option. I realize it may be obvious to many, but would you be open to a small PR adding information about the intentions of root-level |
Beta Was this translation helpful? Give feedback.
First, please note that the current organization of your repository is not compatible with distributing it as a source distribution using
meson dist
nor as a Python package source distribution created by meson-python. The first requires the root folder of the project to contain ameson.build
file describing the project. The latter also requires thepyproject.toml
file to be in the root folder of the project.There isn't only one way in which you can ach…