Update of /cvsroot/mahogany/M/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv31916/src/Python
Modified Files:
InitPython.cpp
Log Message:
changed "make install" under Unix to be more consistent with FSSTD and common sense:
1. binary is now installed in $prefix/bin
2. $prefix/share/mahogany (and not Mahogany) contains only arch-independent files
3. modules are now in $prefix/lib/mahogany/modules
4. code has been updated accordingly and tweaked to ensure that everything
works both after and before the installation
5. some preliminary/untested code for Mac OS X bundle directory detection added
Index: InitPython.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/Python/InitPython.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -b -u -2 -r1.37 -r1.38
--- InitPython.cpp 2 Jan 2004 22:53:02 -0000 1.37
+++ InitPython.cpp 12 Jan 2004 17:48:28 -0000 1.38
@@ -72,60 +72,64 @@
#endif // USE_PYTHON_DYNAMIC
- // set PYTHONPATH correctly to find our modules
- String tmp = _T("PYTHONPATH=");
+ // set PYTHONPATH correctly to find our modules and scripts
+ String pythonPathNew = _T("PYTHONPATH=");
String path = READ_APPCONFIG(MP_PYTHONPATH);
- bool didntHavePath = path.empty();
+ const bool didntHavePath = path.empty();
if ( didntHavePath )
{
- String pythondir;
- String globaldir = mApplication->GetGlobalDir();
- if ( globaldir.empty() )
+ // first, use user files
+ String localdir = mApplication->GetLocalDir();
+ if ( !localdir.empty() )
{
- // not installed
- pythondir << mApplication->GetDataDir() << DIR_SEPARATOR << _T("Python");
+ path << localdir << DIR_SEPARATOR << _T("scripts")
+ << PATH_SEPARATOR << localdir << DIR_SEPARATOR << _T("python");
}
- else
+
+ // next, use the program files
+ String globaldir = mApplication->GetDataDir();
+ if ( !globaldir.empty() && globaldir != localdir )
{
- pythondir = globaldir;
+ // note that both "python" and "scripts" directories are not
+ // capitalized after installation (as used here) but are capitalized
+ // in the source tree (below) -- this is a historical accident...
+ path << PATH_SEPARATOR << globaldir << DIR_SEPARATOR << _T("scripts")
+ << PATH_SEPARATOR << globaldir << DIR_SEPARATOR << _T("python");
}
- // note that "scripts" has small 's'
- path << pythondir << PATH_SEPARATOR
- << pythondir << DIR_SEPARATOR << _T("Python") << PATH_SEPARATOR
- << pythondir << DIR_SEPARATOR << _T("scripts")
- // add also the uninstalled locations
+ // finally, also add the uninstalled locations: this makes it possible
+ // to use the program without installing it which is handy
#ifdef M_TOP_BUILDDIR
- // but "Python/Scripts" has a capital 'S'!
- << PATH_SEPARATOR << M_TOP_BUILDDIR << _T("/src/Python")
- << PATH_SEPARATOR << M_TOP_BUILDDIR << _T("/src/Python/Scripts")
-#endif
- ;
+ path << PATH_SEPARATOR << M_TOP_BUILDDIR << _T("/src/Python");
+#endif // M_TOP_BUILDDIR
- String localdir = mApplication->GetLocalDir();
- if ( localdir != globaldir )
- {
- path << PATH_SEPARATOR
- << localdir << DIR_SEPARATOR << _T("Scripts") << PATH_SEPARATOR;
- }
+#ifdef M_TOP_SOURCEDIR
+ path << PATH_SEPARATOR << M_TOP_SOURCEDIR << _T("/src/Python/Scripts");
+#endif // M_TOP_SOURCEDIR
}
- tmp += path;
+ wxLogTrace(_T("Python"), "Adding \"%s\" to PYTHONPATH", path.c_str());
+
+ pythonPathNew += path;
- const char *pathOld = getenv("PYTHONPATH");
- if ( pathOld )
+ // also keep the old path but after our directories
+ const char *pythonPathOld = getenv("PYTHONPATH");
+ if ( pythonPathOld )
{
- tmp << PATH_SEPARATOR << pathOld;
+ pythonPathNew << PATH_SEPARATOR << pythonPathOld;
}
// on some systems putenv() takes "char *", cast silents the warnings but
// should be harmless otherwise
- putenv((char *)tmp.c_str());
+ putenv((char *)pythonPathNew.c_str());
// initialise the interpreter - this we do always, just to avoid problems
Py_Initialize();
- if( !READ_CONFIG(mApplication->GetProfile(), MP_USEPYTHON) )
- return true; // it is not an error to have it disabled
+ if ( !READ_CONFIG(mApplication->GetProfile(), MP_USEPYTHON) )
+ {
+ // it is not an error to have it disabled
+ return true;
+ }
// initialise the modules
@@ -152,6 +156,5 @@
{
Py_INCREF(Python_MinitModule); // keep it in memory
- PyObject *minit = PyObject_GetAttrString(Python_MinitModule,
- "Minit");
+ PyObject *minit = PyObject_GetAttrString(Python_MinitModule, "Minit");
if(minit)
{
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates