Skip to content

Commit

Permalink
Find the python path if it exists in urbanopt gem directories
Browse files Browse the repository at this point in the history
  • Loading branch information
tijcolem committed Oct 10, 2024
1 parent 7cf86c4 commit f6c3402
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions scripts/setup-env.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@
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
$UO_DIR = Split-Path -Path $PSScriptRoot -Leaf

$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\$UO_DIR\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"

Expand All @@ -23,4 +33,4 @@ Remove-Item $HOME/.env_uo.ps1 -ErrorAction Ignore
'$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
'$env:RUBY_DLL_PATH = "' + $env:RUBY_DLL_PATH + '"' >> $HOME/.env_uo.ps1

0 comments on commit f6c3402

Please sign in to comment.