libtool python 模块链接和安装
我正在开发一个用 C 编写的项目,使用自动工具生成静态库。我还在同一项目的上下文中提供 C API 的 Python 接口。直到最近我才获得许可在项目中引入 libtool,以便能够以可移植的方式提供静态和动态库。到目前为止,我使用 distutils 生成 Python 共享模块,并将 python 模块链接到项目的 C 静态库。同样,那是因为我不被允许将 libtool/共享库引入到 ecuation 中。现在我想放入 libtool,我面临以下两个有问题的场景:
如果我继续使用 distutils 生成 Python 共享模块,由于 distutils 和 autotools 不互相通信,我需要告诉distutils 要链接到的 C 库。到目前为止,除了解析 .la 文件以获取 libtool 能够生成的库的名称和路径之外,我想不出任何方法可以做到这一点。 libtool 是否提供有关它能够在系统上生成什么类型的库的任何信息?
如果我将 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:
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 ?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你读过 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, addAM_PATH_PYTHON
toconfigure.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.