From 92d48ea82d259b9e0fd99dde1e7f63b0c39d9269 Mon Sep 17 00:00:00 2001 From: z-ichinohe Date: Sun, 30 Jun 2024 22:27:05 +0900 Subject: [PATCH 1/4] Building Manual Update --- source/developer/build.rst | 462 ++++++++++++++++++++++--------------- 1 file changed, 270 insertions(+), 192 deletions(-) diff --git a/source/developer/build.rst b/source/developer/build.rst index 4c7a604c..5cf8661b 100644 --- a/source/developer/build.rst +++ b/source/developer/build.rst @@ -4,13 +4,77 @@ Building Application ******************** -The OpenSees applications are built using `CMake `_, an extensible open-source system that manages the build system. It provides a uniform build process across a range of operating systems: Windows, MacOS and different version of Linux. CMake needs to be installed on your system. For it to work, other applications such as C, C++ and Fortran compilers need to be also installed. +This chapter is geared to provide information about building OpenSees applications and its Python Modules. Besides this document, there are Github Action workflows for Windows, Mac OS, and Ubuntu, which is located in ``.github/workflows/build_cmake.yml``. They will be good samples to build, though there are some differences between your computer and remote runner hosted by Github Actions because they are pre-installed many applications used for building applications. +The OpenSees applications are built using `CMake `_, an extensible open-source system that manages the build system. It provides a uniform build process across a range of operating systems: Windows, MacOS and different version of Linux. Thus, following applications need to be installed: + +* CMake + + * Version 3.20 or later is recommended. + +* Git +* C, C++, Fortran Compiler + + * Microsoft Visual Studio and Intel oneAPI Fortran Compiler (for Windows) + * AppleClang in XCode Command Developer Tools and gfortran (for Mac) + * gcc, g++, and gfortran (for Linux) + +* Python 3.11 + + * It's necessary to OpenSeesPy and also required to install conan with PyPI. +* Package Manager + + * Conan 1.59.0 (for Windows, Linux) + + * A package build manager for C/C++ applications. + * Conan 2.0 and beyond have been already released but currently we don't catch up with that. Thus, you should install Conan **1.59.0**. + + * Homebrew (for Mac) + +* MUMPS + + * A parallel solver used in OpenSees + * This should be cloned from GitHub and built. + * Following procedure specifies its location with relative location and assumes mumps and opensees foldera are located in a same directory. + +* Libraries + + * eigen + * hdf5 + * tcl (for Windows) + * zlib (for Windows) + * Intel MPI Libray (for Windows) + * open-mpi (for Mac, Linux) + * scalapack (for Mac, Linux) + * lapack (for Linux) + * Intel oneAPI Math Kernel Library (for Windows) + * mkl (for Linux) + +Obtaining OpenSees Source Code +****************************** + +Source codes will be obtained by Git and its command is same across different OSs. +From a terminal **cd** to the directory you want to place OpenSees. Then type the following and you'll get the source codes in the directory named ``OpenSees``.: + + .. code:: + + git clone https://github.com/OpenSees/OpenSees.git + +If you plan on contributing source code to the OpenSees effort, you should fork the OpenSees repository on GitHub and clone your own fork. To clone your own fork, replace OpenSees in above with your github username. + + .. code:: + + git clone https://github.com/YOUR_USER_NAME/OpenSees.git + +Once the repository is forked, you can catch up with ``OpenSees/OpenSees`` by ``Sync fork`` on GitHub. Once the repository is cloned, you can get updates on GitHub to type: + + .. code:: + + git pull .. note:: - - Most code instructions below are run from a **Terminal** application. Type **cmd** in the Windows search or **terminal** in MacOS spotlight to start the application. If you are on a Unix machine this note may cause you some amusement! + Most code instructions below are run from a **Terminal** application. Type **cmd** in the Windows search or **terminal** in MacOS spotlight to start the application. If you are on a Unix machine this note may cause you some amusement! Windows 10 ********** @@ -18,118 +82,138 @@ Windows 10 Software Requirements ^^^^^^^^^^^^^^^^^^^^^ -For Windows 10 the user must have the following applications installed on their computer: CMake, VisualStudio Basic, Intel One Basic and HPC Toolkits, and MUMPS, and conan: +For Windows 10 the user must have the following applications installed on their computer: -1. **CMake**: We use `CMake `_ for managing the build process. Version 3.20 or later is recommended. +* CMake +* Git +* Microsoft VisualStudio +* Intel oneAPI Basic and HPC Toolkits +* Python 3.11 +* conan 1.59.0 +* MUMPS -2. **Visual Studio**: `Visual Studio (Community Edition) `_ can be used. Some extensions of Visual Studio are also needed: Open Visual Studio Installer, go to Installed / More / Modify, under the Workloads tab, check Desktop development with C++ and Visual Studio extension development; +Other applications will be installed by conan in the building section. -.. warning:: +CMake +===== + + Install from ``_. Version 3.20 or later is recommended. - The very latest release of MSVC, 2022.2, does not currently work with Intel OneAPI. Install the version 2022.1 or the 2019 version of MSCV. - +Git +=== -3. **IntelOne Basic & HPC Toolkits**: Intel's `oneAPI `_ toolkits. To install the Fortran compiler you need to install TWO toolkits, the `base toolkit `_ and the `HPC toolkit `_. One advantage of installing the HPC one to obtain the Fortran compiler is that it comes with **MPI** for building and running the parallel OpenSees applications. + Install from ``_. - - .. note:: +Microsoft Visual Studio +======================= - When downloading, you do not need to sign up with Intel. After you select the Download button a new window pops up titled 'Get Your Download'. In bottom left had corner you can select the 'Continue as Guest' link to start a download without logging in. + `Visual Studio (Community Edition) `_ can be used. Some extensions of Visual Studio are also needed: Open Visual Studio Installer, go to Installed / More / Modify, under the Workloads tab, check Desktop development with C++ and Visual Studio extension development; .. warning:: - 1. The install of the latest version of the base toolkit may fail due to issues installing Python. The error pops up right at the end. To overcome the problem, choose to install the selected components option and choose every package BUT Python. - 2. On windows order matters, the Intel compilers come after Visual Studio. If you reverse the order or if the install was not successfullm cmake when running below will give an error message about failing to find a fortran compiler. + The very latest release of MSVC, 2022.2, does not currently work with Intel OneAPI. Install the version 2022.1 or the 2019 version of MSVC. -4. **MUMPS & conan**: MUMPS is a parallel solver used in OpenSees. Conan is a package build manager for C/C++ applications, that is used to install Tcl and HDF5. They are both installed via the command line, i.e. a DOS terminal. - Mumps is one of the defaults solvers used in OpenSessMP and OpenSeesMP. Like OpenSees it must be installed using **cmake**. Open a terminal window and type the following to set the intel env variables, download and then build the MUMPS library. - - .. code:: - - "C:\Program Files (x86)\Intel\oneAPI\setVars" intel64 mod - git clone https://github.com/OpenSees/mumps.git - cd mumps - mkdir build - cd build - cmake .. -Darith=d -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" -G Ninja - cmake --build . --config Release --parallel 4 - cd ..\.. - pip install conan==1.59.0 - - -Obtaining OpenSees Source Code -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -To obtain the source code, from a terminal **cd** to the directory you want to place OpenSees and then type the following: +Intel oneAPI Basic & HPC Toolkits +================================= - .. code:: + Intel's `oneAPI `_ toolkits. You need to install ``Intel oneAPI Math Kernel Library`` from `Base Toolkit `_ and ``Intel MPI Library`` and ``Intel Fortran Comipler & Intel Fortran Compiler Classic`` from `HPC Toolkit `_. One advantage of installing the HPC one to obtain the Fortran compiler is that it comes with **MPI** for building and running the parallel OpenSees applications. - git clone https://github.com/OpenSees/OpenSees.git + .. note:: -.. note:: + When downloading, you do not need to sign up with Intel. After you select the Download button a new window pops up titled 'Get Your Download'. In bottom left had corner you can select the 'Continue as Guest' link to start a download without logging in. - 1. If you plan on contributing source code to the OpenSees effort, you should fork the OpenSees github repo and clone your own fork. To clone your own fork, replace OpenSees in above with your github username. + .. warning:: - .. code:: + You should install these toolkits after Microsoft Visual Studio is installed and the integration with Microsoft Visual Studio should be enabled. If you reverse the order or if the install was not successfull, cmake when running below will give an error message about failing to find a fortran compiler. + +Python 3.11 +=========== + + Install from ``_. Python **3.12** or newer is not supported by OpenSeesPy currently. Python 3.10 or older version may work. Of course you can install from other channels, i.e. Anaconda, Microsoft Stores. + +conan 1.59.0 +============ + + Conan is used to install Eigen, HDF5, Tcl and Zlib. Type the following to install: + + .. code:: + + pip install conan==1.59.0 + +MUMPS +===== + + Mumps is one of the defaults solvers used in OpenSessMP and OpenSeesMP. Like OpenSees it must be installed using **cmake**. Open a terminal window and type the following to set the intel env variables, download and then build the MUMPS library. + + .. code:: - git clone https://github.com/YOUR_USER_NAME/OpenSees.git + git clone https://github.com/OpenSees/mumps.git + cd mumps + mkdir build + cd build + call "C:\Program Files (x86)\Intel\oneAPI\setVars.bat" intel64 mod + cmake .. -Darith=d -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" -G Ninja + cmake --build . --config Release --parallel 4 + + .. note:: + + Environment variables set by ``"C:\Program Files (x86)\Intel\oneAPI\setVars"`` are only available in Command Prompt just after the batch file is called. That means you should call the batch file from Command Prompt and should not from Powershell. Building the OpenSees Applications and Python module ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ With everything installed the build process is somewhat simple! From a terminal window move to the folder that contains the OpenSees folder and issue the following: - .. code:: - - "C:\Program Files (x86)\Intel\oneAPI\setVars" intel64 mod - cd OpenSees - git pull - mkdir build - cd build - conan install .. --build missing --settings compiler.runtime="MT" - cmake .. -DBLA_STATIC=ON -DMKL_LINK=static -DMKL_INTERFACE_FULL=intel_lp64 -DMUMPS_DIR="..\..\mumps\build" - cmake --build . --config Release --target OpenSees --parallel 4 - cmake --build . --config Release --target OpenSeesPy - cmake --build . --config Release --target OpenSeesMP - cmake --build . --config Release --target OpenSeesSP - cd lib - copy OpenSeesPy.dll opensees.pyd - -When completed the executables (OpenSees, OpenSeesMP, and OpenSeesMP) are located in the build/bin folder and the python module (opensees.pyd) is located in the build/lib folder. - +.. code:: + + mkdir build + cd build + call "C:\Program Files (x86)\Intel\oneAPI\setVars.bat" intel64 mod + conan install .. --build missing --settings compiler.runtime="MT" + cmake .. -DBLA_STATIC=ON -DMKL_LINK=static -DMKL_INTERFACE_FULL=intel_lp64 -DMUMPS_DIR="..\..\mumps\build" + cmake --build . --config Release --target OpenSees -j8 + cmake --build . --config Release --target OpenSeesPy -j8 + move ./bin/OpenSeesPy.dll ./bin/opensees.pyd + copy C:\Program Files (x86)\Intel\oneAPI\compiler\2024.1\bin\libiomp5md.dll ./bin/ + +When completed the executables (OpenSees, OpenSeesMP, and OpenSeesMP) and the python module (opensees.pyd) are located in the build/bin directory. + .. note:: + #. Environment variables set by ``"C:\Program Files (x86)\Intel\oneAPI\setVars"`` are only available in Command Prompt just after the batch file is called. That means you should call the batch file from Command Prompt and should not from Powershell. + #. The --parallel option is used to compile the code in parallel. Change the **4** to how many cores is at your disposal. - #. The above assumes the OpenSees and mumps folders are located in the same folder. + #. The last copy is needed as the OpenSeesPy.dll module at present actually needs to load from a file named **opensees.pyd**. To import this module in a python script you can do one of 2 things: - 1. If you have used pip to install openseespy, you can replace the opensees.pyd file in the site_package location with the opensees.pyd above. To find the location of this module, use the following: + #. If you have used pip to install openseespy, you can replace the opensees.pyd file in the site_package location with the opensees.pyd above. To find the location of this module, use the following: - .. code:: + .. code:: + + python3 + import opensees + import inspect + inspect.getfile(opensees) + + You may of course want to give the existing file a new name with the **copy** command before you overwrite it just in case! You can check the version of **opensees** installed by issuing ``opensees.version()`` at the python command prompt above. - python3 - import opensees - import inspect - inspect.getfile(opensees) + #. If you have not installed openseespy or you want to load the .pyd you built instead of the installed one you can add the path to opensees.pyd to your **PYTHONPATH** env variables. Search for **env settings** in search bar lower left. Add a line to the PYTHONPATH variable with your location of the **bin** folder. If you do this, you also need to copy the python39.dll (or the python310.dll is that is what was used INTO the bin folder). This is because of a security feature with python versions above 3.8 and the dll search path they now use. - You may of course want to give the existing file a new name with the **copy** command before you overwrite it just in case! You can check the version of **opensees** installed by issuing :code: `opensees.version()` at the python command prompt above. - - 2. If you have not installed openseespy or you want to load the .pyd you built instead of the installed one you can add the path to opensees.pyd to your **PYTHONPATH** env variables. Search for **env settings** in search bar lower left. Add a line to the PYTHONPATH variable with your location of the **bin** folder. If you do this, you also need to copy the python39.dll (or the python310.dll is that is what was used INTO the bin folder). This is because of a security feature with python versions above 3.8 and the dll search path they now use. + #. ``libiomp5md.dll`` should be located in a same folder as ``opensees.pyd`` or you'll get DLL load failed error when importing opensees on Python. - 3. Please note you will get a segmentation fault if you run with a different python exe than the one you build for. Look in output of **cmake ..** for the python library used. + #. Please note you will get a segmentation fault if you run with a different python exe than the one you build for. Look in output of **cmake ..** for the python library used. + + #. **conan install .. -build missing** may fail. If it is related to a **zlib** mismatch error see below. If something else and you had installed conan before, it may be related to the version ypu are using. First try installing the latest by issuing *pip install conan --upgrade**. Ty the build again. If it fails (and again it does not issue a warning about a zlib mismatch) try installing the bleeding head latest using the following commands issued at a terminal - 4. **conan install .. -build missing** may fail. If it is related to a **zlib** mismatch error see below. If something else and you had installed conan before, it may be related to the version ypu are using. First try installing the latest by issuing *pip install conan --upgrade**. Ty the build again. If it fails (and again it does not issue a warning about a zlib mismatch) try installing the bleeding head latest using the following commands issued at a terminal - .. code:: - git clone https://github.com/conan-io/conan.git conan-io - cd conan-io - pip install -e . - - 5. The **conan install .. --build missing** step may fail due to a **zlib mismatch**. This is due to fact that the **hdf5** and **tcl** packages used to build OpenSees both rely on **zlib** and the hdf5 group are more apt to update their package to the lastest zlib package than the tcl group. This sometimes results in the **conan** step failing. There is a fix, but it requires you do edit a file in the **tcl** package! + git clone https://github.com/conan-io/conan.git conan-io + cd conan-io + pip install -e . - In your home directory there is a **.conan** folder and in that folder there are some more folders. You need to edit the file **conanfile.py** in the folder **$HOME/.conan/data/tcl/8.6.10/_/_/export**. Change line **51** to use the same zlib as the hdf5 package, currently zlib 1.2.13, i.e. line 51 should now read **self.requires("zlib/1.2.13")**. Now go back to OpenSees/build folder and try again. + #. The **conan install .. --build missing** step may fail due to a **zlib mismatch**. This is due to fact that the **hdf5** and **tcl** packages used to build OpenSees both rely on **zlib** and the hdf5 group are more apt to update their package to the lastest zlib package than the tcl group. This sometimes results in the **conan** step failing. There is a fix, but it requires you do edit a file in the **tcl** package! + In your home directory there is a **.conan** folder and in that folder there are some more folders. You need to edit the file **conanfile.py** in the folder **$HOME/.conan/data/tcl/8.6.10/_/_/export**. Change line **51** to use the same zlib as the hdf5 package, currently zlib 1.2.13, i.e. line 51 should now read **self.requires("zlib/1.2.13")**. Now go back to OpenSees/build folder and try again. MacOS ***** @@ -137,192 +221,186 @@ MacOS Software Requirements ^^^^^^^^^^^^^^^^^^^^^ -For MacOS the user must have the following applications installed on their computer: xcode command line tools, brew, cmake, gcc, gfortran, python, and open-mpi. All the applications are installed via the command line. Some of these you can skip as you may already have them installed. +For MacOS the user must have the following applications installed on their computer: + +* xcode command line tools + * AppleClang + * Git +* brew + * cmake + * eigen + * gfortran + * hdf5 + * open-mpi + * scalapack. +* mumps -1. **XCODE Command Line Tools**: To make Apple Clang and git available, type the following in a terminal application: +All the applications are installed via the command line. Some of these you can skip as you may already have them installed. - .. code:: +XCode Command Line Tools +======================== + + To make sure latest Xcode Command Line Tools installed, type the following in a terminal application. It's required for AppleClang and git. + + .. code:: xcode-select install -.. note:: - - #. if `xcode-select: error: command line tools are already installed, use "Software Update" to install updates` appears, skip because it's already installed. - - #. if `xcode-select: error: command line tools are already installed, use "Software Update" to install updates` appears, skip because it's already installed. + .. note:: + + If `xcode-select: error: command line tools are already installed, use "Software Update" to install updates` appears, skip because it's already installed. + +Install other dependencies via Homebrew +======================================= -2. **brew**: To install the HomeBrew package manager, type the following in a terminal window: + You can install HomeBrew package manager with typing the following in a terminal window: .. code:: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh) - -3. **cmake, gfortran, python & open-mpi**. Now we will use brew to install these applications. Again from the command line type: - + Then, you can install dependencies via Homebrew. Again from the command line type: .. code:: - + brew install cmake - brew install gcc + brew install eigen + brew install gfortran + brew install hdf5 brew install open-mpi brew install scalapack - brew install python@3.9 - git clone https://github.com/OpenSees/mumps.git - cd mumps - mkdir build - cd build - cmake .. -Darith=d - cmake --build . --config Release --parallel 4 - cd .. - -Obtaining the Source Code -^^^^^^^^^^^^^^^^^^^^^^^^^ -To obtain the source code, from a terminal **cd** to the directory you want to place OpenSees and then type the following: + Eigen via **brew** is installed in ``/usr/local/include/eigen3/Eigen`` by default but ``Eigen`` should be found in ``/usr/local/include``. Then, make link by typing: - .. code:: + .. code:: - git clone https://github.com/OpenSees/OpenSees.git + sudo ln -sf /usr/local/include/eigen3/Eigen /usr/local/include/Eigen + .. note:: -.. note:: + The location where eigen is installed may differ. It can be ``/opt/homebrew/include/eigen3/Eigen`` - 1. If you plan on contributing source code to the OpenSees effort, you should fork the OpenSees github repo and clone your own fork. To clone your own fork, replace OpenSees in above with your github username. +MUMPS +===== - .. code:: + Mumps is one of the defaults solvers used in OpenSessMP and OpenSeesMP. Like OpenSees it must be installed using **cmake**. Open a terminal window and type the following to set the intel env variables, download and then build the MUMPS library. + + .. code:: - git clone https://github.com/YOUR_USER_NAME/OpenSees.git + git clone https://github.com/OpenSees/mumps.git + cd mumps + mkdir build + cd build + cmake .. -Darith=d + cmake --build . --config Release --parallel 4 -Building the OpenSees Tcl Application -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Building the OpenSees Applications and Python module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ With everything installed the build process is somehwat simple! Again from a terminal window: - .. code:: +.. code:: - cd OpenSees - git pull - mkdir build - cd build - conan install .. --build missing - cmake .. -DMUMPS_DIR=$PWD/../../mumps/build -DOPENMPI=TRUE -DSCALAPACK_LIBRARIES=/usr/local/Cellar/scalapack/2.2.0_1/lib/libscalapack.dylib - cmake --build . --config Release --target OpenSees --parallel 4 - cmake --build . --config Release --target OpenSeesPy - cmake --build . --config Release --target OpenSeesMP - cmake --build . --config Release --target OpenSeesSP - mv ./lib/OpenSeesPy.dylib ./lib/opensees.so + mkdir build + cd build + cmake .. -DMUMPS_DIR=$PWD/../../mumps/build + cmake --build . --target OpenSees -j8 + cmake --build . --target OpenSeesPy -j8 + mv ./OpenSeesPy.dylib ./opensees.so .. warning:: + #. The -j option is used to compile the code in parallel. Change the **8** to how many cores is at your disposal. - 1. The path to scalapack might change depending on your Mac type, e.g. x86 or ARM cpu, and the version of scalapack. When using brew install scalapack, look to see what path the library is located in. USE THAT PATH IF DIFFERENT! - 2. This last copy is needed as the OpenSeesPy.dylib module at present actually needs to load from a file named **opensees.so** To import this module now in your code you must do one of 2 things: + #. Pre-installed python in ``/usr/bin`` may have problem especially on Apple Silicon Mac. It would be better to install ``python@3.11`` via brew. It will be installed in ``/usr/local/bin`` and called by ``python3.11``. - 2.1 If you have used pip3 to install openseespy, you can replace the opensees.so file in the site_package location with the opensees.so above. To find the location of this module, use the following: + #. ``cmake --build . --target OpenSeesPy`` yields ``OpenSeesPy.dylib`` as its target and this is exactly a python module. However, it can't be loaded from Python unless it's renamed to **opensees.so**. + To import this module in your code, you have two options to do: 1. replacing a file of openseespy.opensees which is installed by pip3 and 2. set an environment variable ``$PYTHONPATH``. - .. code:: + #. If you have used pip3 to install openseespy, you can replace the opensees.so file in the site_package location with the opensees.so above. To find the location of this module, use the following: + + .. code:: - python3 - import opensees - import inspect - inspect.getfile(opensees) + python3 + import opensees + import inspect + inspect.getfile(opensees) - You may of course want to give the existing file a new name with the **mv** command. You can check the version of **opensees** installed by issuing :code: `opensees.version()` at the python command prompt above. - - 2.2 If you have not installed openseespy or you want to load the .so you built instead of the installed one you can add the path to opensees.so to your **PYTHONPATH** env variables with export PYTHONPATH=$PWD or PYTHONPATH=$PWD:$PYTHONPATH depending on if PYTHONPATH exists when you type **env** in the terminal. NOTE: Using $PWD assumes you are in the directory containing the lib file, other put in the full path to the directory. + You may of course want to give the existing file a new name with the **mv** command. You can check the version of **opensees** installed by issuing ``opensees.version()`` at the python command prompt above. - 3. Finally plase note you will get a segmentation fault if you run with a different python exe than the one you build for. Look in output of **cmake ..** for the python library used. + #. If you have not installed openseespy or you want to load the .so you built instead of the installed one you can add the path to opensees.so to your **PYTHONPATH** env variables with ``export PYTHONPATH=$PWD`` or ``PYTHONPATH=$PWD:$PYTHONPATH`` depending on if PYTHONPATH exists when you type **env** in the terminal. NOTE: Using $PWD assumes you are in the directory containing the lib file, other put in the full path to the directory. + + #. Finally plase note you will get a segmentation fault if you run with a different python exe than the one you build for. Look in output of **cmake ..** for the python library used. - Ubuntu ****** Software Requirements ^^^^^^^^^^^^^^^^^^^^^ -1. **Needed Applications and Libraries**: For Ubuntu, the user must have a number of packages installed on their system. These can be installed following commands issued in a terminal window. +Needed Applications and Libraries +================================= + + For Ubuntu, the user must have a number of packages installed on their system. These can be installed following commands issued in a terminal window. .. code:: - sudo apt-get update + sudo apt-get update sudo apt install -y cmake sudo apt install -y gcc g++ gfortran sudo apt install -y python3-pip sudo apt install -y liblapack-dev sudo apt install -y libopenmpi-dev - sudo apt install -y libmkl-rt + sudo apt install -y libmkl-rt sudo apt install -y libmkl-blacs-openmpi-lp64 sudo apt install -y libscalapack-openmpi-dev - git clone https://github.com/OpenSees/mumps.git - cd mumps - mkdir build - cd build - cmake .. -Darith=d - cmake --build . --config Release --parallel 4 - cd ../.. - git clone --depth 1 --branch hdf5-1_12_2 https://github.com/HDFGroup/hdf5.git - cd hdf5 - ./configure --prefix=/usr/local/hdf5 - make - sudo make install - pip3 install conan==1.59.0 - -.. warning:: - - Read the output from the last command. When building **OpenSees** below you will use the conan executable just installed, or find it using :code: `whereis conan` from the command line. If located in a different location to the path used below, you will get an error. Change the command below to path where conan was just installed. -Obtaining the Source Code -^^^^^^^^^^^^^^^^^^^^^^^^^ +conan 1.59.0 +============ -You need to obtain the OpenSees source code from github. To obtain the source code, from a terminal **cd** to the directory you want to place OpenSees and then type the following: + Conan is used to install Eigen, HDF5, Tcl and Zlib. Type the following to install: - .. code:: + .. code:: - git clone https://github.com/OpenSees/OpenSees.git + pip install conan==1.59.0 -Building the OpenSees Applications -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Building the OpenSees Applications and Python module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -With everything installed the build process is somehwat simple! Again from a terminal window enter the following commands: +With everything installed the build process is somewhat simple! Again from a terminal window enter the following commands: - .. code:: + .. code:: - cd OpenSees - git pull - mkdir build - cd build - $HOME/.local/bin/conan install .. --build missing - cmake .. -DMUMPS_DIR=$PWD/../../mumps/build -DOPENMPI=TRUE -DSCALAPACK_LIBRARIES="/usr/lib/x86_64-linux-gnu/libmkl_blacs_openmpi_lp64.so;/usr/lib/x86_64-linux-gnu/libscalapack-openmpi.so.2.1" - cmake --build . --config Release --target OpenSees --parallel 4 - cmake --build . --config Release --target OpenSeesPy - cmake --build . --config Release --target OpenSeesMP - cmake --build . --config Release --target OpenSeesSP - mv ./lib/OpenSeesPy.so ./opensees.so + mkdir build + cd build + $HOME/.local/bin/conan install .. --build missing + cmake .. + cmake --build . --target OpenSees -j8 + cmake --build . --target OpenSeesPy -j8 + mv ./lib/OpenSeesPy.so ./opensees.so .. note:: - 1. If you have more than **4** cores available, you can use the extra cores by changing the **4** value! - + #. If you have more than **4** cores available, you can use the extra cores by changing the **4** value! .. warning:: - This last copy is needed as the OpenSeesPy.dylib module at present actually needs to load from a file named **opensees.so** (go figure). Also to import this module now in your code you can do one of 2 things: + #. This last copy is needed as the OpenSeesPy.dylib module at present actually needs to load from a file named **opensees.so** (go figure). Also to import this module now in your code you can do one of 2 things: - 1. If you have used pip3 to install openseespy, you can replace the opensees.so file in the site_package location with the opensees.so above. To find the location of this module, use the following: + #. If you have used pip3 to install openseespy, you can replace the opensees.so file in the site_package location with the opensees.so above. To find the location of this module, use the following: - .. code:: + .. code:: + + python3 + import opensees + import inspect + inspect.getfile(opensees) - python3 - import opensees - import inspect - inspect.getfile(opensees) + You may of course want to give the existing file a new name with the **mv** command. You can check the version of **opensees** installed by issuing ``opensees.version()`` at the python command prompt above. - You may of course want to give the existing file a new name with the **mv** command. You can check the version of **opensees** installed by issuing :code: `opensees.version()` at the python command prompt above. - - 2. If you have not installed openseespy or you want to load the .so you built instead of the installed one you can add the path to opensees.so to your **PYTHONPATH** env variables with export PYTHONPATH=$PWD or PYTHONPATH=$PWD:$PYTHONPATH depending on if PYTHONPATH exists when you type **env** in the terminal. NOTE: Using $PWD assumes you are in the directory containg the lib file. + #. If you have not installed openseespy or you want to load the .so you built instead of the installed one you can add the path to opensees.so to your **PYTHONPATH** env variables with export PYTHONPATH=$PWD or PYTHONPATH=$PWD:$PYTHONPATH depending on if PYTHONPATH exists when you type **env** in the terminal. NOTE: Using $PWD assumes you are in the directory containg the lib file. - 3. Finally please note you will get a segmentation fault if you run with a different python exe than the one you build with. Look in output of **cmake ..** for the python library used. + #. Finally please note you will get a segmentation fault if you run with a different python exe than the one you build with. Look in output of **cmake ..** for the python library used. - 4. The **conan install .. --build missing** step may fail. This is due to fact that the **hdf5** and **tcl** packages used to build OpenSees both rely on **zlib** and the hdf5 group are more apt to update their package to the lastest zlib package than the tcl group. This sometimes results in the **conan** step failing. There is a fix, but it requires you do edit a file in the **tcl** package! + #. The **conan install .. --build missing** step may fail. This is due to fact that the **hdf5** and **tcl** packages used to build OpenSees both rely on **zlib** and the hdf5 group are more apt to update their package to the lastest zlib package than the tcl group. This sometimes results in the **conan** step failing. There is a fix, but it requires you do edit a file in the **tcl** package! - In your home directory there is a **.conan** folder and in that folder there are some more folders. You need to edit the file **conanfile.py** in the folder **$HOME/.conan/data/tcl/8.6.10/_/_/export**. Change line **51** to use the same zlib as the hdf5 package, currently zlib 1.2.13, i.e. self.requires("zlib/1.2.13"). Now go back to OpenSees/build folder and try again. + In your home directory there is a **.conan** folder and in that folder there are some more folders. You need to edit the file **conanfile.py** in the folder **$HOME/.conan/data/tcl/8.6.10/_/_/export**. Change line **51** to use the same zlib as the hdf5 package, currently zlib 1.2.13, i.e. self.requires("zlib/1.2.13"). Now go back to OpenSees/build folder and try again. From a618cb4694f0416896a75023caf8c472f912d8a9 Mon Sep 17 00:00:00 2001 From: z-ichinohe Date: Mon, 1 Jul 2024 19:45:29 +0900 Subject: [PATCH 2/4] conan 1.x --- source/developer/build.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source/developer/build.rst b/source/developer/build.rst index 5cf8661b..e32bef41 100644 --- a/source/developer/build.rst +++ b/source/developer/build.rst @@ -24,10 +24,10 @@ The OpenSees applications are built using `CMake `_, an exte * It's necessary to OpenSeesPy and also required to install conan with PyPI. * Package Manager - * Conan 1.59.0 (for Windows, Linux) + * Conan 1.x (for Windows, Linux) * A package build manager for C/C++ applications. - * Conan 2.0 and beyond have been already released but currently we don't catch up with that. Thus, you should install Conan **1.59.0**. + * Conan 2.0 and beyond have been already released but currently we don't catch up with that. Thus, you should install Conan **1.64.1**, which is the last version of Conan 1.x * Homebrew (for Mac) @@ -89,7 +89,7 @@ For Windows 10 the user must have the following applications installed on their * Microsoft VisualStudio * Intel oneAPI Basic and HPC Toolkits * Python 3.11 -* conan 1.59.0 +* conan 1.64.1 * MUMPS Other applications will be installed by conan in the building section. @@ -131,14 +131,14 @@ Python 3.11 Install from ``_. Python **3.12** or newer is not supported by OpenSeesPy currently. Python 3.10 or older version may work. Of course you can install from other channels, i.e. Anaconda, Microsoft Stores. -conan 1.59.0 -============ +conan 1.x +========= Conan is used to install Eigen, HDF5, Tcl and Zlib. Type the following to install: .. code:: - pip install conan==1.59.0 + pip install conan<2.0 MUMPS ===== @@ -182,7 +182,7 @@ When completed the executables (OpenSees, OpenSeesMP, and OpenSeesMP) and the py #. Environment variables set by ``"C:\Program Files (x86)\Intel\oneAPI\setVars"`` are only available in Command Prompt just after the batch file is called. That means you should call the batch file from Command Prompt and should not from Powershell. - #. The --parallel option is used to compile the code in parallel. Change the **4** to how many cores is at your disposal. + #. The -j option is used to compile the code in parallel. Change the **4** to how many cores is at your disposal. #. The last copy is needed as the OpenSeesPy.dll module at present actually needs to load from a file named **opensees.pyd**. To import this module in a python script you can do one of 2 things: @@ -199,7 +199,7 @@ When completed the executables (OpenSees, OpenSeesMP, and OpenSeesMP) and the py #. If you have not installed openseespy or you want to load the .pyd you built instead of the installed one you can add the path to opensees.pyd to your **PYTHONPATH** env variables. Search for **env settings** in search bar lower left. Add a line to the PYTHONPATH variable with your location of the **bin** folder. If you do this, you also need to copy the python39.dll (or the python310.dll is that is what was used INTO the bin folder). This is because of a security feature with python versions above 3.8 and the dll search path they now use. - #. ``libiomp5md.dll`` should be located in a same folder as ``opensees.pyd`` or you'll get DLL load failed error when importing opensees on Python. + #. ``libiomp5md.dll`` should be located in a same folder as ``opensees.pyd`` or you'll get ``ImportError: DLL load failed while importing opensees: The specified module could not be found.`` when importing opensees on Python. #. Please note you will get a segmentation fault if you run with a different python exe than the one you build for. Look in output of **cmake ..** for the python library used. @@ -354,14 +354,14 @@ Needed Applications and Libraries sudo apt install -y libmkl-blacs-openmpi-lp64 sudo apt install -y libscalapack-openmpi-dev -conan 1.59.0 -============ +Conan 1.x +========= Conan is used to install Eigen, HDF5, Tcl and Zlib. Type the following to install: .. code:: - pip install conan==1.59.0 + pip install conan<2.0 Building the OpenSees Applications and Python module ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From d824b6c46e859e664dc33ee7c5411d4acb1b0d60 Mon Sep 17 00:00:00 2001 From: z-ichinohe Date: Mon, 1 Jul 2024 20:55:57 +0900 Subject: [PATCH 3/4] XCode Command Line Tools Reinstall --- source/developer/build.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/developer/build.rst b/source/developer/build.rst index e32bef41..8c2b6db3 100644 --- a/source/developer/build.rst +++ b/source/developer/build.rst @@ -248,7 +248,14 @@ XCode Command Line Tools .. note:: - If `xcode-select: error: command line tools are already installed, use "Software Update" to install updates` appears, skip because it's already installed. + #. If `xcode-select: error: command line tools are already installed, use "Software Update" to install updates` appears, skip because it's already installed. + + #. After update of OS, XCode Command Line Tools version may have a problem. To reinstall, type: + + .. code:: + + sudo rm -rf /Library/Developer/CommandLineTools + sudo xcode-select --install Install other dependencies via Homebrew ======================================= From 24d65c1e5b989e7e0f0f9abc538a15ec45e16b23 Mon Sep 17 00:00:00 2001 From: z-ichinohe Date: Tue, 2 Jul 2024 18:43:01 +0900 Subject: [PATCH 4/4] Conan 2.0 --- source/developer/build.rst | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/source/developer/build.rst b/source/developer/build.rst index 8c2b6db3..1c655a8d 100644 --- a/source/developer/build.rst +++ b/source/developer/build.rst @@ -22,12 +22,12 @@ The OpenSees applications are built using `CMake `_, an exte * Python 3.11 * It's necessary to OpenSeesPy and also required to install conan with PyPI. + * Package Manager - * Conan 1.x (for Windows, Linux) + * Conan (for Windows, Linux) * A package build manager for C/C++ applications. - * Conan 2.0 and beyond have been already released but currently we don't catch up with that. Thus, you should install Conan **1.64.1**, which is the last version of Conan 1.x * Homebrew (for Mac) @@ -131,14 +131,14 @@ Python 3.11 Install from ``_. Python **3.12** or newer is not supported by OpenSeesPy currently. Python 3.10 or older version may work. Of course you can install from other channels, i.e. Anaconda, Microsoft Stores. -conan 1.x -========= +Conan +===== Conan is used to install Eigen, HDF5, Tcl and Zlib. Type the following to install: .. code:: - pip install conan<2.0 + pip install conan MUMPS ===== @@ -169,12 +169,13 @@ With everything installed the build process is somewhat simple! From a terminal mkdir build cd build call "C:\Program Files (x86)\Intel\oneAPI\setVars.bat" intel64 mod - conan install .. --build missing --settings compiler.runtime="MT" - cmake .. -DBLA_STATIC=ON -DMKL_LINK=static -DMKL_INTERFACE_FULL=intel_lp64 -DMUMPS_DIR="..\..\mumps\build" + conan profile detect + conan install .. --output-folder=conan --build=missing --settings compiler.runtime="static" + cmake .. -DBLA_STATIC=ON -DMKL_LINK=static -DMKL_INTERFACE_FULL=intel_lp64 -DMUMPS_DIR="..\..\mumps\build" -DCMAKE_TOOLCHAIN_FILE=conan/conan_toolchain.cmake cmake --build . --config Release --target OpenSees -j8 cmake --build . --config Release --target OpenSeesPy -j8 - move ./bin/OpenSeesPy.dll ./bin/opensees.pyd - copy C:\Program Files (x86)\Intel\oneAPI\compiler\2024.1\bin\libiomp5md.dll ./bin/ + move ./Release/OpenSeesPy.dll ./Release/opensees.pyd + copy C:\Program Files (x86)\Intel\oneAPI\compiler\2024.1\bin\libiomp5md.dll ./Release/ When completed the executables (OpenSees, OpenSeesMP, and OpenSeesMP) and the python module (opensees.pyd) are located in the build/bin directory. @@ -197,7 +198,7 @@ When completed the executables (OpenSees, OpenSeesMP, and OpenSeesMP) and the py You may of course want to give the existing file a new name with the **copy** command before you overwrite it just in case! You can check the version of **opensees** installed by issuing ``opensees.version()`` at the python command prompt above. - #. If you have not installed openseespy or you want to load the .pyd you built instead of the installed one you can add the path to opensees.pyd to your **PYTHONPATH** env variables. Search for **env settings** in search bar lower left. Add a line to the PYTHONPATH variable with your location of the **bin** folder. If you do this, you also need to copy the python39.dll (or the python310.dll is that is what was used INTO the bin folder). This is because of a security feature with python versions above 3.8 and the dll search path they now use. + #. If you have not installed openseespy or you want to load the .pyd you built instead of the installed one you can add the path to opensees.pyd to your **PYTHONPATH** env variables. Search for **env settings** in search bar lower left. Add a line to the PYTHONPATH variable with your location of the **Release** folder. If you do this, you also need to copy the python39.dll (or the python310.dll is that is what was used INTO the bin folder). This is because of a security feature with python versions above 3.8 and the dll search path they now use. #. ``libiomp5md.dll`` should be located in a same folder as ``opensees.pyd`` or you'll get ``ImportError: DLL load failed while importing opensees: The specified module could not be found.`` when importing opensees on Python. @@ -361,14 +362,14 @@ Needed Applications and Libraries sudo apt install -y libmkl-blacs-openmpi-lp64 sudo apt install -y libscalapack-openmpi-dev -Conan 1.x -========= +Conan +===== Conan is used to install Eigen, HDF5, Tcl and Zlib. Type the following to install: .. code:: - pip install conan<2.0 + pip install conan Building the OpenSees Applications and Python module ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -379,11 +380,12 @@ With everything installed the build process is somewhat simple! Again from a ter mkdir build cd build - $HOME/.local/bin/conan install .. --build missing - cmake .. + $HOME/.local/bin/conan profile detect + $HOME/.local/bin/conan install .. --output-folder=conan --build missing + cmake .. -DCMAKE_TOOLCHAIN_FILE=conan/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release cmake --build . --target OpenSees -j8 cmake --build . --target OpenSeesPy -j8 - mv ./lib/OpenSeesPy.so ./opensees.so + mv ./OpenSeesPy.so ./opensees.so .. note::