I'm trying to make a C++ research code written by colleagues easily usable by new graduate students. What I'd like to do is a package that abstracts the underlying structure of the project with a clean programming interface. This should be simple enough for my colleagues to help maintain it, without being world class experts of Python.
I would need your help to design and organize my package.
Existing code
The existing code does physics simulations. It takes a plain text input file that contains values for initiating a model. Then, some number-crunching is done in C++, and it writes the simulation results to another text file.
The problem with this approach is that it lacks flexibility, especially when looping on different values of the parameters, and it's not super user-friendly to setup and use. Using bash scripts encourages bad practices and poor reproducibility.
Goal
What we would like is a package that :
- ships with the C++ model and is able to run it from Python.
- is able to do template-filling to create the input file and to parse the output file. [for that I don't need help]
- (optional) build the C++ to allow extending the model. Otherwise just include pre-compiled binaries.
The user would have something like this at the end :
import mymodel
# The variables I'll use
myparams = {temperature : 100, foo : 1, bar : "hello", ...}
# create a Python object for example
mysim = mymodel.simulation(myparams)
# run the C++ model
result = mysim.run()
Questions
What I still can't figure out is :
- In my case, is this a reasonable strategy to do so, or should I consider another one, eg. Python/C++ direct interface ? Seems difficult and I only have to call the main function of the C++ code to have the model running.
- How to build the C++ code when the package is being installed, with support of Linux/MacOS/Windows (the C++ project has no third-party dependencies), and then how do I manage to run the binary ? Alternatively, how do I distribute pre-compiled versions for major OS families.
What I really don't understand
I read a number of doc pages related to distutils
, setup.py
files, searched The Hitchhiker’s Guide to Packaging, but I couldn't find a comprehensive guide to what I'm trying to do. Especially, I don't understand what my setup.py
should contain, how my package should be organized and how I should handle the different files paths when calling the binary...