Skip to content

Commit

Permalink
fix meson options (#18)
Browse files Browse the repository at this point in the history
* fix meson options

fixes  #17
also add pyproject.toml so that numpy can be a build dependency
also add run_commnad check=True to squash warnings
fix GitHub actions
  • Loading branch information
kjmeagher authored Jul 20, 2023
1 parent 1494d8c commit 8430b6a
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 83 deletions.
84 changes: 41 additions & 43 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,78 @@
name: Tests
on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
jobs:
Tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
build: ["meson", "setuptools"]
build: [meson, setuptools]
include:
- os: ubuntu-latest
python-version: "3.10"
- os: macos-latest
python-version: "3.11"
steps:
- name: Checkout nuflux
uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Apt-Get Install Dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install ninja-build gcovr libcfitsio-dev python-is-python3 libboost-python-dev python3-numpy doxygen
sudo python3 -m pip install meson sphinx breathe sphinx_rtd_theme
sudo apt-get install ninja-build gcovr libcfitsio-dev python-is-python3 libboost-python-dev doxygen
python3 -m pip install sphinx breathe sphinx_rtd_theme meson numpy
curl -L https://github.com/icecube/photospline/archive/refs/tags/v2.1.0.tar.gz | tar xz
cmake -S photospline-2.1.0 -B photospline -DCMAKE_BUILD_TYPE=Release
sudo make install -C photospline
- name: HomeBrew Install Dependencies
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install boost-python3 numpy ninja doxygen cfitsio gcovr
sudo python3 -m pip install meson sphinx breathe sphinx_rtd_theme
- name: Checkout Photospline
uses: actions/checkout@v2
with:
repository: icecube/photospline
ref: v2.0.7
path: photospline
- name: Build Photospline
if: matrix.os == 'macos-latest'
run: |
cmake .
make
sudo make install
working-directory: photospline
- name: Checkout nuflux
uses: actions/checkout@v2
brew tap icecube/icecube
brew install boost-python3 ninja doxygen cfitsio gcovr icecube/icecube/photospline
python3 -m pip install sphinx breathe sphinx_rtd_theme meson numpy
- name: Build nuflux with Meson
if: ${{ matrix.build == 'meson' }}
if: matrix.build == 'meson'
run: |
mkdir build
meson build . -D b_coverage=true
meson setup build . -D b_coverage=true --libdir=lib
ninja -C build
sudo ninja -C build install
- name: Build nuflux with setuptools
if: ${{ matrix.build == 'setuptools' }}
run: sudo python3 -m pip install .
if: matrix.build == 'setuptools'
run: python3 -m pip install --user .
- name: Run Python Tests
working-directory: tests
env:
LD_LIBRARY_PATH: /usr/local/lib/:/usr/local/lib/x86_64-linux-gnu
PYTHONPATH: /usr/local/lib/python3/dist-packages
LD_LIBRARY_PATH: /usr/local/lib/
PYTHONPATH: /usr/local/lib/python${{matrix.python-version}}/site-packages
run: |
./test_fluxes.py
python3 -m doctest -v ../README.md
- name: Generate Coverage Report
if: ${{ matrix.build == 'meson' && matrix.os == 'ubuntu-latest' }}
if: matrix.build == 'meson' && startsWith( matrix.os, 'ubuntu')
run: ninja -C build coverage
- name: Upload Coverage to Codecov
if: ${{ matrix.build == 'meson' && matrix.os == 'ubuntu-latest' }}
if: matrix.build == 'meson' && startsWith( matrix.os, 'ubuntu')
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false
verbose: true
- name: Build Documentation
if: ${{ matrix.build == 'meson' }}
run: ninja -C build docs/html
if: matrix.build == 'meson'
env:
LD_LIBRARY_PATH: /usr/local/lib/:/usr/local/lib/x86_64-linux-gnu
PYTHONPATH: /usr/local/lib/python3/dist-packages
LD_LIBRARY_PATH: /usr/local/lib/
PYTHONPATH: /usr/local/lib/python${{matrix.python-version}}/site-packages
run: ninja -C build docs/html
- name: Upload Documentation
if: ${{ matrix.build == 'meson' && matrix.os == 'ubuntu-latest' }}
if: matrix.build == 'meson' && matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master'
run: docs/docs-upload.sh
env:
ICECUBE_PASSWORD: ${{ secrets.ICECUBE_PASSWORD }}
- name: Check Documentation Links
if: ${{ matrix.build == 'meson' }}
run: sphinx-build -c build/docs/ docs/ . -b linkcheck
env:
LD_LIBRARY_PATH: /usr/local/lib/:/usr/local/lib/x86_64-linux-gnu
PYTHONPATH: /usr/local/lib/python3/dist-packages
ICECUBE_PASSWORD: ${{ secrets.ICECUBE_PASSWORD }}
2 changes: 1 addition & 1 deletion docs/cppapi.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
C++ API Reference
=================

.. doxygenindex::
.. .. doxygenindex::
4 changes: 2 additions & 2 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ In Python::
Creating new fluxes
-------------------

| Since the main purpose of nuflux is to provide atmospheric fluxes to analysers in an easy and simple-to-use manner, the introduction of new models and fluxes is the major part of developing it. This section is about creating new fluxes by means of `MCEq <https://github.com/afedynitch/MCEq>`_ and `photospline <https://github.com/icecube/photospline>`_, with the example of a specific combination of models.
| Since the main purpose of nuflux is to provide atmospheric fluxes to analysers in an easy and simple-to-use manner, the introduction of new models and fluxes is the major part of developing it. This section is about creating new fluxes by means of `MCEq <https://github.com/mceq-project/MCEq>`_ and `photospline <https://github.com/icecube/photospline>`_, with the example of a specific combination of models.
| Note that not all fluxes are created this way. This is just to give you an idea of how it might work. If you already have ready-to-go flux tables or splines and are curious on how to integrate them into the project, see :ref:`Storing new fluxes<Storing_new_fluxes>` instead.
1) **Choose your weapon**: To make a new flux, there are three ingredients you need to get started: A primary cosmic ray (CR) model, a hadronic interaction (HI) model, and the type of particle (i.e. atmospheric lepton) you want to make the flux for. In this example, we choose ``HillasGaisser2012 (H3a)``, ``SIBYLL23C``, and ``NuMu``.
Expand All @@ -62,7 +62,7 @@ Creating new fluxes
energy = mceq.e_grid

