diff --git a/configure.ac b/configure.ac index 7ce3c1f3..6c707df2 100644 --- a/configure.ac +++ b/configure.ac @@ -87,7 +87,9 @@ else fi AC_ARG_ENABLE([pykat], - AS_HELP_STRING([--disable-pykat], [Disable build of python package pykat. If this is disabled, KAT will not create plots or perform extra distribution analysis.]), make_pykat="no", make_pykat="yes") + AS_HELP_STRING([--disable-pykat], [Disable build of python package kat. If this is disabled, KAT will not create plots or perform extra distribution analysis.]), make_pykat="no", make_pykat="yes") +AC_ARG_ENABLE([pykat-install], + AS_HELP_STRING([--disable-pykat-install], [Disable installation of python package kat. If this is disabled, KAT will not install the python package kat to /lib/python/site-packages. The user can manually install the kat package using setuptools.]), make_pykat_install="no", make_pykat_install="yes") if [[ "${make_pykat}" == "yes" ]]; then @@ -123,6 +125,8 @@ fi AM_CONDITIONAL([MAKE_PYKAT], [test x$make_pykat = xyes]) AC_SUBST([MAKE_PYKAT]) +AM_CONDITIONAL([MAKE_PYKAT_INSTALL], [test x$make_pykat_install = xyes]) +AC_SUBST([MAKE_PYKAT_INSTALL]) # Check for sphinx to build documentation (optional) AC_CHECK_PROG([sphinx], [sphinx-build], [yes], [no]) @@ -174,7 +178,7 @@ AC_OUTPUT pystr="detected ${PYTHON_VERSION}. Plotting and downstream analysis enabled." if [[ "${make_pykat}" == "no" ]]; then - pystr="no. No plotting or downstream analysis will be performed." + pystr="no. No plotting or distribution analysis will be performed." fi sphinxstr="detected. Docs will be built." if [[ "${sphinx}" == "no" ]]; then @@ -185,4 +189,5 @@ AC_MSG_NOTICE([ Configuration status: - Python V3.5+ - ${pystr} - - Sphinx V1.3+ - ${sphinxstr}]) + - Sphinx V1.3+ - ${sphinxstr} + - Python install - ${make_pykat_install}]) diff --git a/doc/Makefile b/doc/Makefile index d6d3c7fd..d2bce4cb 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -10,7 +10,7 @@ MKDIR_P = mkdir -p INSTALL = /usr/bin/install -c -m 644 # Set autoconf variables -prefix = /usr/local +prefix = /home/dan/software/kat_test/nopyinstall PACKAGE_TARNAME = kat top_srcdir = .. srcdir = . diff --git a/lib/include/kat/kat_fs.hpp b/lib/include/kat/kat_fs.hpp index a71c99ed..42f6fb9a 100644 --- a/lib/include/kat/kat_fs.hpp +++ b/lib/include/kat/kat_fs.hpp @@ -124,33 +124,50 @@ namespace kat { #endif } else { - // If we are here then we are not running from an installed location, - // we are running from the source tree. - // Not 100% sure how far back we need to go (depends on whether using KAT exe or tests) - // so try 2, 3 and 4 levels. - this->scriptsDir = canonicalExe.parent_path().parent_path(); - this->scriptsDir /= "scripts"; - - if (!exists(this->scriptsDir)) { - this->scriptsDir = canonicalExe.parent_path().parent_path().parent_path(); + path kcc(canonicalExe.parent_path()); + if (exists("kat.cc")) { + // If we are here then we are not running from an installed location, + // we are running from the source tree. + // Not 100% sure how far back we need to go (depends on whether using KAT exe or tests) + // so try 2, 3 and 4 levels. + this->scriptsDir = canonicalExe.parent_path().parent_path(); this->scriptsDir /= "scripts"; if (!exists(this->scriptsDir)) { - this->scriptsDir = canonicalExe.parent_path().parent_path().parent_path().parent_path(); + this->scriptsDir = canonicalExe.parent_path().parent_path().parent_path(); this->scriptsDir /= "scripts"; if (!exists(this->scriptsDir)) { - BOOST_THROW_EXCEPTION(FileSystemException() << FileSystemErrorInfo(string( - "Could not find suitable directory containing KAT scripts relative to provided exe: ") + canonicalExe.c_str())); - } + this->scriptsDir = canonicalExe.parent_path().parent_path().parent_path().parent_path(); + this->scriptsDir /= "scripts"; + + if (!exists(this->scriptsDir)) { + BOOST_THROW_EXCEPTION(FileSystemException() << FileSystemErrorInfo(string( + "Could not find suitable directory containing KAT scripts relative to provided exe: ") + canonicalExe.c_str())); + } + } + } + kda = this->scriptsDir; + kda /= "setup.py"; + if (!exists(kda)) { + BOOST_THROW_EXCEPTION(FileSystemException() << FileSystemErrorInfo(string( + "Could not find suitable directory containing KAT scripts derived from relative path of executable"))); } } - kda = this->scriptsDir; - kda /= "setup.py"; - if (!exists(kda)) { - BOOST_THROW_EXCEPTION(FileSystemException() << FileSystemErrorInfo(string( - "Could not find suitable directory containing KAT scripts derived from relative path of executable"))); + else { + +#ifdef HAVE_PYTHON + // Assume user install KAT but without installing python modules alongside + this->scriptsDir = path(KAT_SITE_PKGS).parent_path(); + this->scriptsDir /= "local"; + if (!exists(this->scriptsDir)) { + BOOST_THROW_EXCEPTION(FileSystemException() << FileSystemErrorInfo(string( + "Could not find KAT scripts at the expected installed location: ") + this->scriptsDir.c_str())); + } +#else + this->scriptsDir = canonicalExe.parent_path(); +#endif } } diff --git a/scripts/Makefile.am b/scripts/Makefile.am index da125924..f8fee285 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,5 +1,8 @@ AUTOMAKE_OPTIONS = subdir-objects + +if MAKE_PYKAT_INSTALL + install-exec-hook: export PYTHONPATH=$(prefix)/lib/python$(PYTHON_VERSION)/site-packages && \ mkdir -p $(prefix)/lib/python$(PYTHON_VERSION)/site-packages/ && \ @@ -8,6 +11,17 @@ install-exec-hook: uninstall-hook: cat install_files.txt | xargs rm -rf +else + +install-exec-hook: + mkdir -p $(prefix)/lib/python$(PYTHON_VERSION)/local/ && \ + cp -r kat $(prefix)/lib/python$(PYTHON_VERSION)/local + +uninstall-hook: + rm -rf $(prefix)/lib/python$(PYTHON_VERSION)/local + +endif + EXTRA_DIST = \ kat/distanalysis.py \ kat/plot/__init__.py \