4
votes

I'm trying to figure out how to build my project for multiple versions of Python. I'm testing this on Debian wheezy, where the default version of Python is 2.7. but 2.6 is also supported and installed. However, automake is only installing and compiling for Python 2.7. I'd like it to compile for 2.6 as well.

Here are the configure.ac and Makefile.am. I can provide more details if necessary, but hopefully these will suffice.

I'm a beginner with Autotools, so there may be some obvious solution to this.

There is what appears to be a wishlist bug about this: RFE: build against multiple python stacks. There is also a similar discussion here: RFC: (automake) add support for dual python 2 / python 3 builds.

There is also a proposed solution (which looks complicated), given at CDBS + Autotools + Python

This is configure.ac.

##################################################################################
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT([corrmodel], [0.1], [[email protected]])
AM_INIT_AUTOMAKE([foreign -Wall -Werror -Wno-extra-portability parallel-tests])
AM_MAINTAINER_MODE
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AM_PATH_PYTHON([2.6])

# Checks for libraries.
AX_BOOST_BASE
AX_BOOST_PYTHON

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

#AC_CONFIG_SUBDIRS([hello/hello-2.9])
LT_INIT
AC_OUTPUT
##################################################################################

Here is Makefile.am.

##################################################################################
# Define primaries
noinst_LTLIBRARIES = libcommon.la
dist_sysconf_DATA = corrmodel/default_conf.yaml

COMMON_CPPFLAGS = -I /usr/include/python$(PYTHON_VERSION) -L/usr/lib/python$(PYTHON_VERSION)/config -ftemplate-depth-100 -fno-strict-aliasing -fno-common -ansi -Wextra -Wall -Werror -Wno-unused-function -Wc++0x-compat -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -std=c++11 -march=native -mtune=native -mfpmath=sse -msse3 -O3 -DBOOST_PYTHON_DYNAMIC_LIB -DBOOST_PYTHON_MAX_ARITY=20
libcommon_la_SOURCES = randutil.cc util.cc gendata_fn.cc model.cc score_fn.cc search_fn.cc pval.cc print.cc \
                       common.hh util.hh model.hh gendata_fn.hh randutil.hh score_fn.hh search_fn.hh pval.hh \
                       print.hh
COMMON_LDFLAGS = -lblitz -lRmath -lpython$(PYTHON_VERSION) -lm -lboost_python
libcommon_la_CPPFLAGS = $(COMMON_CPPFLAGS)
#libcommon_la_LDFLAGS = $(COMMON_LDFLAGS)

# name of Python library.
# See http://www.gnu.org/software/automake/manual/html_node/Python.html
pkgpyexec_LTLIBRARIES = cpplib.la
cpplib_la_SOURCES = cpparr_conv_pif.cc cppmap_conv_pif.cc cpppair_conv_pif.cc cppset_conv_pif.cc cpptup_conv_pif.cc \
                    cppvec_conv_pif.cc cppunicode_conv_pif.cc util_pif.cc gendata_fn_pif.cc model_pif.cc score_fn_pif.cc \
                    search_fn_pif.cc pval_pif.cc main.cc conv_pif.hh util_pif.hh gendata_fn_pif.hh score_fn_pif.hh search_fn_pif.hh
cpplib_la_CPPFLAGS = $(COMMON_CPPFLAGS)
cpplib_la_LDFLAGS = -module -avoid-version -share $(COMMON_LDFLAGS)

cpplib_la_LIBADD = libcommon.la

ACLOCAL_AMFLAGS = -I m4

pkgpython_PYTHON =  corrmodel/dbschema.py corrmodel/__init__.py corrmodel/init_schema.py  corrmodel/modeldist.py corrmodel/crossval.py corrmodel/dbutils.py corrmodel/getmodel.py corrmodel/load.py corrmodel/utils.py

##################################################################################
1
did you ever find a solution? I'm looking to do this for a project that needs to work with python2 and python3matt
Hi @matt. It's so long ago I don't even remember writing this question, but I don't think I ever did find an answer. If you do find an answer, please post it. Thanks.Faheem Mitha

1 Answers

0
votes

Automake's job is to create a buildsystem consisting of a configure script and a set of Makefiles which detect the properties of the build environment in an appropriate level of detail so the software package can be built for that build environment.

Build environments might be just a specific set of options to configure to run your compiler with different options. Or to run with a different compiler the same machine. Or inside another operating system in a container or a VM, or on two racks full of build server farms.

Defining, setting up, accessing and maintaining those different build environments is outside of Automake's scope. You need to do that yourself with the help of whatever set of tools you want to use for that.

Then you can (or have your special tool set) run the Automake generated buildsystem within these different build environments to build the software package.