Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bind/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For Python to be able to find and use these bindings, you need to set some envir

## Running the Examples

Example Python scripts are found in this directory as `iguana_ex_*.py`; they will be installed in the `bin/` subdirectory.
Example Python scripts are found in the [`examples/` directory as `iguana_ex_python*.py`](/examples); they will be installed in the `bin/` subdirectory.

Most of them are analogous to the C++ examples, but some may be specific to the Python bindings.

Expand Down
11 changes: 0 additions & 11 deletions bind/python/meson.build
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
install_subdir('pyiguana', install_dir: project_pythondir)

if (get_option('install_examples'))
python_examples = [
'iguana_ex_python_00_run_functions.py',
'iguana_ex_python_01_action_functions.py',
'iguana_ex_python_hipopy.py',
]
foreach example : python_examples
install_data(example, install_dir: get_option('bindir'), install_mode: 'rwxr-xr-x')
endforeach
endif
8 changes: 4 additions & 4 deletions bind/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cppyy==3.1.2
cppyy-backend==1.15.2
cppyy-cling==6.30.0
CPyCppyy==1.12.16
cppyy==3.5.0
cppyy-backend==1.15.3
cppyy-cling==6.32.8
CPyCppyy==1.13.0
pkgconfig==1.5.5
hipopy==2.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@

# set log levels
# NOTE: this can also be done in a config file
seq.SetOption('clas12::EventBuilderFilter', 'log', 'info')
seq.SetOption('clas12::SectorFinder', 'log', 'info')
seq.SetOption('clas12::rga::MomentumCorrection', 'log', 'info')
seq.SetLogLevel('clas12::EventBuilderFilter', 'info')
seq.SetLogLevel('clas12::SectorFinder', 'info')
seq.SetLogLevel('clas12::rga::MomentumCorrection', 'info')

# set algorithm options
# NOTE: this can also be done in a config file, but setting options here OVERRIDES config file settings
Expand Down
34 changes: 33 additions & 1 deletion examples/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
example_config_files_prefix = project_etcdir / 'examples'
install_subdir('config', install_dir: example_config_files_prefix, strip_directory: true)

# example source information
# compiled examples
example_sources = {
# C++
'iguana_ex_cpp_00_run_functions': {'sources': [ 'iguana_ex_cpp_00_run_functions.cc' ]},
'iguana_ex_cpp_00_run_functions_with_banks': {'sources': [ 'iguana_ex_cpp_00_run_functions_with_banks.cc' ]},
'iguana_ex_cpp_01_action_functions': {'sources': [ 'iguana_ex_cpp_01_action_functions.cc' ]},
Expand All @@ -16,6 +17,7 @@ example_sources = {
'sources': [ 'iguana_ex_cpp_config_files.cc' ],
'test_args': [ get_option('prefix') / example_config_files_prefix ],
},
# Fortran
'iguana_ex_fortran_01_action_functions': {
'sources': [ 'iguana_ex_fortran_01_action_functions.f' ],
'build_this': get_option('bind_fortran') and ROOT_dep.found(), # depends on physics::InclusiveKinematics, which depends on ROOT
Expand Down Expand Up @@ -48,3 +50,33 @@ foreach example, info : example_sources
endif
endif
endforeach

# Python examples
if (get_option('bind_python'))
python_examples = [
'iguana_ex_python_00_run_functions.py',
'iguana_ex_python_01_action_functions.py',
'iguana_ex_python_hipopy.py',
]
foreach example : python_examples
install_data(
example,
install_dir: get_option('bindir'),
install_mode: 'rwxr-xr-x'
)
# FIXME: test disabled, because of https://github.com/JeffersonLab/iguana/issues/427
# and many of us have Clas12root libraries in LD_LIBRARY_PATH; anyway, these scripts
# are tested on CI at least
# if fs.is_file(get_option('test_data_file'))
# test(
# example,
# prog_python,
# suite: [ 'example', 'single_threaded' ],
# args: [ example, get_option('test_data_file'), '100' ], # don't run too many events, or meson test log will be huge
# workdir: meson.current_source_dir(),
# env: project_test_env,
# timeout: 240,
# )
# endif
endforeach
endif
9 changes: 9 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ prog_ruby = find_program(
version: '>=3.0.0',
required: use_chameleon,
)
prog_python = find_program(
'python3',
version: '>=3.0.0',
required: get_option('bind_python'),
)
rcdb_dep = dependency(
'rcdb',
fallback: ['rcdb', 'rcdb_dep'],
Expand Down Expand Up @@ -178,6 +183,10 @@ project_test_env.set(
'LSAN_OPTIONS',
'suppressions=' + meson.project_source_root() / 'meson' / 'lsan.supp',
)
project_test_env.prepend(
'PYTHONPATH',
get_option('prefix') / 'python'
)

# set preprocessor macros
add_project_arguments('-DIGUANA_ETCDIR="' + get_option('prefix') / project_etcdir + '"', language: [ 'cpp' ])
Expand Down
7 changes: 7 additions & 0 deletions meson/setup_python_venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
python -m venv .venv
source .venv/bin/activate
python -m pip install -r bind/python/requirements.txt
python -m pip install -r doc/mkdocs/requirements.txt
echo "DONE: now source one of the activate scripts in '.venv/bin/'"
Loading