【问题标题】:Using Autotools to compile and install a python module to the python library path使用Autotools编译安装python模块到python库路径
【发布时间】:2020-02-17 12:33:18
【问题描述】:

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

python_PYTHON = mymodule.py

在 configure.ac 我有:

AM_PATH_PYTHON([2.4])

在顶层目录 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】:

    对不起,这是我的一个小错误,问题不在 Makefile.am 文件中,而是在 configure.ac 文件中,我只需将路径“pythonlib”添加到 AC_CONFIG_FILES:

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

    有了这个一切正常。

    【讨论】:

    • 您介意接受这个答案,以便这个问题显示为已回答吗?谢谢。
    猜你喜欢
    • 2019-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多