Skip to content

Commit e4d9ff5

Browse files
committed
adding in envs to reference installed gems from the installer
1 parent 793bc20 commit e4d9ff5

5 files changed

Lines changed: 45 additions & 0 deletions

File tree

lib/uo_cli.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,22 @@ def self.create_project_folder(dir_name, empty_folder: false, overwrite_project:
648648
FileUtils.cp(example_files_dir / 'runner.conf', project_path)
649649
use_num_parallel(project_path)
650650

651+
# if env variable for gemfile_path and bundle_install_path is set, open the runner.conf
652+
# and update the gemfile_path and bundle_install_path values
653+
if ENV['UO_GEMFILE_PATH'] || ENV['UO_BUNDLE_INSTALL_PATH']
654+
runner_file_path = project_path / 'runner.conf'
655+
runner_conf_hash = JSON.parse(File.read(runner_file_path))
656+
if ENV['UO_GEMFILE_PATH']
657+
runner_conf_hash['gemfile_path'] = ENV['UO_GEMFILE_PATH']
658+
end
659+
if ENV['UO_BUNDLE_INSTALL_PATH']
660+
runner_conf_hash['bundle_install_path'] = ENV['UO_BUNDLE_INSTALL_PATH']
661+
end
662+
File.open(runner_file_path, 'w+') do |f|
663+
f << runner_conf_hash.to_json
664+
end
665+
end
666+
651667
# copy gemfile
652668
FileUtils.cp(example_files_dir / 'Gemfile', project_path)
653669

@@ -837,6 +853,22 @@ def self.update_project(existing_project_folder, new_project_directory)
837853
FileUtils.cp_r(example_files_dir / 'runner.conf', new_path, remove_destination: true)
838854
use_num_parallel(new_path)
839855

856+
# if env variable for gemfile_path and bundle_install_path is set, open the runner.conf
857+
# and update the gemfile_path and bundle_install_path values
858+
if ENV['UO_GEMFILE_PATH'] || ENV['UO_BUNDLE_INSTALL_PATH']
859+
runner_file_path = project_path / 'runner.conf'
860+
runner_conf_hash = JSON.parse(File.read(runner_file_path))
861+
if ENV['UO_GEMFILE_PATH']
862+
runner_conf_hash['gemfile_path'] = ENV['UO_GEMFILE_PATH']
863+
end
864+
if ENV['UO_BUNDLE_INSTALL_PATH']
865+
runner_conf_hash['bundle_install_path'] = ENV['UO_BUNDLE_INSTALL_PATH']
866+
end
867+
File.open(runner_file_path, 'w+') do |f|
868+
f << runner_conf_hash.to_json
869+
end
870+
end
871+
840872
# Replace standard mappers
841873
# FIXME: this also copies createBar and Floorspace without checking project type (for now)
842874
mappers = example_files_dir / 'mappers'

scripts/setup-env-gitbash.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ UO_DIR_NAME=$(basename "$BASE_DIR_NAME")
1313

1414
GEM_HOME=${BASE_DIR_NAME}/gems/ruby/${RUBY_BASE_VERSION}
1515
GEM_PATH=${BASE_DIR_NAME}/gems/ruby/${RUBY_BASE_VERSION}
16+
GEMFILE_PATH=${BASE_DIR_NAME}/gems/Gemfile
17+
BUNDLE_INSTALL_PATH=${BASE_DIR_NAME}/gems
1618
PATH=${BASE_DIR_NAME}/ruby/bin:${BASE_DIR_NAME}/gems/ruby/${RUBY_BASE_VERSION}/bin:${BASE_DIR_NAME}/gems/ruby/${RUBY_BASE_VERSION}/gems/${UO_DIR_NAME}/example_files/python_deps/Miniconda-${MINICONDA_VERSION}/bin:$PATH
1719
RUBYLIB=${BASE_DIR_NAME}/OpenStudio/Ruby
1820
RUBY_DLL_PATH=${BASE_DIR_NAME}/OpenStudio/Ruby
1921

22+
2023
#Remove if exists
2124
if [ -f ~/.env_uo.sh ]; then
2225
rm ~/.env_uo.sh

scripts/setup-env-unix.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ UO_DIR_NAME=$(basename "$UO_DIR")
1212

1313
GEM_HOME=${UO_DIR}/gems/ruby/${RUBY_BASE_VERSION}
1414
GEM_PATH=${UO_DIR}/gems/ruby/${RUBY_BASE_VERSION}
15+
GEMFILE_PATH=${UO_DIR}/gems/Gemfile
16+
BUNDLE_INSTALL_PATH=${UO_DIR}/gems
1517
PATH=${UO_DIR}/ruby/bin:${UO_DIR}/gems/ruby/${RUBY_BASE_VERSION}/bin:${UO_DIR}/gems/ruby/${RUBY_BASE_VERSION}/gems/${UO_DIR_NAME}/example_files/python_deps/Miniconda-${MINICONDA_VERSION}/bin:$PATH
1618
RUBYLIB=${UO_DIR}/OpenStudio/Ruby
1719
RUBY_DLL_PATH=${UO_DIR}/OpenStudio/Ruby

scripts/setup-env.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ SET BASE_DIR_NAME=%~d0%~p0
77

88
SET GEM_HOME=%BASE_DIR_NAME%\gems\ruby\%RUBY_BASE_VERSION%
99
SET GEM_PATH=%BASE_DIR_NAME%\gems\ruby\%RUBY_BASE_VERSION%
10+
SET GEMFILE_PATH=%UO_DIR%\gems\Gemfile
11+
SET BUNDLE_INSTALL_PATH=%UO_DIR%\gems
1012
SET PATH=%BASE_DIR_NAME%\ruby\bin;%BASE_DIR_NAME%\gems\ruby\%RUBY_BASE_VERSION%\bin;%PATH%
1113
SET RUBYLIB=%BASE_DIR_NAME%\OpenStudio\Ruby
1214
SET RUBY_DLL_PATH=%BASE_DIR_NAME%\OpenStudio\Ruby

scripts/setup-env.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ $BASE_DIR_NAME = $PSScriptRoot
2525

2626
$GEM_HOME = "$BASE_DIR_NAME\gems\ruby\$RUBY_BASE_VERSION"
2727
$GEM_PATH = "$BASE_DIR_NAME\gems\ruby\$RUBY_BASE_VERSION"
28+
$GEMFILE_PATH = "$UO_DIR\gems\Gemfile"
29+
$BUNDLE_INSTALL_PATH = "$UO_DIR\gems"
2830
$PATH += ";$BASE_DIR_NAME\ruby\bin;$BASE_DIR_NAME\gems\ruby\$RUBY_BASE_VERSION\bin;$RUBY_PYTHON_PATH;$env::PATH"
2931
$RUBYLIB = "$BASE_DIR_NAME\OpenStudio\Ruby"
3032
$RUBY_DLL_PATH = "$BASE_DIR_NAME\OpenStudio\Ruby"
@@ -35,13 +37,17 @@ Remove-Item $HOME/.env_uo.bat -ErrorAction Ignore
3537

3638
'$env:GEM_HOME = "' + $GEM_HOME + '"' >> $HOME/.env_uo.ps1
3739
'$env:GEM_PATH = "' + $GEM_PATH + '"' >> $HOME/.env_uo.ps1
40+
'$env:GEMFILE_PATH = "' + $GEMFILE_PATH + '"' >> $HOME/.env_uo.ps1
41+
'$env:BUNDLE_INSTALL_PATH = "' + $BUNDLE_INSTALL_PATH + '"' >> $HOME/.env_uo.ps1
3842
'$env:PATH = "' + $PATH + '"' >> $HOME/.env_uo.ps1
3943
'$env:RUBYLIB = "' + $RUBYLIB + '"' >> $HOME/.env_uo.ps1
4044
'$env:RUBY_DLL_PATH = "' + $RUBY_DLL_PATH + '"' >> $HOME/.env_uo.ps1
4145

4246
'' >> $HOME/.env_uo.bat
4347
'SET "GEM_HOME=' + $GEM_HOME + '"' >> $HOME/.env_uo.bat
4448
'SET "GEM_PATH=' + $GEM_PATH + '"' >> $HOME/.env_uo.bat
49+
'SET "GEMFILE_PATH=' + $GEMFILE_PATH + '"' >> $HOME/.env_uo.bat
50+
'SET "BUNDLE_INSTALL_PATH=' + $BUNDLE_INSTALL_PATH + '"' >> $HOME/.env_uo.bat
4551
'SET "PATH=' + $PATH + '"' >> $HOME/.env_uo.bat
4652
'SET "RUBYLIB=' + $RUBYLIB + '"' >> $HOME/.env_uo.bat
4753
'SET "RUBY_DLL_PATH=' + $RUBY_DLL_PATH + '"' >> $HOME/.env_uo.bat

0 commit comments

Comments
 (0)