Skip to content

Commit

Permalink
simplified FORCE build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
j-bryan committed Sep 30, 2024
1 parent ea7f999 commit 4e540fd
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 286 deletions.
Binary file removed package/FORCE.icns
Binary file not shown.
72 changes: 55 additions & 17 deletions package/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,66 @@
# FORCE One-Step Installer Creation
FORCE one-step installers are created using the `cx_Freeze` python package after creating a python environment using either `venv` or `conda`.
A computer with the same operating system and architecture as the target operating system must be used to generate an installer, i.e. use a Windows machine to generate a Windows installer, a Mac (Intel) to generate a Mac installer, etc.
Note that installers generated with Apple computers with M-series chips will not be backwards compatible with Intel-based Apple computers.

Creating package way 1:
Windows and macOS are the only operating systems currently supported.
Linux users are encouraged to use pip-installed or source built versions of the RAVEN, HERON, and TEAL software packages.

python3.10 -m venv test310
source test310/bin/activate
pip install cx_Freeze
pip install raven-framework teal-ravenframework heron-ravenframework
## 1. Build FORCE executables
Create a conda environment `force_build_310`, install the RAVEN, HERON, and TEAL pip packages, and build the FORCE executables using the script
```console
./build_force.sh
```

## 2. Add IPOPT to build directory (Windows only)
Download the IPOPT Windows binary:
https://github.com/coin-or/Ipopt/releases

python setup.py install_exe --install-dir raven_install
Extract the downloaded zip directory and copy its contents to the raven_install directory, ensuring to replace the version numbers of IPOPT as needed.
```console
cd force_install
unzip ~/Downloads/Ipopt-3.14.12-win64-msvs2019-md.zip
mv Ipopt-3.14.12-win64-msvs2019-md local
cd ..
```

## 3. Copy examples and build/copy the RAVEN, HERON, and TEAL documentation
Adding examples and documentation to the one-step installer requires having the source installation present on the build machine, with the `raven_libraries` conda environment already created.
```console
conda activate raven_libraries
./copy_examples.sh --raven-dir /path/to/raven --heron-dir /path/to/HERON
cp -R examples force_install/examples
./make_docs.sh --raven-dir /path/to/raven --heron-dir /path/to/HERON --teal-dir /path/to/TEAL
cp -R docs force_install/docs
```
When running the `make_docs.sh` script, the optional `--no-build` flag may be added if the desired documentation PDFs have already been built, and you do not wish to rebuild the documents.

Way 2:
## 4. Get NEAMS Workbench installer
The installers for the NEAMS Workbench software can be found here:
https://code.ornl.gov/neams-workbench/downloads/-/tree/5.4.1?ref_type=heads

conda create -n test39 python=3.9
conda activate test39
Download `Workbench-5.4.1.exe` for Windows and `Workbench-5.4.1.dmg` for macOS.
Place this file in the current directory.

pip install cx_Freeze
pip install raven-framework teal-ravenframework heron-ravenframework
Windows:
```console
cp ~/Downloads/Workbench-5.4.1.exe .
```

python setup.py install_exe --install-dir raven_install
macOS:
```console
cp ~/Downloads/Workbench-5.4.1.dmg .
```

ipopt work:

cd raven_install
unzip ~/Downloads/Ipopt-3.14.12-win64-msvs2019-md.zip
mv Ipopt-3.14.12-win64-msvs2019-md local
## 5. Create the installer
### Windows
The Windows installer is created using Inno Setup.
Run the `inno_package.iss` script from the Inno Setup application.
The resulting .exe installer file can be found in the `inno_output` directory.

### macOS
Run the macOS build script
```console
./build_mac_app.sh
```
The disk image `FORCE.dmg` contains applications for both FORCE and Workbench.
141 changes: 0 additions & 141 deletions package/build_force

This file was deleted.

42 changes: 42 additions & 0 deletions package/build_force.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Have users point to the location of their conda installation so we can properly activate the
# conda environment that is being made. Use the "--conda-defs" option to specify this path.
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--conda-defs)
CONDA_DEFS="$2"
shift
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done

# Establish conda environment
conda create -n force_build_310 python=3.10 -y
source $CONDA_DEFS
conda activate force_build_310

# Check that the conda environment is active. If not, exit.
if [[ $CONDA_DEFAULT_ENV != "force_build_310" ]]; then
echo "Conda environment not activated. Maybe the path to the conda installation is incorrect?"
echo "Provided conda path: $CONDA_DEFS"
exit 1
fi

pip install cx_Freeze
pip install raven-framework heron-ravenframework teal-ravenframework
# If on macOS, use conda to install ipopt
if [[ "$OSTYPE" == "darwin"* ]]; then
# Note: The PyPI version of ipopt is not maintained and is severl major version
# behind the conda-forge distribution.
conda install -c conda-forge ipopt -y
fi

# Build the FORCE executables
python setup.py install_exe --install-dir force_install
22 changes: 16 additions & 6 deletions package/build_force_mac.sh → package/build_mac_app.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Freeze the FORCE app using cx_Freeze. We require a suitable python environment to be active.
sh build_force
#!/bin/bash

# Set up the FORCE application bundle
# We'll set up the app so that some FORCE launcher script is the main executable, and the RAVEN,
# HERON, and TEAL executables are in the Resources directory.
# Build the initial app from the force_launcher.scpt AppleScript
osacompile -o FORCE.app force_launcher.scpt
# Now copy over the force_install directory contents to the application's Resources directory
cp -R force_install/* FORCE.app/Contents/Resources/
cp -Rp force_install/* FORCE.app/Contents/Resources/
# Overwrite the app's icon with the FORCE icon
cp FORCE.icns FORCE.app/Contents/Resources/applet.icns
cp icons/FORCE.icns FORCE.app/Contents/Resources/applet.icns

# Create a new disk image
hdiutil create -size 5g -fs HFS+ -volname "FORCE" -o force_build.dmg
Expand All @@ -20,9 +19,20 @@ hdiutil attach force_build.dmg -mountpoint /Volumes/FORCE
# Mount the existing .dmg file file Workbench
hdiutil attach Workbench-5.4.1.dmg -mountpoint /Volumes/Workbench

# Add the workshop tests and data directories to FORCE so that Workbench's autocomplete works for workshop examples
mkdir FORCE.app/Contents/Resources/tests
mkdir FORCE.app/Contents/Resources/examples
cp -Rp examples/workshop FORCE.app/Contents/Resources/tests/
cp -Rp examples/data FORCE.app/Contents/Resources/examples/

# Move the FORCE app to the disk image
cp -R FORCE.app /Volumes/FORCE/
cp -R /Volumes/Workbench/Workbench-5.4.1.app /Volumes/FORCE/
cp -Rp FORCE.app /Volumes/FORCE/
cp -Rp /Volumes/Workbench/Workbench-5.4.1.app /Volumes/FORCE/

# Move the "examples" and "docs" directories from the FORCE app bundle to the top level of the disk
# image to make them more accessible.
cp -Rp examples /Volumes/FORCE/
cp -Rp docs /Volumes/FORCE/

# Move the "examples" and "docs" directories from the FORCE app bundle to the top level of the disk
# image to make them more accessible.
Expand Down
Loading

0 comments on commit 4e540fd

Please sign in to comment.