Replies: 10 comments
-
From what I know the Meson approach is to integrate some custom scripts in to your I've done this with Vala, but hopefully you'll be able to apply the pattern for Python. So Vala has the
This creates a As far as installing goes take a look at Installing and the |
Beta Was this translation helpful? Give feedback.
-
I think the python module has the helpers you want: https://mesonbuild.com/Python-module.html#extension_module |
Beta Was this translation helpful? Give feedback.
-
You might want to take a look at how Meson's module building unit test does it. For distutils I don't have an answer. However I do know that there is a way to tell distutils to invoke external build systems. This is how e.g. projects using SCons get turned into Python packages. I have never done it myself, though. |
Beta Was this translation helpful? Give feedback.
-
Hi folks, thanks for your suggestions! I haven't cracked the The main problem here is twofold:
Once I have found out how to implement a Thanks again for your suggestions and your work on meson! It's a great build system, quite simple, has a nice syntax and it doesn't tempt you to do crazy specialized stuff. |
Beta Was this translation helpful? Give feedback.
-
Hello, is there an example how to build a c python extension by meson from setup.py? (And I do not know how to use meson in pip packages.) |
Beta Was this translation helpful? Give feedback.
-
@Nic30 I don't know if there is an example, but it shouldn't be too hard to build a Python extension from setup.py. Provided that you can call meson via |
Beta Was this translation helpful? Give feedback.
-
@D4N I am not afraid of build I am afraid of correct installation on all platforms. |
Beta Was this translation helpful? Give feedback.
-
@Nic30 You could take a look at the python test cases that Meson uses: https://github.com/mesonbuild/meson/tree/master/test%20cases/python3, maybe one of them roughly fits your use case? If yes, you could probably just call |
Beta Was this translation helpful? Give feedback.
-
Distributing the built extension via distutils is best solved by not using distutils at all, but using https://pypi.org/project/mesonpep517/ instead. For generating sphinx documentation, run_target or custom_target have since been updated to accept an env kwarg which sets the PYTHONPATH. Sphinx refusing to run in a directory that doesn't have the conf file, might be solvable by using configure_file(..., copy: true) to copy over the conf file into the build dir? Is this all sufficient for your needs? |
Beta Was this translation helpful? Give feedback.
-
@eli-schwartz Thank you. |
Beta Was this translation helpful? Give feedback.
-
I have a mixed C++ & Python project, where a part of the C++ API is exposed via boost.python (this part works like a charm, thank you meson-devs!). I have however now the problem, that my C++ extension ends up somewhere in
build/src/extname.cpython-36m-x86_64-linux-gnu.so
. The python code on the other hand stays in the source directory (under lets saypy/
).Is there a canonical way, how to allow the C++ extension
extname.*.so
to be installable via distutils? I know that I can provide aMANIFEST.in
file tosetup.py
to find the extension, but I can't put that back into the source directory with meson (as that violates the out of source build idea) forsetup.py
to find it.Bonus question: I have written the documentation with sphinx, which also documents the python code and requires that I can import it (also the C++ extension). Imho the easiest would be to run
setup.py install --user
before building the documentation (but that feels wrong as the install step is run before the build doc step plus it pollutes the user's directory just for building the documentation). Is there a better way? Maybe copy the whole python module intobuild/
and exportPYTHONPATH
(although that is only possible via hacks forrun_target
), if that is somehow possible?Beta Was this translation helpful? Give feedback.
All reactions