Commit 4a7da8a9 authored by Tiago Peixoto's avatar Tiago Peixoto

Directory restructuring of graph_tool Python module (now a package)

Everything was moved into the graph_tool directory, which should have,
after installation, the following structure:

graph_tool/                          Top-level package
      __init__.py                    Initialize the graph_tool package
      libgraph_tool.so               libgraph_tool submodule
      libgraph_tool.la               libtool file for libgraph_tool
      include/                       C++ include files for dynamically
                                     compiled code
parent 0c1f0df2
dnl Process this file with autoconf to produce a configure script.
AC_INIT(graph-tool, 1.2.0devel)
AC_INIT(graph-tool, 1.2.0devel, [http://graph-tool.forked.de])
AC_CONFIG_SRCDIR(src/graph-tool)
AM_INIT_AUTOMAKE
AM_PROG_CC_C_O
......@@ -21,13 +21,13 @@ dnl Checks for options
dnl Turn debugging on or off
AC_MSG_CHECKING(whether to enable debug info...)
AC_ARG_ENABLE([debug], [AC_HELP_STRING([--enable-debug@<:@=full@:>@],
[compile debug information [default=yes] ])],
[AC_MSG_RESULT(yes)]
[AC_DEFINE([DEBUG], 1, [compile debug info])]
[CXXFLAGS=" $CXXFLAGS -ggdb3 "],
[AC_MSG_RESULT(no)]
[AC_MSG_RESULT(no)]
)
dnl set template depth and hidden visibility
......@@ -35,7 +35,7 @@ dnl set template depth and hidden visibility
[CXXFLAGS="$CXXFLAGS -ftemplate-depth-150 "]
AC_MSG_CHECKING(whether to enable function inlining...)
AC_ARG_ENABLE([inline], [AC_HELP_STRING([--disable-inline],
[disable inline functions [default=enabled] ])],
if test $enableval = no; then
......@@ -50,11 +50,11 @@ AC_ARG_ENABLE([inline], [AC_HELP_STRING([--disable-inline],
[AC_MSG_RESULT(yes)]
NO_INLINE=no
)
AM_CONDITIONAL(NO_INLINE, test $NO_INLINE = yes)
AC_MSG_CHECKING(whether to enable optimizations...)
AC_ARG_ENABLE([optimization], [AC_HELP_STRING([--disable-optimization],
[disable optimization [default=enabled] ])],
[AC_MSG_RESULT(no)]
......@@ -64,7 +64,7 @@ AC_ARG_ENABLE([optimization], [AC_HELP_STRING([--disable-optimization],
)
AC_MSG_CHECKING(whether to enable hidden visibility...)
AC_ARG_ENABLE([visibility], [AC_HELP_STRING([--disable-visibility],
[disable hidden visibility [default=enabled] ])],
[AC_MSG_RESULT(no)]
......@@ -95,8 +95,8 @@ AC_ARG_ENABLE([openmp], [AC_HELP_STRING([--enable-openmp],
if test $enableval = yes; then
[AC_MSG_RESULT(yes)]
[AC_DEFINE([USING_OPENMP], 1, [using openmp])]
USING_OPENMP=yes
[CXXFLAGS="$CXXFLAGS -fopenmp"]
USING_OPENMP=yes
[CXXFLAGS="$CXXFLAGS -fopenmp"]
[OPENMP_LDFLAGS=" -lgomp "]
fi
,
......@@ -108,7 +108,7 @@ AC_ARG_ENABLE([openmp], [AC_HELP_STRING([--enable-openmp],
)
AC_SUBST(OPENMP_LDFLAGS)
dnl Checks for programs.
dnl Checks for libraries.
......@@ -164,6 +164,12 @@ AC_SUBST(NO_PREFIX_PACKAGE_DOC_DIR)
PACKAGE_DOC_DIR="${packageprefix}/${packagedocdir}"
AC_SUBST(PACKAGE_DOC_DIR)
dnl Subst PYTHON_DIR.
AC_DEFINE_UNQUOTED([INSTALL_PREFIX],"${prefix}", [python prefix])
AC_DEFINE_UNQUOTED([PYTHON_DIR], "${pythondir}", [The directory name for the site-packages subdirectory of the standard Python install tree.])
AC_DEFINE_UNQUOTED([CXXFLAGS],"${CXXFLAGS}", [c++ compilation options])
AC_DEFINE_UNQUOTED([PACKAGE_DATA_DIR], "${packageprefix}/${packagedatadir}", [package data dir])
AC_DEFINE_UNQUOTED([PACKAGE_DOC_DIR], "${packageprefix}/${packagedocdir}", [package doc dir])
AC_DEFINE_UNQUOTED([PACKAGE_SOURCE_DIR], "${packagesrcdir}", [package source dir])
......@@ -181,5 +187,6 @@ AC_OUTPUT([
Makefile
src/Makefile
src/graph/Makefile
src/graph_tool/Makefile
])
......@@ -2,10 +2,7 @@
AUTOMAKE_OPTIONS = subdir-objects
SUBDIRS = graph .
graph_tool_PYTHON = graph_tool.py
graph_tooldir = $(pythondir)
SUBDIRS = graph graph_tool .
bin_SCRIPTS = graph-tool
......@@ -12,13 +12,11 @@ AM_CXXFLAGS =\
AM_CFLAGS=$(AM_CXXFLAGS)
libgraph_tool_ladir = ${pythondir}
libgraph_tool_includedir = $(includedir)/graph_tool
install-data-hook:
chmod 755 $(includedir)/graph_tool
libgraph_tooldir = $(pythondir)/graph_tool
libgraph_tool_LTLIBRARIES = libgraph_tool.la
lib_LTLIBRARIES = libgraph_tool.la
libgraph_tool_la_includedir = $(pythondir)/graph_tool/include
libgraph_tool_la_SOURCES = \
graph.hh\
......@@ -51,7 +49,7 @@ libgraph_tool_la_SOURCES = \
../boost-workaround/boost/graph/fruchterman_reingold.hpp\
../boost-workaround/boost/graph/graphml.hpp
libgraph_tool_include_HEADERS = \
libgraph_tool_la_include_HEADERS = \
graph_adaptor.hh\
graph.hh\
graph_filtering.hh\
......@@ -73,4 +71,9 @@ libgraph_tool_la_LIBADD = \
# needed for typeinfo objects to work across DSO boundaries.
# see http://gcc.gnu.org/faq.html#dso
libgraph_tool_la_LDFLAGS = \
-Wl,-E
-module \
-avoid-version \
-export-dynamic \
-no-undefined \
-Wl,-E
......@@ -225,6 +225,9 @@ struct LibInfo
string GetCopyright() const {return COPYRIGHT;}
string GetVersion() const {return VERSION " (commit " GIT_COMMIT ", " GIT_COMMIT_DATE ")";}
string GetLicense() const {return "GPL version 3 or above";}
string GetCXXFLAGS() const {return CXXFLAGS;}
string GetInstallPrefix() const {return INSTALL_PREFIX;}
string GetPythonDir() const {return PYTHON_DIR;}
};
// overloads
......@@ -357,5 +360,8 @@ BOOST_PYTHON_MODULE(libgraph_tool)
.add_property("author", &LibInfo::GetAuthor)
.add_property("copyright", &LibInfo::GetCopyright)
.add_property("version", &LibInfo::GetVersion)
.add_property("license", &LibInfo::GetLicense);
.add_property("license", &LibInfo::GetLicense)
.add_property("cxxflags", &LibInfo::GetCXXFLAGS)
.add_property("install_prefix", &LibInfo::GetInstallPrefix)
.add_property("python_dir", &LibInfo::GetPythonDir);
}
## Process this file with automake to produce Makefile.in
graph_tool_PYTHON = __init__.py
graph_tooldir = $(pythondir)/graph_tool
......@@ -1049,26 +1049,31 @@ class Graph(object):
raise GraphError(self, "You need to have scipy installed to use" + \
" 'run_action'.")
prefix_dir = libgraph_tool.mod_info().install_prefix
python_dir = libgraph_tool.mod_info().python_dir
python_dir = string.Template(python_dir).substitute(prefix=prefix_dir)
cxxflags = libgraph_tool.mod_info().cxxflags
# this is the code template which defines the action functor
support_template = r"""
#include <map>
#include <set>
#include <list>
#include <tr1/unordered_set>
#include <tr1/unordered_map>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/type_traits.hpp>
#include <graph_tool/graph.hh>
#include <graph_tool/graph_filtering.hh>
#include <graph_tool/graph_properties.hh>
#include "${include_prefix}/graph.hh"
#include "${include_prefix}/graph_filtering.hh"
#include "${include_prefix}/graph_properties.hh"
using namespace boost;
using namespace boost::tuples;
using namespace std;
using namespace graph_tool;
template <class IndexMap>
struct prop_bind_t
{
......@@ -1155,9 +1160,12 @@ class Graph(object):
arg_expansion = "\n".join([ exp_term % (i,arg_names[i],i) for i in \
xrange(0, len(arg_names))])
support_template = string.Template(support_template)
inc_prefix = python_dir + "/graph_tool/include"
support_code = support_template.substitute(code_hash=code_hash,
arg_expansion=arg_expansion,
code=code) + support_code
code=code,
include_prefix = inc_prefix)\
+ support_code
# insert a hash value of the support_code into the code below, to force
# recompilation when support_code (and module version) changes
......@@ -1199,12 +1207,12 @@ class Graph(object):
support_code=support_code,
libraries=["graph_tool"] + libraries,
library_dirs=sys.path + library_dirs,
extra_compile_args=["-O3","-ftemplate-depth-150",
"-Wall", "-Wno-deprecated"] + \
extra_compile_args=[cxxflags] + \
extra_compile_args,
runtime_library_dirs=runtime_library_dirs,
extra_objects=extra_objects,
extra_link_args=["-Wl,-E"]+extra_link_args)
extra_link_args=["-L" + python_dir + "/graph_tool/",
"-Wl,-E"] + extra_link_args)
sys.setdlopenflags(_orig_dlopen_flags) # reset dlopen to normal case to
# avoid unnecessary symbol
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment