diff --git a/babelizer/data/{{cookiecutter.package_name}}/meson.build b/babelizer/data/{{cookiecutter.package_name}}/meson.build index 5126f54..6edc29d 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/meson.build +++ b/babelizer/data/{{cookiecutter.package_name}}/meson.build @@ -11,21 +11,16 @@ project( version: '{{ cookiecutter.package_version }}', ) +py = import('python').find_installation(pure: false) + {%- if cookiecutter.language == 'c' %} -lang = 'c' -bmilib = 'bmiheatc' +compiler = meson.get_compiler('c') {%- elif cookiecutter.language == 'c++' %} -lang = 'cpp' -bmilib = 'bmiheatcxx' +compiler = meson.get_compiler('cpp') {%- elif cookiecutter.language == 'fortran' %} -lang = 'fortran' -bmilib = 'bmiheatf' +compiler = meson.get_compiler('fortran') {%- endif %} -py = import('python').find_installation(pure: false) - -compiler = meson.get_compiler(lang) - # python_inc = py.get_path('data') / 'include' numpy_inc = run_command( py, @@ -43,26 +38,13 @@ incs = include_directories( ] ) -{% set babelized_class = cookiecutter.components|list|first -%} -# babelized_class = {{ babelized_class }} - {% set dependency_list = cookiecutter.package_requirements.split(',') -%} deps = [ -{%- if cookiecutter.language in ['c', 'c++', 'fortran'] %} - dependency(bmilib, method : 'pkg-config'), -{% endif %} {%- for dependency in dependency_list if dependency != '' %} compiler.find_library('{{ dependency }}'), {%- endfor %} ] -srcs = [ -{%- if cookiecutter.language == 'fortran' %} - '{{ cookiecutter.package_name }}/lib/bmi_interoperability.f90', -{%- endif %} - '{{ cookiecutter.package_name }}/lib/{{ babelized_class|lower }}.pyx', -] - # Files get copied to /site-packages/ install_pkg_srcs = [ '{{ cookiecutter.package_name }}/__init__.py', @@ -73,24 +55,31 @@ py.install_sources( install_pkg_srcs, subdir: '{{ cookiecutter.package_name }}', ) + install_lib_srcs = [ '{{ cookiecutter.package_name }}/lib/__init__.py', +{%- for babelized_class in cookiecutter.components|list|sort %} '{{ cookiecutter.package_name }}/lib/{{ babelized_class|lower }}.pyx', +{%- endfor %} ] py.install_sources( install_lib_srcs, subdir: '{{ cookiecutter.package_name }}/lib', ) -install_subdir( - 'meta/{{ babelized_class }}', - install_dir: py.get_install_dir() / '{{ cookiecutter.package_name }}/data', -) +{%- for babelized_class, component in cookiecutter.components|dictsort %} py.extension_module( '{{ babelized_class|lower }}', - srcs, - dependencies: deps, + [ +{%- if cookiecutter.language == 'fortran' %} + '{{ cookiecutter.package_name }}/lib/bmi_interoperability.f90', +{%- endif %} + '{{ cookiecutter.package_name }}/lib/{{ babelized_class|lower }}.pyx', + ], + dependencies: [ + dependency('{{ component.library }}', method : 'pkg-config'), + ], include_directories: incs, install: true, subdir: '{{ cookiecutter.package_name }}/lib', @@ -99,5 +88,12 @@ py.extension_module( {%- endif %} ) +install_subdir( + 'meta/{{ babelized_class }}', + install_dir: py.get_install_dir() / '{{ cookiecutter.package_name }}/data', +) + +{%- endfor %} + # This is a temporary fix for editable installs. run_command('cp', '-r', '{{ cookiecutter.package_name }}/data', 'build')