Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Latest commit

 

History

History

pybindings

    PGMcpp : PRIMED Grid Modelling Code (in C++) - v2.1

    Anthony Truelove MASc, P.Eng.
    email:   [email protected]
    github:  gears1763-2

    See license terms


    // ======== METHOD 1: build Python 3 bindings using make ======== //

    *** NOTE THAT THIS METHOD DOES NOT WORK ON WINDOWS. FOR WINDOWS, ONE MUST USE
    METHOD 2 ***

    To compile Python 3 bindings for PGMcpp, first run

        $   make all

    from the PGMcpp root directory. Once this step completes sucessfully, you should
    see ALL TESTS PASSED.


    Next, ensure that you have pybind11 installed. To do so, you can just

        $   pip install pybind11

    Once that is done, simply run

        $   make pybindings

    from the PGMcpp root directory. This will compile the Python 3 bindings for PGMcpp
    (which is then written to pybindings/PGMcpp.<extension-suffix>), and then run the
    test script at pybindings/test_bindings_from_make.py. If all tests pass, then you
    are set up and ready to go. You should only need to do this step once!


    At this point, you should just be able to

        import PGMcpp

    in any of your Python scripts.
    
    // ======== END METHOD 1 ======== //
    
    
    // ======== METHOD 2: build Python 3 bindings using setuptools ======== //
    
    *** NOTE THAT, IF YOU ARE ON WINDOWS, THEN YOU NEED TO BE USING Python for Windows
    (AS AVAILABLE FROM https://www.python.org/downloads/) TOGETHER WITH THE Microsoft
    Visual Studio "Desktop development with C++" WORKLOAD (AS AVAILABLE FROM
    https://visualstudio.microsoft.com/downloads/). USING MINGW/GCC WILL NOT WORK! ***
    
    First, ensure that you have both pybind11 and setuptools installed. To do so, you
    can just
    
        $   pip install pybind11
        $   pip install setuptools
    
    Once that is done, simply run
    
        $   python(3) setup.py build_ext --inplace
    
    from the pybindings/ directory to build the Python 3 bindings, where the (3) is
    optional depending on your set up. This will generate PGMcpp.<extension-suffix>.
    
    To test the bindings, simply run
    
        $ python(3) test_bindings_from_setup.py
    
    which is found in pybindings/. If all tests pass, then you are set up and ready to
    go. You should only need to do this step once!
    
    // ======== END METHOD 2 ======== //