Skip to content

Commit

Permalink
Meson!
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Jun 13, 2024
1 parent dbbdd05 commit 48e09be
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 437 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ output/
# Transonic
__pythran__
__numba__
__python__

# PDM
.pdm-python
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ lock:

test:
pdm test

build_doc:
nox -s doc -R

test_in_nox_env:
nox -s test
67 changes: 67 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
project(
'pylandstats',
'cpp',
license: 'GPL-3.0-or-later',
meson_version: '>= 1.1.0',
default_options: [
'buildtype=release',
'cpp_std=c++11',
],
)

# https://mesonbuild.com/Python-module.html
py_mod = import('python')
py = py_mod.find_installation('python3', pure: false)
py_dep = py.dependency()

backend = get_option('transonic-backend')

if backend.contains(',')
backends = backend.split(',')
else
backends = [backend]
endif

use_pythran = backend.contains('pythran')
if use_pythran
incdir_numpy = run_command('transonic-get-include', 'numpy', check: true).stdout().strip()
inc_np = include_directories(incdir_numpy)
np_dep = declare_dependency(include_directories: inc_np)

incdir_pythran = run_command('transonic-get-include', 'pythran', check: true).stdout().strip()
pythran = find_program('pythran', native: true)

cpp_args_pythran = [
'-DENABLE_PYTHON_MODULE',
'-D__PYTHRAN__=3',
'-DPYTHRAN_BLAS_NONE'
]

if get_option('use-xsimd') == true
# xsimd is unvendored from pythran by conda-forge, and due to a compiler
# activation bug the default <prefix>/include/ may not be visible (see
# gh-15698). Hence look for xsimd explicitly.
xsimd_dep = dependency('xsimd', required: false)
pythran_dep = declare_dependency(
include_directories: incdir_pythran,
dependencies: xsimd_dep,
)
cpp_args_pythran += ['-DUSE_XSIMD']
else
pythran_dep = declare_dependency(
include_directories: incdir_pythran,
)
endif

pythran_complex_hook = get_option('pythran-complex-hook')
if pythran_complex_hook == 'os-dependent'
pythran_complex_hook = host_machine.system() == 'linux'
endif

if get_option('native')
cpp_args_pythran += ['-march=native', '-Ofast']
endif

endif

subdir('pylandstats')
27 changes: 27 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
option(
'transonic-backend',
type: 'string',
value: 'pythran,python,numba',
description:
'pythran,python,numba (default), cython, numpy, numba; ' +
'or comma separated value representing multi-backends',
)
option(
'native',
type: 'boolean',
value: false,
description: 'Performance oriented and not portable build',
)
option(
'use-xsimd',
type: 'boolean',
value: true,
description: 'Turns on xsimd vectorization',
)
option(
'pythran-complex-hook',
type: 'combo',
choices: ['os-dependent', 'true', 'false'],
value: 'os-dependent',
description: 'Pythran complex_hook option',
)
17 changes: 14 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Task runner for the developer
"""Task runner for the developer.
# Usage
Expand All @@ -20,23 +20,34 @@

@nox.session
def doc(session):
command = "pdm sync --clean -G doc"
"""Build the documentation in a Nox environment."""
command = "pdm sync --clean -G doc --no-self"
session.run_install(*command.split(), external=True)

# for documentation, we don't need the other backends
command = "pip install . -C setup-args=-Dtransonic-backend=python"
session.run_install(*command.split(), external=True)

session.run("sphinx-build", "docs", "docs/_build")
print(f"file://{os.getcwd()}/docs/_build/index.html")


@nox.session
def wheel(session):
"""Build the wheel."""
session.install("build", "twine")
session.run("python", "-m", "build")
session.run("twine", "check", "dist/*")


@nox.session
def test(session):
command = "pdm sync --clean -G test"
"""Run the test in a Nox environment."""
command = "pdm sync --clean --prod -G test --no-self"
session.run_install(*command.split(), external=True)

session.install(".", "--no-deps", external=True)

session.run(
"pytest",
"-v",
Expand Down
Loading

0 comments on commit 48e09be

Please sign in to comment.