libtool python 模块链接和安装

发布于 2024-10-17 00:03:18 字数 881 浏览 1 评论 0原文

我正在开发一个用 C 编写的项目,使用自动工具生成静态库。我还在同一项目的上下文中提供 C API 的 Python 接口。直到最近我才获得许可在项目中引入 libtool,以便能够以可移植的方式提供静态和动态库。到目前为止,我使用 distutils 生成 Python 共享模块,并将 python 模块链接到项目的 C 静态库。同样,那是因为我不被允许将 libtool/共享库引入到 ecuation 中。现在我想放入 libtool,我面临以下两个有问题的场景:

  1. 如果我继续使用 distutils 生成 Python 共享模块,由于 distutils 和 autotools 不互相通信,我需要告诉distutils 要链接到的 C 库。到目前为止,除了解析 .la 文件以获取 libtool 能够生成的库的名称和路径之外,我想不出任何方法可以做到这一点。 libtool 是否提供有关它能够在系统上生成什么类型​​的库的任何信息?

  2. 如果我将 Python 模块生产移至 automake,那没问题,直到进入安装过程。我不知道如何告诉 libtool 我希望我的 Python 模块位于 lib 文件夹之外的其他位置,即“lib/python2.5/site-packages/myproject”。我尝试过 只需复制 Makefile 中的库,但是这无法正常工作,因为库的 rpath 错误(构建的路径,而不是安装的路径)。为什么我想要它在那里?因为我还有 .py 包装器。那么,有没有办法告诉 libtool 在其他地方安装我的模块并正确设置 rpath ?

我想我只是在寻找一个优雅的解决方案,或者也许解决方案就在那里,而且很简单,但我看不到它,因为我经验不足。有什么帮助吗?

PS 如果我能让它工作的话,我会更喜欢选项 2,因为这样我就不必将信息从 autotools 传递到 distutils。

I work on a project written in C, using the autotools, that produces a static library. Am also providing a Python interface to the C API in the context of the same project. I did not have permission until recently to introduce libtool in the project, in order to be able to provide both static and dynamic libraries in a portable fashion. So far, I'd produce the Python shared module using the distutils, and link the python module to the project's C static library. Again, that's because I was not allowed to introduce libtool/shared libraries into the ecuation. Now that I want to put libtool in, I am facing the following two problematic scenarios:

  1. If I keep producing the Python shared module using the distutils, since the distutils and the autotools do not talk to eachother, I need to tell the distutils what C library to link to. So far, I cannot think of any way of doing that but parsing the .la file to get the name and path of the library libtool was able to produce. Does libtool provide any information with regards to what type of library it was able to produce on a system ?

  2. If I move the Python module production to automake, that's fine, until I reach the installation process. I have not idea how to tell libtool I want my Python module somewhere else but the lib folder, i.e. 'lib/python2.5/site-packages/myproject'. I tried to
    just copy the library in the Makefile however that did not work properly as the library had the wrong rpath (that of the build and not that of the install). Why do I want it there ? Because there I also have the .py wrappers. So, is there any way to tell libtool to install my module somewhere else and properly set the rpath ?

I guess I'm just looking for an elegant solution, or maybe the solution is there and it's simple but I can't see it as I'm not experienced enough. Any help ?

P.S. Would prefer option 2, if I could make it work, since that way I would not have to pass information from the autotools to the distutils.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷你仙 2024-10-24 00:03:18

你读过 http://www.gnu.org/software/hello/手册/automake/Python.html?我不知道您是否想使用 pyexecdir 作为安装模块的位置。如果是这样,请将 AM_PATH_PYTHON 添加到 configure.ac

无论如何,在 automake 中,_PRIMARY 之前的名称指定要安装某些内容的位置:lib_LTLIBRARIES 将在 $(libdir) 中安装库, pyexec_LTLIBRARIES 将安装到 $(pyexecdir)bin_PROGRAMS 将安装到 $(bindir),依此类推。

Have you read http://www.gnu.org/software/hello/manual/automake/Python.html ? I can't tell if you want to use pyexecdir as the location to install your modules. If so, add AM_PATH_PYTHON to configure.ac.

Anyway, in automake, the name before the _PRIMARY specifies where something is to be installed: lib_LTLIBRARIES will install the library in $(libdir), pyexec_LTLIBRARIES will install to $(pyexecdir), bin_PROGRAMS will install to $(bindir), and so on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文