From a74ee3bb98f5f6eb2c176b66476160d7edeb3f95 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Tue, 3 Oct 2023 15:30:27 -0600 Subject: [PATCH 01/16] make sure libraries in idaes-local are relocatable --- scripts/compile_solvers.sh | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) mode change 100644 => 100755 scripts/compile_solvers.sh diff --git a/scripts/compile_solvers.sh b/scripts/compile_solvers.sh old mode 100644 new mode 100755 index d04a180b..4c6934f3 --- a/scripts/compile_solvers.sh +++ b/scripts/compile_solvers.sh @@ -335,7 +335,7 @@ echo "# Ipopt Shared Libraries #" echo "#########################################################################" cd Ipopt_share ./configure --enable-shared --disable-static --without-asl --disable-java \ - --with-mumps --with-hsl --prefix=$IDAES_EXT/coinbrew/dist-share + --with-mumps --with-hsl --enable-relocatable --prefix=$IDAES_EXT/coinbrew/dist-share make $PARALLEL make install cd $IDAES_EXT/coinbrew @@ -378,13 +378,12 @@ cp ../coinbrew/dist/bin/couenne ./ # aren't exe or libraries) strip --strip-unneeded * +# Copy the solver libraries and header files (just ipopt and sipopt for now) +# into ./dist-share. We will compress them and copy into ./dist-solvers later. cd ../ cp -r ./coinbrew/dist-share ./dist-share -cd $IDAES_EXT/dist-share -tar -czvf idaes-local-${osname}-${MNAME}.tar.gz * - -cd $IDAES_EXT/dist-solvers/ -cp ../dist-share/idaes-local-${osname}-${MNAME}.tar.gz ./ +# Subsequent parts of this script rely on being in this directory +cd $IDAES_EXT/dist-solvers echo "#########################################################################" echo "# Copy License and Version Files to dist-solvers #" @@ -503,6 +502,10 @@ if [ ${osname} = "darwin" ]; then install_name_tool -change ${BREWLIB}libgomp.1.dylib @rpath/libgomp.1.dylib $1 install_name_tool -change ${BREWLIB}libquadmath.0.dylib @rpath/libquadmath.0.dylib $1 } + # Dynamic libraries also need to update their own install names + update_library_rpath_darwin() { + install_name_tool -id @rpath/$1 $1 + } update_rpath_darwin ipopt update_rpath_darwin ipopt_sens update_rpath_darwin clp @@ -516,11 +519,26 @@ if [ ${osname} = "darwin" ]; then update_rpath_darwin libipopt.3.dylib update_rpath_darwin libsipopt.3.dylib update_rpath_darwin libpynumero_ASL.dylib + update_library_rpath_darwin libipopt.dylib + update_library_rpath_darwin libsipopt.dylib + update_library_rpath_darwin libipopt.3.dylib + update_library_rpath_darwin libsipopt.3.dylib + update_library_rpath_darwin libpynumero_ASL.dylib # if no hsl k_aug and dot_snse won't exist update_rpath_darwin k_aug || true update_rpath_darwin dot_sens || true cd $IDAES_EXT/dist-petsc update_rpath_darwin petsc + # Update rpaths in dist-share/lib + cd $IDAES_EXT/dist-share/lib + update_rpath_darwin libipopt.dylib + update_rpath_darwin libsipopt.dylib + update_rpath_darwin libipopt.3.dylib + update_rpath_darwin libsipopt.3.dylib + update_library_rpath_darwin libipopt.dylib + update_library_rpath_darwin libsipopt.dylib + update_library_rpath_darwin libipopt.3.dylib + update_library_rpath_darwin libsipopt.3.dylib fi # here you pack files @@ -529,7 +547,10 @@ echo "# Finish #" echo "#########################################################################" cd $IDAES_EXT/dist-petsc tar -czvf idaes-petsc-${osname}-${MNAME}.tar.gz * +cd $IDAES_EXT/dist-share +tar -czvf idaes-local-${osname}-${MNAME}.tar.gz * cd $IDAES_EXT/dist-solvers +cp ../dist-share/idaes-local-${osname}-${MNAME}.tar.gz ./ tar -czvf idaes-solvers-${osname}-${MNAME}.tar.gz * echo "Done" echo "HSL Present: ${with_hsl}" From ff319b6c3558d527a5889a720a7ef9f062c11e60 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Fri, 6 Oct 2023 12:35:42 -0600 Subject: [PATCH 02/16] patch ipopt.pc --- scripts/compile_solvers.sh | 6 ++++++ scripts/ipopt.pc.patch | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 scripts/ipopt.pc.patch diff --git a/scripts/compile_solvers.sh b/scripts/compile_solvers.sh index 4c6934f3..5169199b 100755 --- a/scripts/compile_solvers.sh +++ b/scripts/compile_solvers.sh @@ -17,6 +17,8 @@ fi export MNAME=`uname -m` # Get path of directory we're working in +# Note that, when accessing patch files, we assume this directory +# to be the root of the idaes-ext repository. export IDAES_EXT=`pwd` if [ -f $IDAES_EXT/../coinhsl.zip ] @@ -382,6 +384,10 @@ strip --strip-unneeded * # into ./dist-share. We will compress them and copy into ./dist-solvers later. cd ../ cp -r ./coinbrew/dist-share ./dist-share +# Patch to remove "Requires.private: coinhsl coinmumps" +# Note that we are patching the file *after* we copy it into the directory +# we will distribute. +patch ./dist-share/lib/pkgconfig/ipopt.pc < $IDAES_EXT/scripts/ipopt.pc.patch # Subsequent parts of this script rely on being in this directory cd $IDAES_EXT/dist-solvers diff --git a/scripts/ipopt.pc.patch b/scripts/ipopt.pc.patch new file mode 100644 index 00000000..303cbb9b --- /dev/null +++ b/scripts/ipopt.pc.patch @@ -0,0 +1,8 @@ +--- coinbrew/dist-share/lib/pkgconfig/ipopt.pc 2023-10-03 15:21:44 ++++ coinbrew/dist-share/lib/pkgconfig/ipopt.pc.fix 2023-10-06 11:38:08 +@@ -12,4 +12,4 @@ + Libs.private: -framework Accelerate -ldl + Cflags: -I${includedir} + Requires: +-Requires.private: coinhsl coinmumps ++#Requires.private: coinhsl coinmumps From 5cf2cc297da1f3f5f37abc7ba00e44520e78f218 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Fri, 6 Oct 2023 15:16:01 -0600 Subject: [PATCH 03/16] remove unnecessary "./" --- scripts/compile_solvers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/compile_solvers.sh b/scripts/compile_solvers.sh index 5169199b..53d7aa91 100755 --- a/scripts/compile_solvers.sh +++ b/scripts/compile_solvers.sh @@ -387,7 +387,7 @@ cp -r ./coinbrew/dist-share ./dist-share # Patch to remove "Requires.private: coinhsl coinmumps" # Note that we are patching the file *after* we copy it into the directory # we will distribute. -patch ./dist-share/lib/pkgconfig/ipopt.pc < $IDAES_EXT/scripts/ipopt.pc.patch +patch dist-share/lib/pkgconfig/ipopt.pc < $IDAES_EXT/scripts/ipopt.pc.patch # Subsequent parts of this script rely on being in this directory cd $IDAES_EXT/dist-solvers From b703b7446d925cb10c13c36ef0b19621ccd67eb6 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Fri, 6 Oct 2023 17:55:25 -0600 Subject: [PATCH 04/16] pack all files into a single dist directory with lib, include, and bin subdirectories --- scripts/compile_solvers.sh | 194 ++++++++++++++++++------------------- 1 file changed, 92 insertions(+), 102 deletions(-) diff --git a/scripts/compile_solvers.sh b/scripts/compile_solvers.sh index 53d7aa91..28d358a1 100755 --- a/scripts/compile_solvers.sh +++ b/scripts/compile_solvers.sh @@ -342,65 +342,69 @@ make $PARALLEL make install cd $IDAES_EXT/coinbrew +# The above compiles and installs solvers into ./coinbrew/dist* +# Now we will copy the files we wish to distribute into a ./dist directory, +# with standard bin, include, and lib sub-directories. + echo "#########################################################################" -echo "# Copy Coin Solver Files to dist-solvers #" +echo "# Copy Coin Solver Files to dist #" echo "#########################################################################" cd $IDAES_EXT -mkdir dist-solvers -cd dist-solvers +mkdir dist dist/bin dist/include dist/lib +# I'll try to avoid cd-ing around, for now, to make this script more +# explicit for the reader. +# cd dist # Executables if [ ${osname} = "windows" ]; then # windows - cp ../coinbrew/dist_l1/bin/ipopt.exe ./ipopt_l1.exe - cp ../coinbrew/dist_l1/bin/ipopt_sens.exe ./ipopt_sens_l1.exe + cp ./coinbrew/dist_l1/bin/ipopt.exe ./dist/bin/ipopt_l1.exe + cp ./coinbrew/dist_l1/bin/ipopt_sens.exe ./dist/bin/ipopt_sens_l1.exe # Explicitly only get ipopt so we don't get anything we shouldn't - cp ../coinbrew/dist-share/bin/libipopt*.dll ./ - cp ../coinbrew/dist-share/bin/libsipopt*.dll ./ + cp ./coinbrew/dist-share/bin/libipopt*.dll ./dist/lib/ + cp ./coinbrew/dist-share/bin/libsipopt*.dll ./dist/lib/ elif [ ${osname} = "darwin" ]; then - cp ../coinbrew/dist_l1/bin/ipopt ./ipopt_l1 - cp ../coinbrew/dist_l1/bin/ipopt_sens ./ipopt_sens_l1 + cp ./coinbrew/dist_l1/bin/ipopt ./dist/bin/ipopt_l1 + cp ./coinbrew/dist_l1/bin/ipopt_sens ./dist/bin/ipopt_sens_l1 # Explicitly only get ipopt so we don't get anything we shouldn't - cp ../coinbrew/dist-share/lib/libipopt*.dylib ./ - cp ../coinbrew/dist-share/lib/libsipopt*.dylib ./ + cp ./coinbrew/dist-share/lib/libipopt*.dylib ./dist/lib/ + cp ./coinbrew/dist-share/lib/libsipopt*.dylib ./dist/lib/ else # linux - cp ../coinbrew/dist_l1/bin/ipopt ./ipopt_l1 - cp ../coinbrew/dist_l1/bin/ipopt_sens ./ipopt_sens_l1 + cp ./coinbrew/dist_l1/bin/ipopt ./dist/bin/ipopt_l1/ + cp ./coinbrew/dist_l1/bin/ipopt_sens ./dist/bin/ipopt_sens_l1 # Explicitly only get ipopt so we don't get anything we shouldn't - cp ../coinbrew/dist-share/lib/libipopt*.so ./ - cp ../coinbrew/dist-share/lib/libsipopt*.so ./ + cp ./coinbrew/dist-share/lib/libipopt*.so ./dist/lib/ + cp ./coinbrew/dist-share/lib/libsipopt*.so ./dist/lib/ fi -cp ../coinbrew/dist/bin/ipopt ./ -cp ../coinbrew/dist/bin/ipopt_sens ./ -cp ../coinbrew/dist/bin/clp ./ -cp ../coinbrew/dist/bin/cbc ./ -cp ../coinbrew/dist/bin/bonmin ./ -cp ../coinbrew/dist/bin/couenne ./ +cp ./coinbrew/dist/bin/ipopt ./dist/bin/ +cp ./coinbrew/dist/bin/ipopt_sens ./dist/bin/ +cp ./coinbrew/dist/bin/clp ./dist/bin/ +cp ./coinbrew/dist/bin/cbc ./dist/bin/ +cp ./coinbrew/dist/bin/bonmin ./dist/bin/ +cp ./coinbrew/dist/bin/couenne ./dist/bin/ # Run strip to remove unneeded symbols (it's okay that some files # aren't exe or libraries) -strip --strip-unneeded * +strip --strip-unneeded ./dist/bin/* + +# Copy contents of dist-share (ipopt lib, include, and share) into dist +cp -r ./coinbrew/dist-share/* ./dist/ -# Copy the solver libraries and header files (just ipopt and sipopt for now) -# into ./dist-share. We will compress them and copy into ./dist-solvers later. -cd ../ -cp -r ./coinbrew/dist-share ./dist-share # Patch to remove "Requires.private: coinhsl coinmumps" # Note that we are patching the file *after* we copy it into the directory # we will distribute. -patch dist-share/lib/pkgconfig/ipopt.pc < $IDAES_EXT/scripts/ipopt.pc.patch -# Subsequent parts of this script rely on being in this directory -cd $IDAES_EXT/dist-solvers +patch ./dist/lib/pkgconfig/ipopt.pc < $IDAES_EXT/scripts/ipopt.pc.patch echo "#########################################################################" echo "# Copy License and Version Files to dist-solvers #" echo "#########################################################################" # Text information files include build time -cp ../license.txt ./ -cp ../version.txt ./version_solvers.txt -sed s/"(DATE)"/`date +%Y%m%d-%H%M`/g version_solvers.txt > tmp -sed s/"(PLAT)"/${osname}-${MNAME}/g tmp > tmp2 -mv tmp2 version_solvers.txt -rm tmp +cp ./license.txt ./dist/ +cp ./version.txt ./dist/version_solvers.txt +sed s/"(DATE)"/`date +%Y%m%d-%H%M`/g ./dist/version_solvers.txt > ./dist/tmp +sed s/"(PLAT)"/${osname}-${MNAME}/g ./dist/tmp > ./dist/tmp2 +# Why do we create dist/version_solvers.txt above if we will just overwrite it? +mv ./dist/tmp2 ./dist/version_solvers.txt +rm ./dist/tmp* # # Copy some linked libraries from homebrew or mingw, covered by gcc runtime @@ -412,25 +416,25 @@ echo "# Copy GCC/MinGW Runtime Libraries to dist-solvers #" echo "#########################################################################" if [ ${osname} = "windows" ]; then # Winodws MinGW linked redistributable libraries - cp /mingw64/bin/libstdc++-6.dll ./ - cp /mingw64/bin/libgcc_s_seh-1.dll ./ - cp /mingw64/bin/libwinpthread-1.dll ./ - cp /mingw64/bin/libgfortran-*.dll ./ - cp /mingw64/bin/libquadmath-0.dll ./ - cp /mingw64/bin/libgomp-1.dll ./ - cp /mingw64/bin/liblapack.dll ./ - cp /mingw64/bin/libblas.dll ./ - cp /mingw64/bin/libbz2-*.dll ./ - cp /mingw64/bin/zlib*.dll ./ - cp /mingw64/bin/libssp*.dll ./ + cp /mingw64/bin/libstdc++-6.dll ./dist/lib/ + cp /mingw64/bin/libgcc_s_seh-1.dll ./dist/lib/ + cp /mingw64/bin/libwinpthread-1.dll ./dist/lib/ + cp /mingw64/bin/libgfortran-*.dll ./dist/lib/ + cp /mingw64/bin/libquadmath-0.dll ./dist/lib/ + cp /mingw64/bin/libgomp-1.dll ./dist/lib/ + cp /mingw64/bin/liblapack.dll ./dist/lib/ + cp /mingw64/bin/libblas.dll ./dist/lib/ + cp /mingw64/bin/libbz2-*.dll ./dist/lib/ + cp /mingw64/bin/zlib*.dll ./dist/lib/ + cp /mingw64/bin/libssp*.dll ./dist/lib/ fi if [ ${osname} = "darwin" ]; then - cp ${BREWLIB}libgfortran.5.dylib ./ - cp ${BREWLIB}libgcc_s.1.1.dylib ./ - cp ${BREWLIB}libstdc++.6.dylib ./ - cp ${BREWLIB}libgomp.1.dylib ./ - cp ${BREWLIB}libquadmath.0.dylib ./ + cp ${BREWLIB}libgfortran.5.dylib ./dist/lib/ + cp ${BREWLIB}libgcc_s.1.1.dylib ./dist/lib/ + cp ${BREWLIB}libstdc++.6.dylib ./dist/lib/ + cp ${BREWLIB}libgomp.1.dylib ./dist/lib/ + cp ${BREWLIB}libquadmath.0.dylib ./dist/lib/ fi echo "#########################################################################" @@ -442,7 +446,7 @@ if [ ${osname} = "darwin" ]; then export CXX="c++" fi -cd $IDAES_EXT +# We are already in this directory git clone $PYNU_REPO cd pyomo git checkout $PYNU_BRANCH @@ -456,12 +460,13 @@ else cmake .. -DENABLE_HSL=no -DIPOPT_DIR=$IDAES_EXT/coinbrew/dist fi make $PARALLEL -cp libpynumero_ASL* $IDAES_EXT/dist-solvers +cp libpynumero_ASL* $IDAES_EXT/dist/lib/ +# Return to root directory +cd $IDAES_EXT echo "#########################################################################" echo "# k_aug, dotsens #" echo "#########################################################################" -cd $IDAES_EXT git clone $K_AUG_REPO cp ./scripts/k_aug_CMakeLists.txt ./k_aug/CMakeLists.txt cd k_aug @@ -473,8 +478,10 @@ else cmake -DCMAKE_C_COMPILER=$CC . fi make $PARALLEL -cp bin/k_aug* $IDAES_EXT/dist-solvers -cp dot_sens* $IDAES_EXT/dist-solvers +cp bin/k_aug* $IDAES_EXT/dist/bin/ +cp dot_sens* $IDAES_EXT/dist/bin/ +# Return to root directory +cd $IDAES_EXT echo "#########################################################################" echo "# PETSc #" @@ -484,23 +491,21 @@ export ASL_LIB=$IDAES_EXT/coinbrew/dist/lib/libcoinasl.a cd $IDAES_EXT/petsc make $PARALLEL make py -mkdir $IDAES_EXT/dist-petsc if [ ${osname} = "windows" ] then - cp petsc.exe $IDAES_EXT/dist-petsc + cp petsc.exe $IDAES_EXT/dist/bin/ else - cp petsc $IDAES_EXT/dist-petsc + cp petsc $IDAES_EXT/dist/bin/ fi -cp -r petscpy $IDAES_EXT/dist-petsc -cp ../dist-solvers/license.txt $IDAES_EXT/dist-petsc/license_petsc.txt -cp ../dist-solvers/version_solvers.txt $IDAES_EXT/dist-petsc/version_petsc.txt +cp -r petscpy $IDAES_EXT/dist/lib/ +# Return to root directory +cd $IDAES_EXT if [ ${osname} = "darwin" ]; then echo "#########################################################################" echo "# macOS update rpaths #" echo "#########################################################################" - cd $IDAES_EXT/dist-solvers update_rpath_darwin() { install_name_tool -change ${BREWLIB}libgfortran.5.dylib @rpath/libgfortran.5.dylib $1 install_name_tool -change ${BREWLIB}libgcc_s.1.1.dylib @rpath/libgcc_s.1.1.dylib $1 @@ -512,51 +517,36 @@ if [ ${osname} = "darwin" ]; then update_library_rpath_darwin() { install_name_tool -id @rpath/$1 $1 } - update_rpath_darwin ipopt - update_rpath_darwin ipopt_sens - update_rpath_darwin clp - update_rpath_darwin cbc - update_rpath_darwin bonmin - update_rpath_darwin couenne - update_rpath_darwin ipopt_l1 - update_rpath_darwin ipopt_sens_l1 - update_rpath_darwin libipopt.dylib - update_rpath_darwin libsipopt.dylib - update_rpath_darwin libipopt.3.dylib - update_rpath_darwin libsipopt.3.dylib - update_rpath_darwin libpynumero_ASL.dylib - update_library_rpath_darwin libipopt.dylib - update_library_rpath_darwin libsipopt.dylib - update_library_rpath_darwin libipopt.3.dylib - update_library_rpath_darwin libsipopt.3.dylib - update_library_rpath_darwin libpynumero_ASL.dylib + update_rpath_darwin dist/bin/ipopt + update_rpath_darwin dist/bin/ipopt_sens + update_rpath_darwin dist/bin/clp + update_rpath_darwin dist/bin/cbc + update_rpath_darwin dist/bin/bonmin + update_rpath_darwin dist/bin/couenne + update_rpath_darwin dist/bin/ipopt_l1 + update_rpath_darwin dist/bin/ipopt_sens_l1 + update_rpath_darwin dist/lib/libipopt.dylib + update_rpath_darwin dist/lib/libsipopt.dylib + update_rpath_darwin dist/lib/libipopt.3.dylib + update_rpath_darwin dist/lib/libsipopt.3.dylib + update_rpath_darwin dist/lib/libpynumero_ASL.dylib + update_library_rpath_darwin dist/lib/libipopt.dylib + update_library_rpath_darwin dist/lib/libsipopt.dylib + update_library_rpath_darwin dist/lib/libipopt.3.dylib + update_library_rpath_darwin dist/lib/libsipopt.3.dylib + update_library_rpath_darwin dist/lib/libpynumero_ASL.dylib # if no hsl k_aug and dot_snse won't exist - update_rpath_darwin k_aug || true - update_rpath_darwin dot_sens || true - cd $IDAES_EXT/dist-petsc - update_rpath_darwin petsc - # Update rpaths in dist-share/lib - cd $IDAES_EXT/dist-share/lib - update_rpath_darwin libipopt.dylib - update_rpath_darwin libsipopt.dylib - update_rpath_darwin libipopt.3.dylib - update_rpath_darwin libsipopt.3.dylib - update_library_rpath_darwin libipopt.dylib - update_library_rpath_darwin libsipopt.dylib - update_library_rpath_darwin libipopt.3.dylib - update_library_rpath_darwin libsipopt.3.dylib + update_rpath_darwin dist/bin/k_aug || true + update_rpath_darwin dist/bin/dot_sens || true + update_rpath_darwin dist/bin/petsc fi # here you pack files echo "#########################################################################" echo "# Finish #" echo "#########################################################################" -cd $IDAES_EXT/dist-petsc -tar -czvf idaes-petsc-${osname}-${MNAME}.tar.gz * -cd $IDAES_EXT/dist-share -tar -czvf idaes-local-${osname}-${MNAME}.tar.gz * -cd $IDAES_EXT/dist-solvers -cp ../dist-share/idaes-local-${osname}-${MNAME}.tar.gz ./ -tar -czvf idaes-solvers-${osname}-${MNAME}.tar.gz * +cd dist +tar -czvf idaes-extensions-${osname}-${MNAME}.tar.gz * +cd $IDAES_EXT echo "Done" echo "HSL Present: ${with_hsl}" From 35b1bf1bb10388d0daa58a6dec15dd013559cf36 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Fri, 6 Oct 2023 19:03:06 -0600 Subject: [PATCH 05/16] pack function libraries in the lib directory of an idaes-functions tar file --- scripts/compile_libs.sh | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/scripts/compile_libs.sh b/scripts/compile_libs.sh index 16c500b6..b96a00b7 100644 --- a/scripts/compile_libs.sh +++ b/scripts/compile_libs.sh @@ -31,29 +31,31 @@ cd $IDAES_EXT # Collect files rm -rf ./dist-lib -mkdir dist-lib -cd dist-lib -cp ../src/dist/*.so ./ +mkdir dist-lib dist-lib/lib +#cd dist-lib +cp ./src/dist/*.so ./dist-lib/lib/ if [ ${osname} = "windows" ]; then - mv functions.so functions.dll - mv general_helmholtz_external.so general_helmholtz_external.dll - mv cubic_roots.so cubic_roots.dll + mv dist-lib/lib/functions.so dist-lib/lib/functions.dll + mv dist-lib/lib/general_helmholtz_external.so dist-lib/lib/general_helmholtz_external.dll + mv dist-lib/lib/cubic_roots.so dist-lib/lib/cubic_roots.dll fi if [ ${osname} = "darwin" ]; then - mv functions.so functions.dylib - mv general_helmholtz_external.so general_helmholtz_external.dylib - mv cubic_roots.so cubic_roots.dylib + mv dist-lib/lib/functions.so dist-lib/lib/functions.dylib + mv dist-lib/lib/general_helmholtz_external.so dist-lib/lib/general_helmholtz_external.dylib + mv dist-lib/lib/cubic_roots.so dist-lib/lib/cubic_roots.dylib fi -cp ../license.txt ./license_lib.txt -cp ../version.txt ./version_lib.txt -mkdir ./helm_data -cp ../src/dist/param_data/*.json ./helm_data/ -cp ../src/dist/param_data/*.nl ./helm_data/ -cp ../src/dist/param_data/*.py ./helm_data/ -sed s/"(DATE)"/`date +%Y%m%d-%H%M`/g version_lib.txt > tmp +cp ./license.txt ./dist-lib/license_lib.txt +cp ./version.txt ./dist-lib/version_lib.txt +mkdir ./dist-lib/lib/helm_data +cp ./src/dist/param_data/*.json ./dist-lib/lib/helm_data/ +cp ./src/dist/param_data/*.nl ./dist-lib/lib/helm_data/ +cp ./src/dist/param_data/*.py ./dist-lib/lib/helm_data/ +sed s/"(DATE)"/`date +%Y%m%d-%H%M`/g dist-lib/version_lib.txt > tmp sed s/"(PLAT)"/${osname}-${MNAME}/g tmp > tmp2 -mv tmp2 version_lib.txt +mv tmp2 dist-lib/version_lib.txt rm tmp # here you pack files -tar -czvf idaes-lib-${osname}-${MNAME}.tar.gz * +cd dist-lib +tar -czvf idaes-functions-${osname}-${MNAME}.tar.gz * +cd $IDAES_EXT From d383768e91b8630d38350dd07d2dfbfc58fc1f73 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Fri, 6 Oct 2023 19:03:32 -0600 Subject: [PATCH 06/16] change name of solvers tar file to idaes-solvers-* --- scripts/compile_solvers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/compile_solvers.sh b/scripts/compile_solvers.sh index 28d358a1..5366724c 100755 --- a/scripts/compile_solvers.sh +++ b/scripts/compile_solvers.sh @@ -546,7 +546,7 @@ echo "#########################################################################" echo "# Finish #" echo "#########################################################################" cd dist -tar -czvf idaes-extensions-${osname}-${MNAME}.tar.gz * +tar -czvf idaes-solvers-${osname}-${MNAME}.tar.gz * cd $IDAES_EXT echo "Done" echo "HSL Present: ${with_hsl}" From 44a82154edac757ee381cba3530f5ebd9a1123aa Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Fri, 6 Oct 2023 19:18:44 -0600 Subject: [PATCH 07/16] update mac_collect for new tar file names --- scripts/mac_collect.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/mac_collect.sh b/scripts/mac_collect.sh index afee5816..8dae3c58 100644 --- a/scripts/mac_collect.sh +++ b/scripts/mac_collect.sh @@ -1,3 +1,2 @@ mv ./dist-solvers/idaes-solvers-darwin-arm64.tar.gz ./idaes-solvers-darwin-aarch64.tar.gz -mv ./dist-lib/idaes-lib-darwin-arm64.tar.gz ./idaes-lib-darwin-aarch64.tar.gz -mv ./dist-petsc/idaes-petsc-darwin-arm64.tar.gz ./idaes-petsc-darwin-aarch64.tar.gz +mv ./dist-lib/idaes-functions-darwin-arm64.tar.gz ./idaes-lib-darwin-aarch64.tar.gz From c4d8cd8c45acbfd28c111677e8ca26c335717341 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Fri, 6 Oct 2023 19:19:52 -0600 Subject: [PATCH 08/16] change temp directory name from dist-lib to dist-functions --- scripts/compile_libs.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/compile_libs.sh b/scripts/compile_libs.sh index b96a00b7..a3f6debe 100644 --- a/scripts/compile_libs.sh +++ b/scripts/compile_libs.sh @@ -30,32 +30,32 @@ make cd $IDAES_EXT # Collect files -rm -rf ./dist-lib -mkdir dist-lib dist-lib/lib -#cd dist-lib -cp ./src/dist/*.so ./dist-lib/lib/ +rm -rf ./dist-functions +mkdir dist-functions dist-functions/lib +#cd dist-functions +cp ./src/dist/*.so ./dist-functions/lib/ if [ ${osname} = "windows" ]; then - mv dist-lib/lib/functions.so dist-lib/lib/functions.dll - mv dist-lib/lib/general_helmholtz_external.so dist-lib/lib/general_helmholtz_external.dll - mv dist-lib/lib/cubic_roots.so dist-lib/lib/cubic_roots.dll + mv dist-functions/lib/functions.so dist-functions/lib/functions.dll + mv dist-functions/lib/general_helmholtz_external.so dist-functions/lib/general_helmholtz_external.dll + mv dist-functions/lib/cubic_roots.so dist-functions/lib/cubic_roots.dll fi if [ ${osname} = "darwin" ]; then - mv dist-lib/lib/functions.so dist-lib/lib/functions.dylib - mv dist-lib/lib/general_helmholtz_external.so dist-lib/lib/general_helmholtz_external.dylib - mv dist-lib/lib/cubic_roots.so dist-lib/lib/cubic_roots.dylib + mv dist-functions/lib/functions.so dist-functions/lib/functions.dylib + mv dist-functions/lib/general_helmholtz_external.so dist-functions/lib/general_helmholtz_external.dylib + mv dist-functions/lib/cubic_roots.so dist-functions/lib/cubic_roots.dylib fi -cp ./license.txt ./dist-lib/license_lib.txt -cp ./version.txt ./dist-lib/version_lib.txt -mkdir ./dist-lib/lib/helm_data -cp ./src/dist/param_data/*.json ./dist-lib/lib/helm_data/ -cp ./src/dist/param_data/*.nl ./dist-lib/lib/helm_data/ -cp ./src/dist/param_data/*.py ./dist-lib/lib/helm_data/ -sed s/"(DATE)"/`date +%Y%m%d-%H%M`/g dist-lib/version_lib.txt > tmp +cp ./license.txt ./dist-functions/license_lib.txt +cp ./version.txt ./dist-functions/version_lib.txt +mkdir ./dist-functions/lib/helm_data +cp ./src/dist/param_data/*.json ./dist-functions/lib/helm_data/ +cp ./src/dist/param_data/*.nl ./dist-functions/lib/helm_data/ +cp ./src/dist/param_data/*.py ./dist-functions/lib/helm_data/ +sed s/"(DATE)"/`date +%Y%m%d-%H%M`/g dist-functions/version_lib.txt > tmp sed s/"(PLAT)"/${osname}-${MNAME}/g tmp > tmp2 -mv tmp2 dist-lib/version_lib.txt +mv tmp2 dist-functions/version_lib.txt rm tmp # here you pack files -cd dist-lib +cd dist-functions tar -czvf idaes-functions-${osname}-${MNAME}.tar.gz * cd $IDAES_EXT From d55d9a0688b7f62cd9d134130d7b542b5e7daf38 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Fri, 6 Oct 2023 19:21:28 -0600 Subject: [PATCH 09/16] update mac_collect --- scripts/mac_collect.sh | 4 ++-- scripts/mac_collect_x86_64.sh | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/mac_collect.sh b/scripts/mac_collect.sh index 8dae3c58..95883701 100644 --- a/scripts/mac_collect.sh +++ b/scripts/mac_collect.sh @@ -1,2 +1,2 @@ -mv ./dist-solvers/idaes-solvers-darwin-arm64.tar.gz ./idaes-solvers-darwin-aarch64.tar.gz -mv ./dist-lib/idaes-functions-darwin-arm64.tar.gz ./idaes-lib-darwin-aarch64.tar.gz +mv ./dist/idaes-solvers-darwin-arm64.tar.gz ./idaes-solvers-darwin-aarch64.tar.gz +mv ./dist-functions/idaes-functions-darwin-arm64.tar.gz ./idaes-functions-darwin-aarch64.tar.gz diff --git a/scripts/mac_collect_x86_64.sh b/scripts/mac_collect_x86_64.sh index b56ef773..fbebc25d 100644 --- a/scripts/mac_collect_x86_64.sh +++ b/scripts/mac_collect_x86_64.sh @@ -1,3 +1,2 @@ -mv ./dist-solvers/idaes-solvers-darwin-x86_64.tar.gz ./idaes-solvers-darwin-x86_64.tar.gz -mv ./dist-lib/idaes-lib-darwin-x86_64.tar.gz ./idaes-lib-darwin-x86_64.tar.gz -mv ./dist-petsc/idaes-petsc-darwin-x86_64.tar.gz ./idaes-petsc-darwin-x86_64.tar.gz +mv ./dist/idaes-solvers-darwin-x86_64.tar.gz ./idaes-solvers-darwin-x86_64.tar.gz +mv ./dist-functions/idaes-functions-darwin-x86_64.tar.gz ./idaes-functions-darwin-x86_64.tar.gz From faf50057555bd31da24a80072b95a58ddb6a47e8 Mon Sep 17 00:00:00 2001 From: Robert Parker <robbybparker@gmail.com> Date: Tue, 31 Oct 2023 12:09:36 -0600 Subject: [PATCH 10/16] update locations and names of .tar.gz files --- docker/build-extensions/build.ps1 | 10 ++-------- docker/build-extensions/build.sh | 5 ++--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/docker/build-extensions/build.ps1 b/docker/build-extensions/build.ps1 index c5822114..e43ddc3b 100644 --- a/docker/build-extensions/build.ps1 +++ b/docker/build-extensions/build.ps1 @@ -35,19 +35,13 @@ docker build --rm ${buildarg_1} --build-arg repo=${repo} --build-arg branch=${br Remove-Item extras -Recurse -Force -Confirm:$false docker run --name ${flavor}_build_tmp -dt ${flavor}_build_itmp:latest docker stop ${flavor}_build_tmp -docker cp ${flavor}_build_tmp:${wdir}/idaes-ext/dist-lib/idaes-lib-${flavor}-${mname}.tar.gz . +docker cp ${flavor}_build_tmp:${wdir}/idaes-ext/dist-functions/idaes-functions-${flavor}-${mname}.tar.gz . try{ - docker cp ${flavor}_build_tmp:${wdir}/idaes-ext/dist-solvers/idaes-solvers-${flavor}-${mname}.tar.gz . + docker cp ${flavor}_build_tmp:${wdir}/idaes-ext/dist/idaes-solvers-${flavor}-${mname}.tar.gz . } catch{ echo "Solvers were not built." } -try{ - docker cp ${flavor}_build_tmp:${wdir}/idaes-ext/dist-petsc/idaes-petsc-${flavor}-${mname}.tar.gz . -} -catch{ - echo "PETSc was not built." -} docker rm ${flavor}_build_tmp docker rmi ${flavor}_build_itmp cp *.tar.gz ../tarballs/ diff --git a/docker/build-extensions/build.sh b/docker/build-extensions/build.sh index 2b022086..f204123f 100644 --- a/docker/build-extensions/build.sh +++ b/docker/build-extensions/build.sh @@ -37,9 +37,8 @@ docker exec "$flavor"_"$mname"_build_tmp sh -c "cd ${wdir}/idaes-ext && bash scr docker exec "$flavor"_"$mname"_build_tmp sh -c "cd ${wdir}/idaes-ext && bash scripts/compile_libs.sh ${flavor}" docker stop "$flavor"_"$mname"_build_tmp -docker cp "$flavor"_"$mname"_build_tmp:"$wdir"/idaes-ext/dist-lib/idaes-lib-"$flavor"-"$mname".tar.gz . -docker cp "$flavor"_"$mname"_build_tmp:"$wdir"/idaes-ext/dist-solvers/idaes-solvers-"$flavor"-"$mname".tar.gz . -docker cp "$flavor"_"$mname"_build_tmp:"$wdir"/idaes-ext/dist-petsc/idaes-petsc-"$flavor"-"$mname".tar.gz . +docker cp "$flavor"_"$mname"_build_tmp:"$wdir"/idaes-ext/dist-functions/idaes-functions-"$flavor"-"$mname".tar.gz . +docker cp "$flavor"_"$mname"_build_tmp:"$wdir"/idaes-ext/dist/idaes-solvers-"$flavor"-"$mname".tar.gz . docker rm "$flavor"_"$mname"_build_tmp From 0b3cacb5bb915b1be876c5f7d70e19dded47772b Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Sun, 3 Dec 2023 14:37:48 -0700 Subject: [PATCH 11/16] update docker driver script to accept arguments for repo and branch --- docker/build-extensions/build.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) mode change 100644 => 100755 docker/build-extensions/build.sh diff --git a/docker/build-extensions/build.sh b/docker/build-extensions/build.sh old mode 100644 new mode 100755 index f204123f..4a62bdfe --- a/docker/build-extensions/build.sh +++ b/docker/build-extensions/build.sh @@ -1,8 +1,21 @@ flavor=$1 mname=$2 -repo="https://github.com/idaes/idaes-ext.git" -branch="main" +repo=$3 +branch=$4 +if [ ! "$repo" ]; then + repo="https://github.com/idaes/idaes-ext.git" +fi +if [ ! "$branch" ]; then + branch="main" +fi + +echo "build.sh script arguments: + OS: $flavor + Arch: $mname + Repo: $repo + Branch: $branch +" if [ "$flavor" = "windows" ]; then image="idaes-ext-windows-build:latest" From ec2d6acabe6a2e6ab74c5659a32cbb813cfcdac9 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Wed, 6 Dec 2023 12:18:36 -0700 Subject: [PATCH 12/16] accept arguments for repo and branch in build.ps1 --- docker/build-extensions/build.ps1 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/docker/build-extensions/build.ps1 b/docker/build-extensions/build.ps1 index e43ddc3b..5c9176dd 100644 --- a/docker/build-extensions/build.ps1 +++ b/docker/build-extensions/build.ps1 @@ -1,8 +1,19 @@ $flavor = $args[0] $buildarg_1 = $args[1] # just use this to pass in --no-cache or some such -$repo = "https://github.com/idaes/idaes-ext.git" -$branch = "main" +# The 3rd and 4th arguments provided will be interpreted as repo and branch. +# (If you don't want to use buildarg_1, just pass in an empty string.) +$repo = $args[2] +$branch = $args[3] + +# If repo and branch are not provided, use default values +IF ($repo -eq $null){ + $repo = "https://github.com/idaes/idaes-ext.git" +} +IF ($branch -eq $null){ + $branch = "main" +} + $mname = "x86_64" IF ($flavor -eq "windows"){ From 7228be4fe8a9563a039cec86e64515c1ca18752d Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Thu, 7 Dec 2023 20:03:05 -0700 Subject: [PATCH 13/16] update doc/build.md --- doc/build.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/build.md b/doc/build.md index b5df6281..87317ef0 100644 --- a/doc/build.md +++ b/doc/build.md @@ -114,6 +114,26 @@ Test on clean VM for now, hopfully GitHub actions runners will be available soon There is a GitHub actions test. +## Testing a non-default branch + +By default, the Docker driver scripts (`docker/build.sh` and `docker\build.ps1`) +checkout the `main` branch of `https://github.com/idaes/idaes-ext.git` to use +for the build process. To test a different branch, arguments can be provided +to the Docker driver scripts. For example, to test the `ubuntu2204` build with +a custom branch called `mybranch` on `user`'s fork, run +```bash +./build.sh ubuntu2204 https://github.com/user/idaes-ext.git mybranch +``` +To test the Windows build, run +```powershell +.\build.ps1 windows --no-cache https://github.com/user/idaes-ext.git mybranch +``` +Note that the second argument to `build.ps1` is interpreted as an argument +to `docker build`, so to run with a custom branch and no such argument, run +```powershell +.\build.ps1 windows https://github.com/user/idaes-ext.git mybranch +``` + ## Release Hashes Collect all the tar files for a release in the same directory. From 5f933ba294efeabe1e9feff776668386d084943c Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Thu, 14 Dec 2023 14:57:29 -0700 Subject: [PATCH 14/16] only set PETSC_DIR if it is not already set --- scripts/compile_solvers.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/compile_solvers.sh b/scripts/compile_solvers.sh index 5366724c..3a3caa50 100755 --- a/scripts/compile_solvers.sh +++ b/scripts/compile_solvers.sh @@ -41,13 +41,19 @@ export CC="gcc" export CXX="g++" # set PETSc location -if [ ${osname} = "windows" ] -then - export PETSC_DIR=/c/repo/petsc-dist -elif [ ${osname} = "darwin" ]; then - export PETSC_DIR="$HOME/src/petsc-dist" -else - export PETSC_DIR=/repo/petsc-dist +# These petsc environment variables are used by the makefile +# in the $IDAES_EXT/petsc subdirectory. +if [ -z $PETSC_DIR ]; then + # We only set PETSC_DIR if it is not already set. This is useful when + # running this script locally (i.e. not via Docker) + if [ ${osname} = "windows" ] + then + export PETSC_DIR=/c/repo/petsc-dist + elif [ ${osname} = "darwin" ]; then + export PETSC_DIR="$HOME/src/petsc-dist" + else + export PETSC_DIR=/repo/petsc-dist + fi fi export PETSC_ARCH="" From 4bcd45f64b45bfa3fa3d365126ebd780b2fd1430 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Thu, 14 Dec 2023 15:43:30 -0700 Subject: [PATCH 15/16] document some gotchas for local build process --- doc/build-local.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 doc/build-local.md diff --git a/doc/build-local.md b/doc/build-local.md new file mode 100644 index 00000000..16acbe47 --- /dev/null +++ b/doc/build-local.md @@ -0,0 +1,36 @@ +# Building IDAES binaries locally + +For testing purposes, it may be useful to build the binaries locally, i.e. not +using the Docker build scripts. This is also necessary for the MacOS builds +(see the MacOS section in `build.md` for more information). + +You can build locally by running the following scripts: + +- `scripts/compile_solvers.sh`: Compile solvers (including `k_aug`, `dot_sens`, +`petsc`, and all solver-associated libraries). +- `scripts/compile_libs.sh`: Compile shared libraries for external functions. + +It is recommended to perform an "out-of-source" build. This can be done by +first running `scripts/build_directory.sh _build` from the top level of this +repository. This copies source code, makefiles, patch files, and build scripts +into the `_build` directory, where you will actually run the build. +Move into the build directory with `cd _build`. + +The build scripts were not designed for local use, so there are a few gotchas: + +- We look for patch files in a specific location relative to the original +working directory. I.e. you must run `compile_solvers.sh` from *one level above* +the scripts directory in order for patches (e.g. `ipopt.pc.patch`) to be +correctly applied. +- `ipopt.pc.patch` assumes that `coinmumps` and `coinhsl` are listed as +dependencies in the `ipopt.pc` file. If either is not found (i.e. we are +compiling without HSL), the patch application will fail. +- By default, Petsc is assumed to be installed in hard-coded, OS-dependent +location. If you are compiling locally, you have probably installed it +in your own preferred location. To override the default, set the `PETSC_DIR` +environment variable to the location where you have installed Petsc. +- If you have your own system-installed HSL libraries that are discoverable +by the linker (i.e. `LD_LIBRARY_PATH` is set), the COIN-OR solvers will likely +be able to find and link against them. In this case, you will see a +`HSL Present: NO` message (as there was no `coinhsl.zip` in the parent of the +working directory), but will likely still build HSL-enabled solvers. From 5013cc954c8728ed25bc30babe1b417f29fd0665 Mon Sep 17 00:00:00 2001 From: robbybp <robbybparker@gmail.com> Date: Thu, 14 Dec 2023 16:16:39 -0700 Subject: [PATCH 16/16] notify user if default PETSC_DIR is being used --- scripts/compile_solvers.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/compile_solvers.sh b/scripts/compile_solvers.sh index 3a3caa50..10e1c6e3 100755 --- a/scripts/compile_solvers.sh +++ b/scripts/compile_solvers.sh @@ -54,6 +54,8 @@ if [ -z $PETSC_DIR ]; then else export PETSC_DIR=/repo/petsc-dist fi + echo "PETSC_DIR has been set to $PETSC_DIR. If this is incorrect, set" + echo "the PETSC_DIR environment variable before running this script." fi export PETSC_ARCH=""