svalinn / DAGMC

Direct Accelerated Geometry Monte Carlo Toolkit
https://svalinn.github.io/DAGMC
Other
96 stars 63 forks source link

Making use of DAGMC in python package #806

Closed shimwell closed 8 months ago

shimwell commented 2 years ago

Describe the Bug
Hi all, I'm making some progress with writing a python package using pybind11 that makes use of DAGMC. I'm getting a small compile error at the moment due to the file names in DAGMC.

This line looks for DagMCVersion.hpp https://github.com/svalinn/DAGMC/blob/50caabf16b12179f92e71d4dcfb5bf6090b30cb6/src/dagmc/DagMC.hpp#L13

The filename in the repo is DagMCVersion.hpp.in https://github.com/svalinn/DAGMC/tree/develop/src/dagmc

So my package doesn't find the file when being built with conda.

I guess we control the version number using this line in the cmake but I'm not sure if conda can pass a variable in here

The package is currently finding #include "dagmc/DagMC.hpp" but then the DagMC.hpp has an include for the DagMCVersion.hpp which it does not find. I believe this is due to the filename ending in .in and the conda package creation not setting the version number or building DAGMC to make the .hpp file.

Any ideas to get this working appreciated.

Screenshot from 2022-05-17 15-45-07

To Reproduce
from a conda environment`

conda install conda-build
git clone https://github.com/shimwell/pybind11_python_example.git
cd pybind11_python_example
conda install -c conda-forge mamba
mamba build conda

The resulting compressed file can then be installed with, but I've not got this far mamba install -c path_to_file dagmc_volume_finder

Expected Behavior
python package gets made that can make use of DAGMC C++ code

Screenshots or Code Snippets
If applicable, add screenshots or snippets of code and error messages to help explain your problem. Note, please do not include screenshots or snippets of code that is export controlled.

Please complete the following information regarding your system:
ubuntu

Additional Context
This error can be observed with the CI https://github.com/shimwell/pybind11_python_example/runs/6472883702?check_suite_focus=true

shimwell commented 2 years ago

I've added this version file to a DAGMC fork and this has helped progress beyond the error I was seeing.

I've also included MOAB in the meta.yaml as the package was looking for .hpp files from MOAB as well. I've also added some extra paths to the include dir in the setup.py to find some moab files that are needed

Currently stuck on this error fatal error: moab/MOABConfig.h: No such file or directory

ahnaf-tahmid-chowdhury commented 9 months ago

Did you have tried with

setup(
    include_dirs=['/path/to/moab/include'],
)

I think we can fix that by adding include dir.

However, the workflow is expaired. Can we plan this and move this in PyDAGMC?

gonuke commented 9 months ago

I'm not sure I follow what you are trying to do. Conceptually, DAGMC will need to be built at some point before this, or during this, right? The build process for DAGMC should create this file.

gonuke commented 8 months ago

I didn't realize how old this was on my last comment - is this still relevant @shimwell ? If not, please feel free to close.

shimwell commented 8 months ago

If we manage to move to a pypi distrbuted pip install for openmc then I think we would need something like this on the dagmc to include dagmc within the openmc wheel. We can close this as until we have that openmc pypi distribution we won't need a dagmc one