Skip to content

Commit

Permalink
adding a setupenv module to examples based on the setting shapeworks …
Browse files Browse the repository at this point in the history
…environment notebook
  • Loading branch information
Shireen Elhabian authored and Shireen Elhabian committed Dec 2, 2020
1 parent c1bee82 commit ba7b438
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*.vtk filter=lfs diff=lfs merge=lfs -text
*.dcm filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text

*.ipynb filter=nbstripout
*.ipynb diff=ipynb
40 changes: 40 additions & 0 deletions Examples/Python/setupenv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import sys
import platform

# helper function to print out python path
def print_python_path():
syspath = sys.path.copy()
print("\nPython path:")
for curpath in syspath:
if curpath != "":
print(curpath)

# helper function to print out system path
def print_env_path():
syspath = os.environ["PATH"].split(os.pathsep)
print("\nSystem path:")
for curpath in syspath:
if curpath != "":
print(curpath)

# helper function to add shapeworks bin directory to the path
def setup_shapeworks_env(shapeworks_bin_dir, # path to the binary directory of shapeworks
dependencies_bin_dir, # path to the binary directory of shapeworks dependencies used when running build_dependencies.sh
verbose = True):

# add shapeworks (and studio on mac) directory to python path
sys.path.append(shapeworks_bin_dir)
if platform.system() == "Darwin": # MacOS
sys.path.append(shapeworks_bin_dir + "/ShapeWorksStudio.app/Contents/MacOS")

# add shapeworks and studio to the system path
os.environ["PATH"] = shapeworks_bin_dir + os.pathsep + os.environ["PATH"]
os.environ["PATH"] = dependencies_bin_dir + os.pathsep + os.environ["PATH"]
if platform.system() == "Darwin": # MacOS
os.environ["PATH"] = shapeworks_bin_dir + "/ShapeWorksStudio.app/Contents/MacOS" + os.pathsep + os.environ["PATH"]

if verbose:
print_python_path()
print_env_path()

0 comments on commit ba7b438

Please sign in to comment.