HIP relative packages

   1698   4   0
User Avatar
Member
8 posts
Joined: 4月 2020
Offline
I want to have some packages shared between a few scenes, and to keep the packages plus scene files in one repo.

I am trying to avoid using machine level package references and instead use hip file references.

Unfortunately the $HIPfolder is not checked for package json (as far as I know anyway, tried creating a ‘packages’ subfolder), and $HIPenvironment variable is only set after the packages are loaded.

I have a work around, but it is a little messy.

So I wondered if I was missing a few setup tricks that would allow me to avoid some mess.

My current work around:
  1. Launch Houdini from command line with setting an Environment Variable dynamically set to the hip file's directory
  2. Add a package json file to a machine level packages directory that using the hip file directory Environment Variable
  3. Add package json files referencing the shared project packages

To make it clearer

Terminal will automatically set PWD. So I will be lazy for now and just launch from the hip file's folder.

open scene.hiplc

In a global packages folder (for example ~/Library/Preferences/houdini/18.0/packages) add:

{
"env": [
{
"SCENE_HIP_DIR": "$PWD"
}
],
"package_path" : [
"$SCENE_HIP_DIR/packages"
]
}

In the scene folder add:

{
"env": [
{
"COMMON_DIR": "$SCENE_HIP_DIR/../Common"
}
],
"package_path" : [
"$COMMON_DIR/packages"
]
}

In the top level Common folder:

{
"env": [
{
"COMMON_SOME_CHILD_DIR": "$COMMON_DIR/SomeChild"
}
],
"path": "$COMMON_DIR",
"package_path" : [
"$COMMON_SOME_CHILD_DIR/packages"
]
}

In the common child subfolders (maybe having sub packages is going to far):

{
"path": "$COMMON_SOME_CHILD_DIR"
}

Problems with this:
  1. Needs to have scene opened from a script; or at least opened from command line
  2. Still need to have a global package file setup. I could setup this in the launch script but I think that would make things a sudo command
  3. Minor issue: potential Environment Variable name clashes.


Any suggestions on what I may have missed?
Edited by dom_campbell - 2020年7月7日 11:35:26
User Avatar
スタッフ
397 posts
Joined: 2月 2018
Offline
Did you consider using HOUDINI_PACKAGE_DIR instead ?

E.g
export HOUDINI_PACKAGE_DIR = $PWD/packages;$PWD/packages2;$PWD/packages3
Edited by mabelzile - 2020年7月15日 11:48:58
User Avatar
Member
7747 posts
Joined: 9月 2011
Offline
mabelzile
Did you consider using HOUDINI_PACKAGE_DIR instead ?

E.g
export HOUDINI_PACKAGE_DIR = $PWD/packages;$PWD/packages2;$PWD/packages3

Won't that only work when launching houdini from the folder containing the HIP file?
User Avatar
スタッフ
397 posts
Joined: 2月 2018
Offline
Right. I could be wrong but if I understand your example, it seems the following would achieve the same.

export HOUDINI_PACKAGE_DIR = $PWD/packages;$PWD/../Common/packages;$PWD/../Common/SomeChild/packages
User Avatar
Member
8 posts
Joined: 4月 2020
Offline
mabelzile
Right. I could be wrong but if I understand your example, it seems the following would achieve the same.

Thats a great suggestion, I am assuming you mean putting in the script and not `houdini.env`; I feel dumb for not trying that originally maybe just assumed it would be cleared out in `houdini.env`. If going the launch script route it would certainly make is simpler by avoiding copying a file to presences.

I think for what I am trying to do keeping with just setup the `packages` directory for the scene would be better than setting them all up. I don't want to be managing dependancies or the dependancies, and would rather change the contents of the package json files in each scene directory than the script.

With a launch script it is going to need to have scene file parameter or have script for each scene file; one script that more work to call command line (better fore devs), many simpler to run scripts (better for non-devs).

Assuming that latter for now would have something like this:
#!/bin/bash

# opens the file with the same name as the script minus the `.sh` or `.command` suffixes.
# copy and name file to open a different scene
# for example: 'sceneXXX.hiplc.command' opens 'sceneXXX.hiplc'

SCRIPT_PATH=$0

export SCRIPT_DIRECTORY_PATH=$(dirname "$SCRIPT_PATH")
export SCENE_HIP_DIR=$(dirname "$SCRIPT_PATH")
export HOUDINI_PACKAGE_DIR=$SCENE_HIP_DIR/packages

FILE_TO_OPEN=$SCRIPT_PATH
FILE_TO_OPEN=${FILE_TO_OPEN%".sh"}
FILE_TO_OPEN=${FILE_TO_OPEN%".command"}

open $FILE_TO_OPEN

Problems:
  • Still required to launch from terminal; unless it is a ‘.command’ on Mac.
  • Script maintenance; script file execution permissions will need preserved between git checkouts, multiple scripts existing if I am avoid a file parameter, etc

If it is just for myself with multiple checkouts at different locations, keeping my current setup looks like the simplest approach for me for now at least.

Not sure when working with others, I guess that will depending on them. Maybe I just uses my existing setup (get them to install that package json to preferences), and create a script that sets PWD to and allow launching from clicking on the script. Not sure what this would be look like on windows or linux but on Mac:

#!/bin/bash

# opens the file with the same name as the script minus the `.sh` or `.command` suffixes.
# copy and name file to open a different scene
# for example: 'sceneXXX.hiplc.command' opens 'sceneXXX.hiplc'

SCRIPT_PATH=$0
export PWD=$(dirname "$SCRIPT_PATH")

FILE_TO_OPEN=$SCRIPT_PATH
FILE_TO_OPEN=${FILE_TO_OPEN%".sh"}
FILE_TO_OPEN=${FILE_TO_OPEN%".command"}

open $FILE_TO_OPEN
  • Quick Links