Skip to content
Snippets Groups Projects
Commit 1e44748f authored by Ansgar Philippsen's avatar Ansgar Philippsen
Browse files

refactored python startup files for ost and dng

there are now three startup files; ost_startup.py (former init_cl.py) initializes non-gui ost; dng_startup (former init.py) initializes dng; and gosty_startup initializes gosty (some issues remain what to put into dng_startup as opposed to gosty_startup). also, files are now properly placed into site-packages/ost (on osx and linux)
parent 96054d05
No related branches found
No related tags found
No related merge requests found
struct=io.LoadEntity("sdh.pdb")
surf=io.LoadSurface("sdh","msms")
surf.Attach(struct,5.0)
go=gfx.Surface("surf",surf)
# this is broken
#go.clip=True
#go.clip_plane=geom.Vec4(0,0,-1,-130)
# this works, z offset to near clipping plane, must be >0
go.clip_offset=1
go.solid=True
go.solid_color=gfx.RGB(1,1,0)
scene.rtc=geom.Mat4(0.914075, -0.355397, 0.195293, 29.688, 0.405471, 0.7934, -0.45397, 19.9405, 0.00639453, 0.494153, 0.869337, 73.0075, 0, 0, -143.077, 1)
scene.Add(go)
scene.SetCenter(go.GetCenter())
scene.Autoslab()
scene.auto_autoslab=False
......@@ -86,6 +86,7 @@ set(OST_GUI_PYMOD_MODULES
traj.py
helpwidget.py
table.py
gosty_startup.py
)
set(OST_GUI_PYMOD_DNG_MODULES
......
from ost import *
from ost import gui
gui_mode=True
scene=gfx.Scene()
scene.Stereo=gfx.Stereo
......@@ -106,25 +106,23 @@ String get_ost_root()
return dir.path().toStdString();
}
void setup_python_search_path(const String& root, PythonInterpreter& pi)
String setup_python_search_path(const String& root, PythonInterpreter& pi)
{
std::stringstream site_pkgs;
site_pkgs << "python" << PY_MAJOR_VERSION << "." << PY_MINOR_VERSION;
#ifdef _MSC_VER
pi.AppendModulePath(QString::fromStdString(root+"\\lib\\"+site_pkgs.str()
+"\\site-packages"));
String loc=root+"\\lib\\"+site_pkgs.str()+"\\site-packages";
#else
# if (defined(__ppc64__) || defined(__x86_64__)) && !defined(__APPLE__)
pi.AppendModulePath(QString::fromStdString(root+"/lib64/"+
site_pkgs.str()+
"/site-packages"));
# else
pi.AppendModulePath(QString::fromStdString(root+"/lib/"+
site_pkgs.str()+
"/site-packages"));
# endif
# if (defined(__ppc64__) || defined(__x86_64__)) && !defined(__APPLE__)
String loc=root+"/lib64/"+site_pkgs.str()+"/site-packages";
# else
String loc=root+"/lib/"+site_pkgs.str()+"/site-packages";
# endif
#endif
pi.AppendModulePath(QString::fromStdString(loc));
// dng is an interactive python session, so add '.' to search path
pi.AppendModulePath(".");
return loc;
}
int setup_resources(QApplication& app)
......@@ -186,9 +184,18 @@ int init_python_interpreter()
console_logger,
SLOT(AppendOutput(unsigned int, const QString &)));
}
setup_python_search_path(root, py);
py.RunCommand("from ost import *");
py.RunCommand("gui_mode=True");
String python_loc=setup_python_search_path(root, py);
//py.RunCommand("from ost import *");
//py.RunCommand("gui_mode=True");
std::stringstream cmd;
cmd << "execfile('" << python_loc;
#ifdef _MSC_VER
cmd << "\\ost\\gui\\";
#else
cmd << "/ost/gui/";
#endif
cmd << "gosty_startup.py')";
py.RunCommand(QString::fromStdString(cmd.str()));
return 0;
}
......
......@@ -31,11 +31,11 @@ if (NOT ENABLE_STATIC)
endif()
set(INIT_SCRIPTS
init_cl.py
ost_startup.py
)
set(SPD "${LIB_DIR}/python${PYTHON_VERSION}/site-packages")
set(SPD "${LIB_DIR}/python${PYTHON_VERSION}/site-packages/ost")
if (ENABLE_GUI)
list(APPEND INIT_SCRIPTS init.py)
list(APPEND INIT_SCRIPTS dng_startup.py)
endif()
copy_if_different("${CMAKE_CURRENT_SOURCE_DIR}" "${STAGE_DIR}/${SPD}"
"${INIT_SCRIPTS}" "python init scripts" ost_scripts)
......
......@@ -27,5 +27,4 @@ echo Starting DNG in %BIN_DIR%
set DNG_ROOT=%BIN_DIR%\..
set PATH=%BIN_DIR%;%DNG_ROOT%\@LIBDIR@\@BUILD_TYPE@;%DNG_ROOT%\@LIBDIR@;%DNG_ROOT%\bin\@BUILD_TYPE@;%PATH%
REM "%BIN_DIR%\@BUILD_TYPE@\gosty.exe" %DNG_ROOT%\@LIBDIR@\openstructure\init.py ost %*
"%BIN_DIR%\@BUILD_TYPE@\gosty.exe" "%DNG_ROOT%\@LIBDIR@\openstructure\init.py" ost %*
"%BIN_DIR%\@BUILD_TYPE@\gosty.exe" "%DNG_ROOT%\@LIBDIR@\openstructure\dng_startup" ost %*
......@@ -28,4 +28,4 @@ fi
BIN_DIR=`dirname "$SCRIPT_NAME"`
source "$BIN_DIR/../@LIBEXEC_PATH@/ost_config"
$BIN_DIR/../@LIBEXEC_PATH@/gosty $DNG_INITDIR/init.py dng $opts
$BIN_DIR/../@LIBEXEC_PATH@/gosty $DNG_INITDIR/dng_startup.py dng $opts
File moved
......@@ -50,6 +50,6 @@ if "%1" == "" (
echo passing commandline options %opts% to ost
)
call "%pyexec%" %interact_% "%DNG_ROOT%\@LIBDIR@\openstructure\init_cl.py" %opts%
call "%pyexec%" %interact_% "%DNG_ROOT%\@LIBDIR@\openstructure\ost_startup.py" %opts%
......@@ -31,6 +31,6 @@ BIN_DIR=`dirname "$SCRIPT_NAME"`
source "$BIN_DIR/../@LIBEXEC_PATH@/ost_config"
$pyexec $interactive "$DNG_ROOT/@LIBDIR@/python@PYTHON_VERSION@/site-packages/init_cl.py" $opts
$pyexec $interactive "$DNG_ROOT/@LIBDIR@/python@PYTHON_VERSION@/site-packages/ost/ost_startup.py" $opts
RC=$?
exit $RC
......@@ -24,7 +24,7 @@
export DNG_ROOT=`cd "$BIN_DIR/..";pwd`
export DNG_BINDIR="$DNG_ROOT/bin"
export DNG_LIBDIR="$DNG_ROOT/@LIBDIR@"
export DNG_INITDIR="$DNG_LIBDIR/python@PYTHON_VERSION@/site-packages"
export DNG_INITDIR="$DNG_LIBDIR/python@PYTHON_VERSION@/site-packages/ost/"
export PATH="$DNG_BINDIR:${PATH}"
export DYLD_FRAMEWORK_PATH="$DNG_LIBDIR:${DYLD_FRAMEWORK_PATH}"
......
......@@ -27,21 +27,25 @@ parser.disable_interspersed_args()
(options, args) = parser.parse_args()
_site_packs='python%d.%d/site-packages' % sys.version_info[0:2]
_base_dir=os.getenv('DNG_ROOT')
if platform.machine()=='x86_64':
sys.path.insert(0, os.path.join(os.getenv('DNG_ROOT'), 'lib64', _site_packs))
sys.path.insert(0, os.path.join(_base_dir, 'lib64', _site_packs))
else:
sys.path.insert(0,os.path.join(os.getenv('DNG_ROOT'), 'lib', _site_packs))
sys.path.insert(0,os.path.join(_base_dir, 'lib', _site_packs))
from ost import *
import ost
try:
from ost import gfx
ost.scene = gfx.Scene()
scene=gfx.Scene()
ost.scene.Stereo=gfx.Stereo
scene.Stereo=gfx.Stereo
except ImportError:
print "ost build without gfx"
pass
ost.SetPrefixPath(os.getenv('DNG_ROOT'))
ost.SetPrefixPath(_base_dir)
def _InitRuleBasedBuilder():
compound_lib_path=os.path.join(ost.GetSharedDataPath(), 'compounds.chemlib')
if os.path.exists(compound_lib_path):
......@@ -79,6 +83,7 @@ else:
PushVerbosityLevel(options.vlevel)
# this should probably only be added when running an interactive shell
sys.path.append(".")
if len(parser.rargs)>0 :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment