-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This PR solves a couple of problems at once. I got an email from a user complaining that the setuptools build system couldn't handle multiple photospline and boost being in different directories. Meson's pkg-config dependency detection is far superior to anything you can ad hoc program in setuptools. This allowed some cleanup that I had wanted to do regarding the meson build file. Also, one of the reasons that I gave up on making wheels for nuflux was that setuptools couldn't figure out how to include header files while mesonpy does this automatically. The files changed looks big but that is just because I also moved the python source directory to /src/. The only change from the user perspective is that when compiling you now use exactly the same env vars for both meson and python. Documentation has been updated to reflect this. cvmfs target py3-v4.0.1 was dropped because the last version of meson that worked with python 3.6 doesn't support the pure option for python. And py3-v4.2.1 was dropped because mesonpy doesn't play well with the python misconfiguration present in that version of cvmfs.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,29 @@ | ||
project('nuflux', 'cpp', | ||
version : '2.0.4', | ||
default_options : ['cpp_std=c++17']) | ||
version: '2.0.4', | ||
default_options: ['cpp_std=c++17']) | ||
|
||
cfitsio = dependency('cfitsio') | ||
photospline = dependency('photospline', method : 'cmake') | ||
|
||
datadir = get_option('data_path') | ||
if datadir == '' | ||
datadir = get_option('prefix') / get_option('datadir') / meson.project_name() | ||
endif | ||
conf_data = configuration_data() | ||
conf_data.set_quoted('DATA_DIR',datadir) | ||
configure_file(output : 'config.h', | ||
configuration : conf_data) | ||
if get_option('install_data') | ||
install_subdir('nuflux/data/', | ||
install_dir:datadir, | ||
strip_directory:true) | ||
conf_data.set_quoted('NUFLUX_VERSION',meson.project_version()) | ||
if not get_option('pymodule') | ||
datadir = get_option('data_path') | ||
if datadir == '' | ||
datadir = get_option('prefix') / get_option('datadir') / meson.project_name() | ||
endif | ||
conf_data.set_quoted('DATA_DIR',datadir) | ||
endif | ||
|
||
subdir('src/include/nuflux') | ||
configure_file( | ||
output: 'config.h', | ||
configuration: conf_data) | ||
configuration_inc = include_directories('.') | ||
|
||
inc = include_directories('src/include') | ||
libnuflux = library( | ||
'nuflux', | ||
'src/library/ANFlux.cpp', | ||
'src/library/IPLEFlux.cpp', | ||
'src/library/LegacyConventionalFlux.cpp', | ||
'src/library/SplineFlux.cpp', | ||
'src/library/SplineFlux2.cpp', | ||
'src/library/FluxFunction.cpp', | ||
'src/library/LegacyPromptFlux.cpp', | ||
'src/library/detail.cpp', | ||
include_directories : inc, | ||
dependencies : [photospline,cfitsio], | ||
install : true) | ||
|
||
init_file = files('src/nuflux/__init__.py') | ||
subdir('src/include/nuflux') | ||
subdir('src/library') | ||
subdir('src/pybindings') | ||
subdir('src/nuflux/data') | ||
subdir('tests') | ||
|
||
pkg_mod = import('pkgconfig') | ||
pkg_mod.generate( | ||
libraries : libnuflux, | ||
version : meson.project_version(), | ||
name : meson.project_name(), | ||
filebase : meson.project_name(), | ||
url : 'https://github.com/IceCubeOpenSource/nuflux', | ||
description : 'A library for calculating atmospheric neutrino fluxes') | ||
|
||
cppcomp = meson.get_compiler('cpp') | ||
pymod = import('python') | ||
python = pymod.find_installation(get_option('python'),required: false) | ||
|
||
if not python.found() | ||
warning('Can\'t find python: "'+get_option('python')+'", skipping python build') | ||
else | ||
pydep = python.dependency() | ||
|
||
# Find numpy | ||
numpy = run_command(python,'-c', | ||
'import importlib.util,os;print(os.path.join(importlib.util.find_spec("numpy").submodule_search_locations[0],"core","include"))', | ||
check: true, | ||
) | ||
if numpy.returncode()==0 | ||
pybind_inc = include_directories(numpy.stdout().strip()) | ||
message ('Numpy found: '+ numpy.stdout().strip()) | ||
else | ||
warning ('Numpy not found: building without arrays') | ||
pybind_inc = include_directories() | ||
endif | ||
|
||
python_name = 'python'+''.join(python.language_version().split('.')) | ||
boost = dependency('boost' , modules : [python_name]) | ||
|
||
if not boost.found() | ||
warning( 'Can\'t find boost python, Skipping python build') | ||
else | ||
message('Building package for python version ' + | ||
python.language_version() + ': ' + python.get_install_dir()) | ||
python.install_sources('nuflux/__init__.py', | ||
subdir: 'nuflux', | ||
) | ||
|
||
python.extension_module( | ||
'_nuflux', | ||
['src/pybindings/module.cxx'], | ||
include_directories : [inc,pybind_inc], | ||
dependencies : [photospline,pydep, boost], | ||
link_with : libnuflux, | ||
install:true) | ||
|
||
pytest_env = environment(test_env) | ||
pytest_env.append('PYTHONPATH',meson.current_source_dir()) | ||
pytest_env.append('PYTHONPATH',meson.current_build_dir()) | ||
test('test_fluxes',find_program('tests/test_fluxes.py'), env: pytest_env) | ||
test('doctest',python,args: ['-m','doctest',files('README.md')],env: pytest_env) | ||
meson.add_devenv(pytest_env) | ||
endif | ||
|
||
endif | ||
|
||
subdir('docs') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
option('python', type : 'string', value : 'python3', description : 'python path to compile against') | ||
option('data_path', type: 'string', value : '', description: 'absolute path to where to install data files, will overrede --datadir Default will be PREFIX/share/nuflux') | ||
option('install_data', type: 'boolean', value : true, description: 'can be set to false if installing on a readonly filesystem') | ||
option('python', type : 'string', value: 'python3', description : 'python path to compile against') | ||
option('data_path', type: 'string', value: '', description: 'absolute path to where to install the raw flux tables, will override --datadir Default will be PREFIX/share/nuflux') | ||
option('install_data', type: 'boolean', value: true, description: 'can be set to false if installing on a readonly filesystem') | ||
option('pymodule', type: 'boolean', value: false, description: 'install as a python module, no shared library, and with the data files as part of the python module' ) |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.