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

2024-09-30 06:19:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我开始在我的项目中使用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

我还试图定义PyExecltu库,但没有成功。我应该在Makefile.am文件中编写什么来编译和安装模块


Tags: 模块文件homemake定义myprojectallam
1条回答
网友
1楼 · 发布于 2024-09-30 06:19:59

很抱歉,这是我的一个小错误,问题不在Makefile.am文件中,但在configure.ac文件中,我只需将路径“pythonlib”添加到ac_CONFIG_文件中:

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

这样一切都很好

相关问题 更多 >

    热门问题