Use C++ __FILE__ rather than Python __file__ to find indra work area.

In this case, the Python code in question is being written from a C++ string
literal to a temp script file in a platform-dependent temp directory -- so the
Python __file__ value tells you nothing about the location of the repository
checkout. Embedding __FILE__ from the containing C++ source file works better.
meow-7.2.2
Nat Goodspeed 2011-07-15 22:32:06 -04:00
parent 15c36ee9b3
commit 2b509383cc
1 changed files with 7 additions and 1 deletions

View File

@ -1674,10 +1674,16 @@ namespace tut
struct TestPythonCompatible
{
TestPythonCompatible():
// Note the peculiar insertion of __FILE__ into this string.
// Normally I like to make a Python script navigate relative to
// its own placement in the repo directory tree (__file__) -- but
// in this case, the script is being written into a platform-
// dependent temp directory! So locate indra/lib/python relative
// to this C++ source file rather than the Python module.
import_llsd("import os.path\n"
"import sys\n"
"sys.path.insert(0,\n"
" os.path.join(os.path.dirname(__file__),\n"
" os.path.join(os.path.dirname('" __FILE__ "'),\n"
" os.pardir, os.pardir, 'lib', 'python'))\n"
"try:\n"
" from llbase import llsd\n"