Skip to content

Commit

Permalink
Fix installer path bug (#485)
Browse files Browse the repository at this point in the history
* remove hard-coded version string from env setup

* correct syntax for creating a variable with PowerShell

* run CI on push, not only on review_requested

* Find the python path if it exists in urbanopt gem directories

* use the powershell to create the bat file for windows command

* remove the bat setup script as this will all be done using the powershell script

* fix unix basename syntax

* ugh dumb copypasta mistake

* update readme installer instructions to match new script fix

---------

Co-authored-by: tijcolem <[email protected]>
  • Loading branch information
vtnate and tijcolem authored Nov 8, 2024
1 parent c8cf58b commit 04239dd
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 50 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/nightly_ci_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ name: CLI CI
on:
workflow_dispatch:
# Run on demand and weeknights
# push:
push:
schedule:
# # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# # 5:24 am UTC (11:24pm MDT the day before) every weekday night in MDT
- cron: '24 5 * * 2-6'
pull_request:
types: [review_requested]

env:
# Favor_Local_Gems enforces develop branch of all Ruby dependencies
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ sudo apt install ./UrbanOptCLI-0.3.1.b6f118d506-Linux.deb

This will install to `/usr/local/` directory.
e.g.
`/usr/local/urbanopt-cli-0.3.1/`
`/usr/local/urbanopt-cli-0.13.0/`

To run the UrbanOpt CLI, first run the `setup-env.sh` script that generates environmental variables and stores these in `env_uo.sh` in your home directory.

```terminal
/usr/local/urbanopt-cli-0.3.1/setup-env.sh
/usr/local/urbanopt-cli-0.13.0/setup-env.sh
. ~/.env_uo.sh
```

Expand All @@ -74,7 +74,7 @@ Use the GUI installer and choose a directory to install. Once installed, open a
The `setup-env.sh` generates env variables and stores them in a file `.env_uo.sh` in your home directory.

```terminal
/Applications/UrbanOptCLI_0.3.1/setup-env.sh
/Applications/UrbanOptCLI_0.13.0/setup-env.sh
. ~/.env_uo.sh
```

Expand All @@ -89,19 +89,19 @@ Use the GUI installer and choose a directory to install. Once installed, open a

#### Bash (or GitBash for Windows)
```terminal
c:/urbanopt-cli-0.3.1/setup-env.sh
c:/urbanopt-cli-0.13.0/setup-env.sh
. ~/.env_uo.sh
```

#### Powershell
#### Powershell or Command Prompt
```terminal
c:\urbanopt-cli-0.3.1\setup-env.ps1
c:\urbanopt-cli-0.13.0\setup-env.ps1
. ~\.env_uo.ps1
```
#### Windows Command Prompt
After the `setup-env.ps1` script has been run:
```terminal
c:\urbanopt-cli-0.3.1\setup-env.bat
%HOMEPATH%\.env_uo.bat
"%HOMEPATH%/.env_uo.bat"
```

When launching new shell terminals run the correct environment config to setup the environment. 
Expand Down
9 changes: 5 additions & 4 deletions scripts/setup-env-gitbash.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/bin/bash
# This is a simple setup script that generates an enviroment file that
# is used to setup the ruby enviroment to run the urbanopt-cli tool.
# This is a simple setup script that generates an environment file that
# is used to setup the ruby environment to run the urbanopt-cli tool.
# To use, just run this script in bash (e.g. ./setup-env.sh)
# Then you can use this env.sh to setup the enviroment.
# Then you can use this env.sh to setup the environment.
# (e.g. source ~/.env_uo.sh)


BASE_DIR_NAME=$(dirname `which $0`)
UO_DIR_NAME=$(basename "$BASE_DIR_NAME")

GEM_HOME=${BASE_DIR_NAME}/gems/ruby/2.7.0
GEM_PATH=${BASE_DIR_NAME}/gems/ruby/2.7.0
PATH=${BASE_DIR_NAME}/ruby/bin:${BASE_DIR_NAME}/gems/ruby/2.7.0/bin:${BASE_DIR_NAME}/gems/ruby/2.7.0/gems/urbanopt-cli-0.11.1/example_files/python_deps/Miniconda-4.12.0/bin:$PATH
PATH=${BASE_DIR_NAME}/ruby/bin:${BASE_DIR_NAME}/gems/ruby/2.7.0/bin:${BASE_DIR_NAME}/gems/ruby/2.7.0/gems/${UO_DIR_NAME}/example_files/python_deps/Miniconda-4.12.0/bin:$PATH
RUBYLIB=${BASE_DIR_NAME}/OpenStudio/Ruby
RUBY_DLL_PATH=${BASE_DIR_NAME}/OpenStudio/Ruby

Expand Down
21 changes: 10 additions & 11 deletions scripts/setup-env-unix.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/bin/bash
# This is a simple setup script that generates an enviroment file that
# is used to setup the ruby enviroment to run the urbanopt-cli tool.
# This is a simple setup script that generates an environment file that
# is used to setup the ruby environment to run the urbanopt-cli tool.
# To use, just run this script in bash (e.g. ./setup-env.sh)
# Then you can use this env.sh to setup the enviroment.
# Then you can use this env.sh to setup the environment.
# (e.g. . env.sh)

BASE_DIR_NAME="$(cd "$(dirname "$0")" && pwd)"
UO_DIR=$(dirname "$(realpath "$0")")
UO_DIR_NAME=$(basename "$UO_DIR")

GEM_HOME=${BASE_DIR_NAME}/gems/ruby/2.7.0
GEM_PATH=${BASE_DIR_NAME}/gems/ruby/2.7.0
PATH=${BASE_DIR_NAME}/ruby/bin:${BASE_DIR_NAME}/gems/ruby/2.7.0/bin:${BASE_DIR_NAME}/gems/ruby/2.7.0/gems/urbanopt-cli-0.11.1/example_files/python_deps/Miniconda-4.12.0/bin:$PATH
RUBYLIB=${BASE_DIR_NAME}/OpenStudio/Ruby
RUBY_DLL_PATH=${BASE_DIR_NAME}/OpenStudio/Ruby
GEM_HOME=${UO_DIR}/gems/ruby/2.7.0
GEM_PATH=${UO_DIR}/gems/ruby/2.7.0
PATH=${UO_DIR}/ruby/bin:${UO_DIR}/gems/ruby/2.7.0/bin:${UO_DIR}/gems/ruby/2.7.0/gems/${UO_DIR_NAME}/example_files/python_deps/Miniconda-4.12.0/bin:$PATH
RUBYLIB=${UO_DIR}/OpenStudio/Ruby
RUBY_DLL_PATH=${UO_DIR}/OpenStudio/Ruby

# Remove if exists
if [ -f ~/.env_uo.sh ]; then
Expand All @@ -23,5 +24,3 @@ echo "export GEM_PATH=\"${GEM_PATH}\"" >> ~/.env_uo.sh
echo "export PATH=\"${PATH}\"" >> ~/.env_uo.sh
echo "export RUBYLIB=\"${RUBYLIB}\"" >> ~/.env_uo.sh
echo "export RUBY_DLL_PATH=\"${RUBY_DLL_PATH}\"" >> ~/.env_uo.sh


20 changes: 0 additions & 20 deletions scripts/setup-env.bat

This file was deleted.

28 changes: 24 additions & 4 deletions scripts/setup-env.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
# This is a simple setup script that generates an enviroment file that
# is used to setup the ruby enviroment to run the urbanopt-cli tool.
# This is a simple setup script that generates an environment file that
# is used to setup the ruby environment to run the urbanopt-cli tool.
# To use just run this script in powershell (e.g. ./setup-env.ps1)
# Then you can use this env.ps1 to setup the enviroment.
# Then you can use this env.ps1 to setup the environment.
# (e.g. . env.ps1)
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'

if (-not (Test-Path $HOME)) { echo "env HOME needs to be set before running this script" }
if (-not (Test-Path $HOME)) { exit }

# uo install_python will install its own python within the gem directories so we need to find the python path and add it to $env.PATH
$output = Get-ChildItem -ErrorAction SilentlyContinue -Directory "C:\URBANopt*" -Recurse -Filter "python-3.10" | Select-Object FullName

if ($output.FullName) {
$RUBY_PYTHON_PATH = $output.FullName
}
else {
$RUBY_PYTHON_PATH = ""
}


$BASE_DIR_NAME = $PSScriptRoot

$env:GEM_HOME = "$BASE_DIR_NAME\gems\ruby\2.7.0"
$env:GEM_PATH = "$BASE_DIR_NAME\gems\ruby\2.7.0"
$env:PATH += ";$BASE_DIR_NAME\ruby\bin;$BASE_DIR_NAME\gems\ruby\2.7.0\bin;$BASE_DIR_NAME\gems\ruby\2.7.0\gems\urbanopt-cli-0.11.1\example_files\python_deps\python-3.10"
$env:PATH += ";$BASE_DIR_NAME\ruby\bin;$BASE_DIR_NAME\gems\ruby\2.7.0\bin;$RUBY_PYTHON_PATH"
$env:RUBYLIB = "$BASE_DIR_NAME\OpenStudio\Ruby"
$env:RUBY_DLL_PATH = "$BASE_DIR_NAME\OpenStudio\Ruby"

# Remove if exists
Remove-Item $HOME/.env_uo.ps1 -ErrorAction Ignore
Remove-Item $HOME/.env_uo.bat -ErrorAction Ignore

'$env:GEM_HOME = "' + $env:GEM_HOME + '"' >> $HOME/.env_uo.ps1
'$env:GEM_PATH = "' + $env:GEM_PATH + '"' >> $HOME/.env_uo.ps1
'$env:PATH = "' + $env:PATH + '"' >> $HOME/.env_uo.ps1
'$env:RUBYLIB = "' + $env:RUBYLIB + '"' >> $HOME/.env_uo.ps1
'$env:RUBY_DLL_PATH = "' + $env:RUBY_DLL_PATH + '"' >> $HOME/.env_uo.ps1

'' >> $HOME/.env_uo.bat
'SET "GEM_HOME=' + $env:GEM_HOME + '"' >> $HOME/.env_uo.bat
'SET "GEM_PATH=' + $env:GEM_PATH + '"' >> $HOME/.env_uo.bat
'SET "PATH=' + $env:PATH + '"' >> $HOME/.env_uo.bat
'SET "RUBYLIB=' + $env:RUBYLIB + '"' >> $HOME/.env_uo.bat
'SET "RUBY_DLL_PATH=' + $env:RUBY_DLL_PATH + '"' >> $HOME/.env_uo.bat

0 comments on commit 04239dd

Please sign in to comment.