Skip to content
Snippets Groups Projects
Commit 7cf0038d authored by Marco Biasini's avatar Marco Biasini
Browse files

make directory layout more pythonic

Instead of creating a lib/openstructure subdirectory containing
all ost modules, use lib/python$MAJOR.$MINOR/site-packages. This
follows more closely what other projects are doing. The main
motivation, however is to simplify deploment of tools built on
OpenStructure.
parent 2a0757bf
No related branches found
No related tags found
No related merge requests found
......@@ -496,9 +496,9 @@ macro(pymod)
return()
endif()
if (_ARG_OUTPUT_DIR)
set(PYMOD_DIR "openstructure/${_ARG_OUTPUT_DIR}")
set(PYMOD_DIR "python${PYTHON_VERSION}/site-packages/${_ARG_OUTPUT_DIR}")
else()
set(PYMOD_DIR "openstructure/${_ARG_PREFIX}/${_ARG_NAME}")
set(PYMOD_DIR "python${PYTHON_VERSION}/site-packages/${_ARG_PREFIX}/${_ARG_NAME}")
endif()
set(_LIB_NAME ${_ARG_PREFIX}_${_ARG_NAME})
set(PYMOD_STAGE_DIR "${LIB_STAGE_PATH}/${PYMOD_DIR}")
......
......@@ -27,7 +27,7 @@ def _deps_for_lib(lib, pool, recursive=True):
return
def collect_deps(stage_dir, components, binaries, libexec_binaries,
site_packages, site_packages_dir):
site_packages, site_packages_dir, libexec_path='openstructure'):
"""
Collect the dependencies for the given components and returns a list of
frameworks/libraries that the component depends on.
......@@ -50,7 +50,7 @@ def collect_deps(stage_dir, components, binaries, libexec_binaries,
if bin_name not in pool:
_deps_for_lib(bin_name, pool)
for bin in libexec_binaries:
bin_name=os.path.abspath(os.path.join(stage_dir, 'libexec/openstructure',
bin_name=os.path.abspath(os.path.join(stage_dir, 'libexec', libexec_path,
bin))
if not os.path.exists(bin_name):
print 'WARNING:', bin_name, 'does not exist'
......@@ -239,7 +239,8 @@ def make_standalone(stage_dir, outdir, no_includes, force_no_rpath=False,
# when running in non-gui mode, we are most likely missing the boost
# python library. Let's add it to the list of dependencies by
# inspecting "_ost_base.so".
_deps_for_lib(os.path.join(stage_dir, 'lib/openstructure/ost/_ost_base.so'),
pymod_dir='lib/python%d.%d/site-packages' % sys.version_info[0:2]
_deps_for_lib(os.path.join(stage_dir, pymod_dir, 'ost/_ost_base.so'),
deps, recursive=False)
print 'copying dependencies'
copy_deps(deps, outdir)
......@@ -249,8 +250,8 @@ def make_standalone(stage_dir, outdir, no_includes, force_no_rpath=False,
print 'copying binaries'
copy_binaries(stage_dir, outdir, binaries, scripts, 'bin')
print 'copying pymod'
shutil.copytree(os.path.join(stage_dir, 'lib/openstructure'),
os.path.join(outdir, 'lib/openstructure'))
shutil.copytree(os.path.join(stage_dir,pymod_dir),
os.path.join(outdir, pymod_dir))
copied_py_framework=False
non_std_python=False
if os.path.exists(os.path.join(outdir, 'lib/Python.framework')):
......@@ -310,9 +311,9 @@ def make_standalone(stage_dir, outdir, no_includes, force_no_rpath=False,
for sp in SITE_PACKAGES:
src=get_python_module_path(sp)
if os.path.isdir(src):
shutil.copytree(src, os.path.join(outdir, 'lib/openstructure', sp))
shutil.copytree(src, os.path.join(outdir, pymod_dir, sp))
else:
shutil.copy(src, os.path.join(outdir, 'lib/openstructure', sp))
shutil.copy(src, os.path.join(outdir, pymod_dir, sp))
print 'updating link commands of python shared objects'
os.path.walk(os.path.join(outdir, 'lib'),
update_pymod_shared_objects,
......
......@@ -13,13 +13,12 @@
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
site_packs='python%d.%d/site-packages' % sys.version_info[0:2]
sys.path.append(os.path.join(os.path.abspath('../..'),
'stage/lib/openstructure'))
'stage/lib', site_packs))
sys.path.append(os.path.join(os.path.abspath('../..'),
'stage/lib64/openstructure'))
'stage/lib64', site_packs))
print site_packs
import ost
# -- General configuration -----------------------------------------------------
......
......@@ -108,13 +108,20 @@ String get_ost_root()
void 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\\openstructure"));
pi.AppendModulePath(QString::fromStdString(root+"\\lib\\"+site_pkgs.str()
+"\\site-packages"));
#else
# if (defined(__ppc64__) || defined(__x86_64__)) && !defined(__APPLE__)
pi.AppendModulePath(QString::fromStdString(root+"/lib64/openstructure"));
pi.AppendModulePath(QString::fromStdString(root+"/lib64/"+
site_pkgs.str()+
"site-packages"));
# else
pi.AppendModulePath(QString::fromStdString(root+"/lib/openstructure"));
pi.AppendModulePath(QString::fromStdString(root+"/lib/"+
site_pkgs.str()+
"/site-packages"));
# endif
#endif
pi.AppendModulePath(".");
......
......@@ -33,13 +33,13 @@ if (NOT ENABLE_STATIC)
set(INIT_SCRIPTS
init_cl.py
)
set(SPD "${LIB_DIR}/python${PYTHON_VERSION}/site-packages")
if (ENABLE_GUI)
list(APPEND INIT_SCRIPTS init.py)
endif()
copy_if_different("./" "${STAGE_DIR}/${LIB_DIR}/openstructure"
copy_if_different("./" "${STAGE_DIR}/${SPD}"
"${INIT_SCRIPTS}" "python init scripts" ost_scripts)
install(FILES ${INIT_SCRIPTS} DESTINATION "${LIB_DIR}/openstructure")
install(FILES ${INIT_SCRIPTS} DESTINATION "${SPD}")
endif()
......@@ -26,10 +26,11 @@ parser.add_option("-v", "--verbosity_level", action="store", type="int", dest="v
parser.disable_interspersed_args()
(options, args) = parser.parse_args()
_site_packs='python%d.%d/site-packages' % sys.version_info[0:2]
if platform.machine()=='x86_64':
sys.path.insert(0, os.getenv('DNG_ROOT')+'/lib64/openstructure')
sys.path.insert(0, os.path.join(os.getenv('DNG_ROOT'), 'lib64', _site_packs))
else:
sys.path.insert(0,os.getenv('DNG_ROOT')+'/lib/openstructure')
sys.path.insert(0,os.path.join(os.getenv('DNG_ROOT'), 'lib', _site_packs))
from ost import *
import ost
......
......@@ -31,7 +31,7 @@ BIN_DIR=`dirname "$SCRIPT_NAME"`
source $BIN_DIR/../@LIBEXEC_PATH@/ost_config
$pyexec $interactive "$DNG_ROOT/@LIBDIR@/openstructure/init_cl.py" $opts
$pyexec $interactive "$DNG_ROOT/@LIBDIR@/python@PYTHON_VERSION@/site-packages/init_cl.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/openstructure"
export DNG_INITDIR="$DNG_LIBDIR/python@PYTHON_VERSION@/site-packages"
export PATH="$DNG_BINDIR:${PATH}"
export DYLD_FRAMEWORK_PATH="$DNG_LIBDIR:${DYLD_FRAMEWORK_PATH}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment