python - 使用 autotools 为多个版本的 Python 构建和安装

标签 python build-process autotools automake

我试图弄清楚如何为多个版本的 Python 构建我的项目。
我正在 Debian wheezy 上对此进行测试,其中 Python 的默认版本是 2.7。
但也支持并安装了 2.6。但是,automake 只是安装
并为 Python 2.7 编译。我也希望它为 2.6 编译。

这里是 configure.ac 和 Makefile.am。如有必要,我可以提供更多详细信息,但希望这些就足够了。

我是 Autotools 的初学者,因此可能有一些明显的解决方案。

似乎有一个关于此的愿望 list 错误:
RFE: build against multiple python stacks .还有
类似的讨论在这里:RFC: (automake) add support for dual python 2 / python 3 builds .

还有一个建议的解决方案(看起来很复杂),在
CDBS + Autotools + Python

这是configure.ac。

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

AC_PREREQ([2.69])
AC_INIT([corrmodel], [0.1], [faheem@faheem.info])
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
##################################################################################

这是 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

##################################################################################

最佳答案

Automake 的工作是创建一个由 configure 组成的构建系统。脚本和一组 Makefile 以适当的详细程度检测构建环境的属性,以便可以为该构建环境构建软件包。

构建环境可能只是 configure 的一组特定选项使用不同的选项运行编译器。或者用不同的编译器在同一台机器上运行。或者在容器或虚拟机中的另一个操作系统中,或者在两个装满构建服务器群的机架上。

定义、设置、访问和维护这些不同的构建环境不在 Automake 的范围内。您需要借助要用于此目的的任何工具集自行完成此操作。

然后您可以(或拥有您的特殊工具集)在这些不同的构建环境中运行 Automake 生成的构建系统来构建软件包。

关于python - 使用 autotools 为多个版本的 Python 构建和安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26826825/

相关文章:

c - 如何使用 Autotools 生成的 Makefile 在 Vim 中编译单个 C 文件

python - 没有正则化的sklearn LogisticRegression

python - 无法通过pip安装py3exiv2?

build-process - 在 scons 中检测 CPU 架构(32 位/64 位)?

c++ - 您使用了哪些策略来缩短大型项目的构建时间?

c - 我可以强制动态库链接到特定的动态库依赖项吗?

python - Pandas 中具有特定总长度的动态索引

python - 比较两个无序列表中各个元素的差异

linux - 构建过程因 maven 包而失败

packaging - 在安装到特定目录时包含额外文件