I run some python scripts on a server, they are under a cvs repository and, for various reasons use absolute path names.

I'm trying to use eclipse as an editor - I check the projects out, but when running them I find that the files are not where the code expects them. ('/home/staff/root/analysis/test.txt' rather than '../test.txt' for example)

Is there a way to get eclipse to trick python into thinking there is a different directory structure? If I did a global find/replace of '/home/staff/root/analysis/' for '..' that would do the trick, but it doesn't appear very guru-like...

2 Answers
2

I don't have an answer for your question in the narrowest sense. I do have two suggestions that may achieve the same end.

Suggestion 1: Symlink

If the file dependencies are rooted in a common tree (or a small number of trees), you might be able to create a symlink to the appropriate files. So, let's say that you want /home/staff/root/analysis/test.txt to resolve to /path/to/working/directory/test.txt, then you could do this:

$ sudo ln -fns /path/to/working/directory /home/staff/root/analysis

This requires root privileges. The effect would be that the entire path prefix
/home/staff/root/analysis would resolve to /path/to/working/directory. This applies to files immediately under the prefix as well as all subdirectories.

Suggestion 2: Support configuration options for runtime dependencies

If files are really required for runtime or testing, they should be part of the package. Describing exactly how to do this is beyond the scope of this answer, but here are some resources, which you might already be well aware: