|
| 1 | +.. _user-guides-develop: |
| 2 | + |
1 | 3 | Develop |
2 | 4 | ======= |
3 | 5 |
|
4 | | -1. Set up a development environment by following the instructions in :ref:`compile <user/guides/compile>`. |
5 | | -2. Install build dependencies by running: |
| 6 | +This guide walks through the steps required to set up a development environment for *xara* |
| 7 | +that can be used to develop code in C++. |
| 8 | + |
| 9 | + |
| 10 | +Initial Setup |
| 11 | +------------- |
| 12 | + |
| 13 | +The following steps only need to be performed once to set up the development environment. |
| 14 | + |
| 15 | +1. Download the source repository to your computer by running: |
| 16 | + |
| 17 | + .. code-block:: shell |
| 18 | +
|
| 19 | + git clone https://github.com/peer-open-source/xara |
| 20 | +
|
| 21 | +2. Install *run-time* dependencies. You can install these with ``pip`` by running: |
6 | 22 |
|
7 | 23 | .. code-block:: bash |
| 24 | +
|
| 25 | + python -m pip install xara |
| 26 | +
|
| 27 | + These are the libraries that will be needed in order to use Xara once it is built. |
| 28 | + |
| 29 | +3. Install *compile-time* dependencies. These dependencies are only |
| 30 | + needed for the compiling process. This is best done in an Anaconda environment. |
| 31 | + For alternative package management systems, see the **Advanced** section below. |
| 32 | + To install the required packages in an Anaconda environment, run: |
| 33 | + |
| 34 | + .. tabs:: |
| 35 | + |
| 36 | + .. tab:: MacOS / Linux |
| 37 | + |
| 38 | + .. note:: |
| 39 | + |
| 40 | + On MacOS, make sure to install the Xcode command line tools by running |
| 41 | + ``xcode-select --install`` from your terminal. |
| 42 | + |
| 43 | + .. code-block:: bash |
| 44 | + |
| 45 | + conda install -c conda-forge fortran-compiler cxx-compiler c-compiler openblas openmpi cmake ninja |
| 46 | +
|
| 47 | +
|
| 48 | + .. tab:: Windows |
| 49 | + |
| 50 | + .. note:: |
| 51 | + |
| 52 | + On Windows, make sure to install Visual Studio with the *"Desktop development with C++"* workload. |
| 53 | + |
| 54 | + .. code-block:: bash |
| 55 | +
|
| 56 | + conda install -c conda-forge cmake ninja ifx_win-64 mkl-devel conda-forge/label/mkl_rc::blas |
| 57 | +
|
| 58 | +
|
| 59 | +4. Create a *persistent* build tree for C/C++ development: |
| 60 | + |
| 61 | + a. Run the CMake *configure* operation. This should be carried out by running: |
| 62 | + |
| 63 | + .. code-block:: shell |
| 64 | +
|
| 65 | + python setup.py cmake |
| 66 | +
|
| 67 | + This effectively runs the standard CMake *configure* procedure |
| 68 | + (i.e., ``mkdir build && cd build && cmake ..``) but adds flags to ensure |
| 69 | + the proper libraries and compilers are found. The name of the resulting |
| 70 | + build directory will depend on factors such as your operating system, |
| 71 | + and the version of Python that is installed in the environment. An example |
| 72 | + might be ``./build/temp.linux-x86_64-cpython-39_local/``, where ``.`` refers |
| 73 | + to the directory that contains ``setup.py``. |
| 74 | + |
| 75 | + b. Navigate into the build tree that was generated by the last step, and |
| 76 | + build the ``OpenSeesRT`` target to create ``libOpenSeesRT.so``: |
| 77 | + |
| 78 | + .. code-block:: shell |
| 79 | +
|
| 80 | + cmake --build . --target OpenSeesRT -j8 |
| 81 | +
|
| 82 | + c. When ``libOpenSeesRT.so`` is built in a persistent tree, the ``xara`` |
| 83 | + package needs to be told where to find it. This is done by setting |
| 84 | + an environment variable with the name ``OPENSEESRT_LIB`` to point to |
| 85 | + the location of ``libOpenSeesRT.so`` in the build tree. |
| 86 | + You may want to add a line like the following to your shell |
| 87 | + startup script (e.g., ``.bashrc``): |
| 88 | + |
| 89 | + .. code-block:: bash |
| 90 | +
|
| 91 | + conda env config vars set OPENSEESRT_LIB="/path/to/libOpenSeesRT.so" -n my_environment |
| 92 | +
|
| 93 | +
|
| 94 | +5. Check that everything was built properly: |
| 95 | + |
| 96 | + .. code-block:: shell |
| 97 | +
|
| 98 | + python -m xara |
| 99 | +
|
| 100 | + This will start a *xara* interpreter which can be closed by running |
| 101 | + the ``exit`` command. |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | +Debug Builds |
| 108 | +------------ |
| 109 | + |
| 110 | +The build type can be configured through the file ``setup.py``. |
| 111 | +For example, to change from a ``Release`` to ``Debug`` build, look for the following lines |
| 112 | +in ``setup.py`` and make the appropriate change: |
| 113 | + |
| 114 | +.. code-block:: python |
| 115 | +
|
| 116 | + cmake_configure_options = [ |
| 117 | + "-G", "Unix Makefiles", |
| 118 | + *EnvArgs, |
| 119 | + "-DCMAKE_BUILD_TYPE=DEBUG", |
| 120 | + # "-DCMAKE_BUILD_TYPE=RELEASE", |
| 121 | + ] |
| 122 | +
|
| 123 | +After this change, rerun the CMake configure and build steps described in |
| 124 | +**Develop → Create a persistent build tree**. |
| 125 | + |
| 126 | + |
| 127 | +Advanced |
| 128 | +-------- |
| 129 | + |
| 130 | +The primary system dependencies required for compiling are LAPACK/BLAS and Tcl. |
| 131 | +Packages providing these libraries are listed below for various package |
| 132 | +management ecosystems. |
| 133 | + |
| 134 | +.. important:: |
| 135 | + |
| 136 | + When building in an Anaconda environment, you should install **all** dependencies |
| 137 | + with ``conda`` or ``mamba``, and preferably from the ``conda-forge`` channel. |
| 138 | + See the **Anaconda** tab below for details. |
| 139 | + |
| 140 | +.. tabs:: |
| 141 | + |
| 142 | + .. tab:: Linux (APT) |
8 | 143 |
|
9 | | - python -m pip install amoeba-build |
| 144 | + The *APT* package manager is used by Debian-based Linux distributions, including Ubuntu. |
| 145 | + |
| 146 | + .. list-table:: |
| 147 | + :header-rows: 1 |
| 148 | + :widths: 30 70 |
| 149 | + |
| 150 | + * - Dependency |
| 151 | + - Package |
| 152 | + * - LAPACK |
| 153 | + - ``liblapack-dev`` |
| 154 | + * - BLAS |
| 155 | + - ``libblas-dev`` |
| 156 | + * - Tcl |
| 157 | + - ``tcl-dev`` |
| 158 | + |
| 159 | + .. tab:: Linux (Pacman) |
| 160 | + |
| 161 | + The Pacman package manager is used by Arch Linux and Manjaro. |
| 162 | + |
| 163 | + .. list-table:: |
| 164 | + :header-rows: 1 |
| 165 | + :widths: 30 70 |
| 166 | + |
| 167 | + * - Dependency |
| 168 | + - Package |
| 169 | + * - LAPACK |
| 170 | + - ``lapack`` |
| 171 | + * - BLAS |
| 172 | + - ``blas`` |
| 173 | + * - Tcl |
| 174 | + - ``tcl`` |
| 175 | + |
| 176 | + .. tab:: Yum (CentOS, Red Hat Linux) |
| 177 | + |
| 178 | + .. list-table:: |
| 179 | + :header-rows: 1 |
| 180 | + :widths: 30 70 |
| 181 | + |
| 182 | + * - Dependency |
| 183 | + - Package |
| 184 | + * - LAPACK |
| 185 | + - ``lapack-devel`` |
| 186 | + * - Tcl |
| 187 | + - ``tcl-devel`` |
| 188 | + |
| 189 | + |
| 190 | +.. tabs:: |
| 191 | + |
| 192 | + .. tab:: MacOS / Linux |
| 193 | + |
| 194 | + .. code-block:: bash |
| 195 | +
|
| 196 | + export OPENSEESRT_LIB="/path/to/your/compiled/libOpenSeesRT.so" |
| 197 | +
|
| 198 | + .. tab:: Windows (Powershell) |
| 199 | + |
| 200 | + .. code-block:: powershell |
10 | 201 |
|
| 202 | + $env:OPENSEESRT_LIB="/path/to/your/compiled/libOpenSeesRT.so" |
0 commit comments