使用Autotools编译并将python模块安装到python库路径

问题描述 投票:1回答:1

我开始在项目中使用Autotool,并且有一个python模块,我希望将其编译为pyc并复制到python库的默认路径,以便在安装后即可导入它,而无需定义额外的环境变量。我可以找到许多用于python库的Makefile.am配置示例,但它们都使用SWIG,这不是我的情况。到目前为止,pythonlib子文件夹中的我的Makefile.am文件只有一行

python_PYTHON = mymodule.py

在configure.ac中,我具有:

AM_PATH_PYTHON([2.4])

以及在topdir Makefile.am中:

ACLOCAL_AMFLAGS = -I m4
SUBDIRS=src pythonlib
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@

但是在配置后,我运行make命令会得到:

Making all in pythonlib
make[2]: Entering directory '/home/golosio/myproject/pythonlib'
make[2]: *** No rule to make target 'all'.  Stop.
make[2]: Leaving directory '/home/golosio/myproject/pythonlib'
make[1]: *** [Makefile:426: all-recursive] Error 1
make[1]: Leaving directory '/home/golosio/myproject'
make: *** [Makefile:358: all] Error 2

我也尝试定义pyexec_LTLIBRARIES,但没有成功。我应该在Makefile.am文件中写些什么来编译和安装模块?

python autotools automake
1个回答
0
投票
[抱歉,这是我的一个小错误,问题不在Makefile.am文件中,而是在configure.ac文件中,我只需要将路径“ pythonlib”添加到AC_CONFIG_FILES:

AC_CONFIG_FILES([Makefile src/Makefile pythonlib/Makefile])

使用此方法,一切正常。
© www.soinside.com 2019 - 2024. All rights reserved.