openstudiocoalition / OpenStudioApplication

The OpenStudio Application is a fully featured graphical interface to OpenStudio models including envelope, loads, schedules, and HVAC.
https://openstudiocoalition.org
Other
137 stars 25 forks source link

Install openstudio to bin directory so it can be found relative to lib #699

Closed macumber closed 8 months ago

macumber commented 8 months ago

Install openstudio to bin directory so it can be found relative to lib, fixes #695

Basically, the openstudio CLI loads the libs from the lib folder, then getOpenStudioCLI looks for the CLI based on the libs paths.

macumber commented 8 months ago

@jmarrec this seems like the best thing to do in the short term. We can try to find a better fix later but the layout in the OpenStudio Application install has to match what getOpenStudioCLI is expecting. My thought was we should add an environment variable that the app could use to pass the path into getOpenStudioCLI. Or just check if the current binary is the openstudio CLI and use that....

macumber commented 8 months ago

@jmarrec I'll go ahead and merge this tomorrow unless you object

jmarrec commented 8 months ago

I don't want to make a copy of the executable. It's big. We should symlink instead.

jmarrec commented 8 months ago

Hum, the CLI is only 3 MB now that it doesn't statically link ruby. That's not too bad.

but I still went ahead (before I realized it was only 3 MB) and tried to make the symlink approach work. The arm64 build failed, not sure if related. My mac needs a Qt upgrade to build and I'm on slow internet, so I'll try again later today once it's installed. If I can make it work under 30 min, I'll do it, otherwise I'll revert back to your changes.

macumber commented 8 months ago

I think the right way to fix this would be to move the content of the lib folder into the Mac bundle, the idea is you can move the bundle around and it still works. However, the Mac bundle doesn't use a bin, lib layout. The important thing is that the openstudio CLI be located relative to the lib files as expected here https://github.com/NREL/OpenStudio/blob/develop/src/utilities/core/ApplicationPathHelpers.cxx.in

jmarrec commented 8 months ago

Tested locally on my mac after installing the dmg:

$ pwd
/Applications/OpenStudioApplication-1.7.0-test/bin
$ ls -la
total 304
drwxr-xr-x   4 julien  admin     128 Mar 27 14:36 .
drwxr-xr-x  20 julien  admin     640 Mar 27 15:20 ..
-rwxr-xr-x   1 julien  admin  152432 Sep 27  2023 install_utility
lrwxr-xr-x   1 julien  admin      46 Mar 27 14:36 openstudio -> ../OpenStudioApp.app/Contents/MacOS/openstudio
$ ./openstudio --version
3.7.0+d5269793f1

Running the test_os_cli from https://github.com/openstudiocoalition/OpenStudioApplication/issues/695#issuecomment-2019863306

Class Name: TestGetOpenStudioCLI
Measure Type: ModelMeasure
Measure Language: Ruby
Current step has 0 arguments
argumentMap={}
Searching for CLI in '/Applications/OpenStudioApplication-1.7.0-test/lib/../openstudio'
Searching for CLI in '/Applications/OpenStudioApplication-1.7.0-test/lib/../bin/openstudio'
Found CLI at '/Applications/OpenStudioApplication-1.7.0-test/OpenStudioApp.app/Contents/MacOS/openstudio'
OpenStudio.getOpenStudioCLI=/Applications/OpenStudioApplication-1.7.0-test/OpenStudioApp.app/Contents/MacOS/openstudio
Step Result: Success
Finished applying OpenStudio Measures.
macumber commented 8 months ago

@jmarrec this works for me, changes to fully self-contain the bundle would be too high risk right now