Skip to content

Commit bc5c095

Browse files
Test meson integration
Fix #2236
1 parent 3a712c9 commit bc5c095

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

.github/workflows/core.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
pip install scipy-openblas64
2727
pip install pytest-xdist
2828
sudo apt install ${{ matrix.cpp-version }}
29+
sudo apt install libopenblas-dev # for meson integration testing
2930
if test ${{ matrix.python-version }} != 'pypy-3.9'; then pip install scipy ; fi
3031
- name: Setup
3132
run: |

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Changelog = "https://pythran.readthedocs.io/en/latest/Changelog.html"
2727

2828
[project.optional-dependencies]
2929
doc = ["numpy", "nbsphinx", "scipy", "guzzle_sphinx_theme"]
30-
test = ["ipython", "nbval", "cython", "wheel", "packaging"]
30+
test = ["ipython", "nbval", "cython", "wheel", "packaging", "ninja", "meson"]
3131

3232
[project.scripts]
3333
pythran = "pythran.run:run"

pythran/tests/test_distutils.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,31 @@ def test_setup_bdist_install3(self):
170170
demo_so = find_so(r"a.*\.so", dist_path)
171171
self.assertIsNotNone(demo_so)
172172
shutil.rmtree(dist_path)
173+
174+
try:
175+
check_call(['ninja', '--version'])
176+
has_ninja = True
177+
except:
178+
has_ninja = False
179+
180+
try:
181+
check_call(['meson', '--version'])
182+
has_meson = True
183+
except:
184+
has_meson = False
185+
186+
class TestMeson(unittest.TestCase):
187+
188+
@unittest.skipIf(not has_meson, "meson not found")
189+
@unittest.skipIf(not has_ninja, "ninja not found")
190+
def test_meson_build(self):
191+
srcdir = os.path.join(cwd, 'test_distutils')
192+
builddir = os.path.join(srcdir, '_meson_build')
193+
shutil.rmtree(builddir, ignore_errors=True)
194+
check_call(['meson', 'setup', builddir, '.'],
195+
cwd=srcdir)
196+
check_call(['ninja', '-v'],
197+
cwd=builddir)
198+
check_call([python, '-c', 'import b'],
199+
cwd=builddir)
200+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
project('pythran-test', 'cpp')
2+
3+
pymod = import('python')
4+
py = pymod.find_installation(modules:['pythran'])
5+
6+
pythran_cmd = [py.path(), '-m', 'pythran.run', '-E', '@INPUT@', '-o', '@OUTPUT@']
7+
8+
pythranrc = join_paths(meson.project_source_root(), 'pythran.rc')
9+
10+
pythran_env = environment()
11+
pythran_env.set('PYTHRANRC', pythranrc)
12+
13+
b_cpp = custom_target(
14+
'b_cpp',
15+
output : 'b.cpp',
16+
input: 'b.py',
17+
command: pythran_cmd,
18+
env: pythran_env,
19+
depend_files: [pythranrc],
20+
)
21+
22+
pythran_cppflags = run_command(py.path(), '-m', 'pythran.config', '--cflags', check:true, env:pythran_env).stdout().strip().split()
23+
pythran_ldflags = run_command(py.path(), '-m', 'pythran.config', '--libs', check:true, env:pythran_env).stdout().strip().split()
24+
25+
py.extension_module(
26+
'b',
27+
b_cpp,
28+
cpp_args: pythran_cppflags,
29+
link_args: pythran_ldflags,
30+
install: true,
31+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[compiler]
2+
blas=openblas
3+
include_dirs=/usr/include/openblas

0 commit comments

Comments
 (0)