| And obtain an array ``solutions``; one value for each value in the ``energy`` array. And that's basically it! We can now repeat this for several zenith angles, to have a 2D solution array (one dimension being energy, the other being zenith angle).
| **Remark:** MCEq can do a lot more than what is currently part of these instructions. For more information and options, please visit `https://github.com/afedynitch/MCEq <https://github.com/afedynitch/MCEq>`_.
| **Remark:** MCEq can do a lot more than what is currently part of these instructions. For more information and options, please visit `MCEq's GitHub <https://github.com/mceq-project/MCEq>`_.
3) **Interpolate the solutions with photospline**: The photospline software is using B-splining as interpolation method. It can turn our 2D solution array into a spline surface that can be evaluated at any desired point on the surface. The splining process is pretty neat but may require some practice. The spline surface is stored in a FITS file, that, if correctly formatted, can be integrated into nuflux.

Expand Down
6 changes: 3 additions & 3 deletions docs/fluxes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Variants: ``CORSIKA_GaisserH3a_QGSJET-II``, ``CORSIKA_GaisserH3a_SIBYLL-2.1``, `

This flux is the atmospheric neutrino flux (ANFlux) from direct CORSIKA calculation. A large Monte Carlo set of a modified verison of CORSIKA (v. 7.4003), to allow for the shower output to be serialized into ROOT files, was run for different hadronic interaction models. The neutrino flux at various directions was histogramed and then weighted to the Gaisser H3a cosmic-ray flux. Then these histogram were splined using photospline.

Schöneberg, Sebastian, The spectrum of atmospheric neutrinos above GeV energies, `PhD Thesis, Ruhr Universität Bochum, 2016 <https://nbn-resolving.org/urn:nbn:de:hbz:294-52689>`_.
Schöneberg, Sebastian, The spectrum of atmospheric neutrinos above GeV energies, `PhD Thesis, Ruhr Universität Bochum, 2016 <https://hss-opus.ub.ruhr-uni-bochum.de/opus4/frontdoor/index/index/docId/5268>`_.


IPhonda2006_sno_solmin, IPhonda2014_spl_solmin, IPhonda2014_spl_solmax, IPhonda2014_sk_solmin, IPhonda2014_sk_solmax
Expand All @@ -79,7 +79,7 @@ Despite being continuous across energy, azimuth angle, and zenith angle, the flu

The tables presented here are based on Honda 2006 location at SNO during the solar minimum/ Honda 2014 location at South Pole and Kamioka during the solar minimum and maximum.

Wren, Steven, "Neutrino Mass Ordering Studies with IceCube-DeepCore", `PhD Thesis, University of Manchester, 2018. <https://www.research.manchester.ac.uk/portal/en/theses/neutrino-mass-ordering-studies-with-icecubedeepcore(70414fde-3bef-4028-877b-5e1e86b2165d).html>`_.
Wren, Steven, "Neutrino Mass Ordering Studies with IceCube-DeepCore", `PhD Thesis, University of Manchester, 2018. <https://research.manchester.ac.uk/en/studentTheses/neutrino-mass-ordering-studies-with-icecube-deepcore>`_.


bartol
Expand All @@ -98,7 +98,7 @@ honda2006

Alternative Knee Models: ``gaisserH3a_elbert``, ``gaisserH4a_elbert``, ``gst13_elbert``, ``gst13star_elbert``, ``polygonato_mod_elbert``

