adding libraries
Posted by nex on Aug 7, 2006i just downloaded photobot. making it run was easy enough, but two thoughts: instructions as to where to put the files should be included with the archive, and i'd prefer to have a standard place in which i can put all the libraries i use. i store my NodeBox scripts in the folders of the projects i use them for, and i think that makes a lot of sense, but this habit in combination with having to libraries with the files that use them means that i'll be storing and duplicating my libraries all over the place. icky!
Posted by Tom De Smedt on Aug 11, 2006
You can make handy use of Unix symbolic links to reference libraries. Symbolic links are like aliases. The only problem here is when you move the referenced source, the link doesn't work anymore.
However, it's easy enough to manage all the dependencies from a script:
import os
# The path where all my scripts are, libraries as well as projects.
# Each library or project is in a subfolder.
path = "/users/tom/projects/nodebox/code/"
libraries = {"wordnet" : ["wordnet.py", "pywordnet"],
"google" : ["google.py", "pygoogle"],
"photobot" : ["photobot.py", "pyimaging"],
}
def link(library, project):
f = libraries[library]
for file in f:
try: os.unlink(path+project+"/"+file)
except: pass
print path+project+"/"+file
os.symlink(path+library+"/"+file,
path+project+"/"+file)
projects = {"hyperpolator" : ["google", "wordnet"],
"prism" : ["google"],
}
for project in projects.keys():
for library in projects[project]:
link(library, project)
You can see how each project in the projects array lists the libraries it needs. Now when I run this script, it will create symbolic links to the required libraries in each project folder.
Posted by Rit Mishra on Sep 25, 2006
It is quite difficult for me to figureout how to run Photobot at my end. Can you please explain the steps from stage one...
I mean where to place the folder, and how to run the program.
Posted by Tom De Smedt on Sep 26, 2006
Everything inside the PhotoBot download goes in the same folder your script that imports PhotoBot is in. Here is an example:
http://nodebox.net/examples/photobot-import-example.zip
Take a look at the setup in this example: there's a script that imports the library. The library itself (i.e. photobot.py and pyimaging) is in the same folder. Else the example script would not be able to locate the library.
The image is in the same folder as well, for the same reasons.
Hope that helps!
Posted by Rit Mishra on Sep 27, 2006
aah !! Thanks that worked fine.
Posted by nex on Aug 11, 2006
this resolves my problem perfectly, many thanks!