Combining build_ext with the Meson build system
Project description
Mebuex
A setuptools Extension
and build_ext
wrapper for builds based on Meson.
Usage
Mebuex assumes that the structure of a package is as follows:
root
| - builddir
| ... some source layout to be compiled with Meson ...
| - *packagename*
| | ... Python package layout handled by setup.py ...
| - setup.py
| - meson.build
That is, the root directory of the package contains the setup.py
file,
the meson.build
file, a Meson build directory (here builddir
, but can be
configured), directories covering the sources to be built by Meson, and the
Python package source tree.
The relevant part of this layout is that setup.py
and meson.build
are
contained in the root directory, and that a designated build directory is
specified (need not exist before building). The Meson build file should contain
all relevant configuration to build a Python extension within the build
directory (here builddir
). The setup.py
file should be based on setuptools
and contain all relevant configuration for the Python part of the package.
Within the setup.py
file, the Python extension built by Meson can then be
included using the MesonExtension
and build_ext
commands supplied by Mebuex.
An example code would look like this (suppose that the Meson build would yield
an extension mypackage.backend
):
from setuptools import setup
from mebuex import MesonExtension, build_ext
ext = MesonExtension('mypackage.backend', builddir='builddir')
setup(name='mypackage',
version='1.0.0',
author='Me',
description='Or is it yours?',
ext_modules=[ext],
cmdclass={'build_ext' : build_ext}
)
Finding the NumPy include directory
Mebuex ships with a Python script to discover the system NumPy includes when
building in the isolated build environment. The gravelspoon
command that
helps break out of the build prison can be used in a meson.build
file as
follows:
incpath_np = run_command(
gravelspoon
)
incdir_np = include_directories([incpath_np])
Install
Mebuex can be installed with Pip locally
pip install .
or from PyPI:
pip install mebuex
License
Mebuex is licensed under the MIT license (see the LICENSE file).
Changelog
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[1.3.0] - 2024-04-07
Added
- Add the
mebuex_destpath
andmebuex_destname
attributes to theMebuexExtension
class. This can be used from install scripts, after performing thebuild_ext
command, to retrieve the destination path where the extension file was copied to.
[1.2.0] - 2023-12-29
Added
- Add the
gravelspoon
command to break out of the setuptools build isolation and find the system NumPy includes.
[1.1.7] - 2023-08-20
Added
- Print error message stderr when re-raising assumed compilation error.
[1.1.6] - 2023-08-20
Added
- Print error message when re-raising assumed compilation error.
[1.1.5] - 2023-06-02
Changed
- Try wiping the build directory if compilation within a previously setup build directory fails.
[1.1.4] - 2023-05-04
Changed
- Be more verbose on
destpath
error inbuild_ext.build_extension
.
[1.1.3] - 2023-04-14
Added
- Add example project in
example/
subfolder.
[1.1.2] - 2023-04-13
Changed
- Change to
pyproject.toml
install workflow.
[1.1.1] - 2022-10-05
Changed
- Add a more informative error message if the directory to copy the built extension to does not exist.
[1.1.0] - 2022-07-13
Changed
- Fixed empty lib being copied to wheel directory instead of Meson-compiled lib.
- Fix handling of dots in compiled names (likely irrelevant).
[1.0.0] - 2022-07-13
Added
- First version
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mebuex-1.3.0.tar.gz
.
File metadata
- Download URL: mebuex-1.3.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 944081f58bb3c1516572f4f2f51b7377ee24ffe4a9d31f121f5b0165030a0111 |
|
MD5 | 75956bc2b1156646f08094a00c6154f5 |
|
BLAKE2b-256 | e7fd5e956fa38bdcfc163e080e49043984fa218b7844519178d7e526febd6b45 |
File details
Details for the file mebuex-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: mebuex-1.3.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47b160c34b17d094776f058c6464031b79e055f4ef3b503ad633e8b155c7fd41 |
|
MD5 | e9163c430fcef8b4614bd1481914c1bb |
|
BLAKE2b-256 | 13de2bd42cccfa06d3ddd8ec66fa470ec384912998c97f0ec06ff0d962159ea9 |