Original tables from `Honda's web page <https://www.icrr.u-tokyo.ac.jp/~mhonda/>`_.
Original tables from Honda's web page (Dead link: ``https://www.icrr.u-tokyo.ac.jp/~mhonda/``).

Honda *et al.*, Phys. Rev. D **75**, 043006 (2007).
`astro-ph/0611418 <https://arxiv.org/abs/astro-ph/0611418>`_.
Expand Down
2 changes: 1 addition & 1 deletion docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sphinx_build = find_program('sphinx-build',required:false)

if sphinx_build.found() and doxygen.found()

version = run_command('git', 'describe', '--tags').stdout().strip()
version = run_command('git', 'describe', '--tags', '--always', check:true).stdout().strip()
docs_config = {
'CPP_SOURCE_DIR' : meson.project_source_root() + '/src',
'DOCS_SOURCE_DIR' : meson.current_source_dir(),
Expand Down
14 changes: 7 additions & 7 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ 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"))')
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())
Expand All @@ -78,12 +81,10 @@ else
if not boost.found()
warning( 'Can\'t find boost python, Skipping python build')
else
py_install_dir = python.get_install_dir() / 'nuflux'
message( 'Building package for python version ' +
python.language_version() + ': ' + py_install_dir)

message('Building package for python version ' +
python.language_version() + ': ' + python.get_install_dir())
python.install_sources('nuflux/__init__.py',
subdir: py_install_dir,
subdir: 'nuflux',
)

python.extension_module(
Expand All @@ -92,7 +93,6 @@ else
include_directories : [inc,pybind_inc],
dependencies : [photospline,pydep, boost],
link_with : libnuflux,
install_dir : py_install_dir,
install:true)

test('test_fluxes',find_program('tests/test_fluxes.py'))
Expand Down
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
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('install_data', type: 'boolean', value : 'true', description: 'can be set to false if installing on a readonly filesystem')
8 changes: 4 additions & 4 deletions nuflux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'PionKaonAdjustable', 'SplineFlux', 'SplineFlux2', 'availableFluxes',
'kneesForFlux', 'makeFlux', 'printModels', 'stand_alone']

from ._nuflux import FluxFunction, KneeReweightable, LegacyConventionalFlux, LegacyPromptFlux
from ._nuflux import NuE, NuEBar, NuMu, NuMuBar, NuTau, NuTauBar, ParticleType
from ._nuflux import PionKaonAdjustable, SplineFlux, SplineFlux2, availableFluxes, kneesForFlux
from ._nuflux import makeFlux, printModels, stand_alone
from _nuflux import FluxFunction, KneeReweightable, LegacyConventionalFlux, LegacyPromptFlux
from _nuflux import NuE, NuEBar, NuMu, NuMuBar, NuTau, NuTauBar, ParticleType
from _nuflux import PionKaonAdjustable, SplineFlux, SplineFlux2, availableFluxes, kneesForFlux
from _nuflux import makeFlux, printModels, stand_alone
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[build-system]
requires = ["setuptools", "oldest-supported-numpy"]
build_backend = "setuptools.build_meta"

[project]
name = "nuflux"
version = "2.0.3"
description = "A library for calculating atmospheric neutrino fluxes"
readme = "README.md"
#requires_python = "~=3.8"
dependencies = ['numpy']
license = {file = "LICENCE"}
keywords = ["python", "science", "astronomy", "astrophysics", "IceCube", "atmospheric", "neutrino"]
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: Linux',
'Programming Language :: C++',
'Programming Language :: Python',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Scientific/Engineering :: Astronomy',
'Topic :: Scientific/Engineering :: Physics',
]
2 changes: 1 addition & 1 deletion scripts/create_fluxes/create_fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def Solve_mceqs():
### This function solves matrix cascade equations using MCEq. Please
### note that MCEq can do a lot more than what is currently used
### in this script. For more information and options, visit:
### https://github.com/afedynitch/MCEq
### https://github.com/mceq-project/MCEq

import crflux.models as crf
from MCEq.core import config, MCEqRun
Expand Down
22 changes: 2 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
prefix = os.environ.get('PREFIX', '/usr/local')

extension = Extension(
'nuflux._nuflux', [
'_nuflux', [
'src/library/logging.cpp',
'src/library/SplineFlux.cpp',
'src/library/SplineFlux2.cpp',
Expand All @@ -26,25 +26,7 @@
)

setup(
name = "nuflux",
version = "2.0.3",
packages = find_packages(),
packages = ['nuflux'],
ext_modules = [extension],
package_data = {"nuflux":["data/*/*.fits",'data/*/*.dat']},
test_suite = "tests.test_fluxes",
zip_safe = False,
keywords = [
'neutrino', 'cosmic rays', 'atmospheric neutrinos',
],
classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: Linux',
'Programming Language :: C++',
'Programming Language :: Python',
'Topic :: Scientific/Engineering :: Astronomy',
'Topic :: Scientific/Engineering :: Physics',
],
)

0 comments on commit 8430b6a

Please sign in to comment.