meson.build 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. project('random-build-examples', 'c', 'cpp', 'cython')
  2. py_mod = import('python')
  3. py3 = py_mod.find_installation(pure: false)
  4. cc = meson.get_compiler('c')
  5. cy = meson.get_compiler('cython')
  6. # Keep synced with pyproject.toml
  7. if not cy.version().version_compare('>=3.0.6')
  8. error('tests requires Cython >= 3.0.6')
  9. endif
  10. base_cython_args = []
  11. if cy.version().version_compare('>=3.1.0')
  12. base_cython_args += ['-Xfreethreading_compatible=True']
  13. endif
  14. _numpy_abs = run_command(py3, ['-c',
  15. 'import os; os.chdir(".."); import numpy; print(os.path.abspath(numpy.get_include() + "../../.."))'],
  16. check: true).stdout().strip()
  17. npymath_path = _numpy_abs / '_core' / 'lib'
  18. npy_include_path = _numpy_abs / '_core' / 'include'
  19. npyrandom_path = _numpy_abs / 'random' / 'lib'
  20. npymath_lib = cc.find_library('npymath', dirs: npymath_path)
  21. npyrandom_lib = cc.find_library('npyrandom', dirs: npyrandom_path)
  22. py3.extension_module(
  23. 'extending_distributions',
  24. 'extending_distributions.pyx',
  25. install: false,
  26. include_directories: [npy_include_path],
  27. dependencies: [npyrandom_lib, npymath_lib],
  28. cython_args: base_cython_args,
  29. )
  30. py3.extension_module(
  31. 'extending',
  32. 'extending.pyx',
  33. install: false,
  34. include_directories: [npy_include_path],
  35. dependencies: [npyrandom_lib, npymath_lib],
  36. cython_args: base_cython_args,
  37. )
  38. py3.extension_module(
  39. 'extending_cpp',
  40. 'extending_distributions.pyx',
  41. install: false,
  42. override_options : ['cython_language=cpp'],
  43. cython_args: base_cython_args + ['--module-name', 'extending_cpp'],
  44. include_directories: [npy_include_path],
  45. dependencies: [npyrandom_lib, npymath_lib],
  46. )