Skip to content

Commit

Permalink
Finish Hotfix-3
Browse files Browse the repository at this point in the history
  • Loading branch information
maplesond committed Mar 13, 2018
2 parents 93561fc + d208993 commit 0e8c490
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 22 deletions.
11 changes: 8 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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 <prefix>/lib/python<version>/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

Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand All @@ -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}])
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 = .
Expand Down
53 changes: 35 additions & 18 deletions lib/include/kat/kat_fs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
14 changes: 14 additions & 0 deletions scripts/Makefile.am
Original file line number Diff line number Diff line change
@@ -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/ && \
Expand All @@ -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 \
Expand Down

0 comments on commit 0e8c490

Please sign in to comment.