让 distutils 安装预构建的编译库?
我管理一个开源项目(Remix,源代码在那里可用)编写Python。 我们要求用户运行 python setup.py install 来安装该软件。 最近,我们添加了一个编译的 C++ 包(SoundTouch 的一个端口 - 转到源代码中的 trunk/externals 来查看它。)我们希望安装基本 Remix 库的 setup.py 文件也安装 pysoundtouch14 库。
但是,我们不希望用户的系统上必须有 gcc 或 msvc 工具链。 我们已经为常见平台(linux-i386、windows、mac 10.5 和 10.6)预编译了二进制文件,请转到 trunk/externals/pysoundtouch14/build 来查看它们。 我希望没有安装 gcc 或 msvc 的用户可以运行 pysoundtouch14 的 setup.py ,它会检测到我们预构建的二进制文件的存在,并将它们复制到正确的位置(/Library/Python/2.5/site-packages ,例如。)但这并没有发生。 例如,在新的 10.5 系统上,setup.py 抱怨没有安装 gcc,即使它需要安装的 .so 已经构建在 build/ 文件夹中。
所以我有两个直接问题:
- 如何让 setup.py 根据平台自动在正确的位置“安装”预构建的 .so 和 .pyd 文件,而不需要构建系统?
- 一个setup.py(我们的主setup.py文件)如何也运行另一个包含的包(pysoundtouch14的setup.py?)的setup.py?
I manage an open source project (Remix, the source is available there) written in python. We ask users to run python setup.py install to install the software. Recently we added a compiled C++ package (a port of SoundTouch -- go to trunk/externals in the source to see it.) We'd like the setup.py file that installs the base Remix libraries to also install the pysoundtouch14 library.
However, we don't want users to have to have a gcc or msvc toolchain on their system. We've precompiled binaries for common platforms (linux-i386, windows, mac 10.5 and 10.6), go to trunk/externals/pysoundtouch14/build to see them. I was hoping that a user who does not have gcc or msvc installed could just run pysoundtouch14's setup.py and it would detect the presence of our prebuilt binaries and just copy them to the right place (/Library/Python/2.5/site-packages, for example.) But that doesn't happen. On a new 10.5 system, for example, setup.py complains about no gcc being installed even though the .so it needs to install is already built in the build/ folder.
So I have two direct questions:
- How can I get setup.py to just "install" prebuilt .so and .pyd files in the right place automatically depending on the platform without requiring a build system?
- How can one setup.py (our main setup.py file) also run the setup.py of another included package (pysoundtouch14's setup.py?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
考虑到多平台要求,你的第一个问题是一个棘手的问题。 如果只是 Windows,您可以使用安装后脚本选项来运行脚本来处理库,或者仅使用非 python 工具,例如 NSIS。 我不确定除了阿尔马德的建议之外还能做什么。
对于第二个问题,您可能需要查看 Paver。
Your first question is a tough one given the multiplatform requirement. If it was just windows, you could use the post-installation script option to run a script to handle the libraries or just use a non-python tool such as NSIS. I'm not sure what else can be done other than Almad's suggestion.
For your second question, you might want to look into Paver.
不幸的是,我想说覆盖安装命令是正确的方法。
使用自定义分发命令可以轻松完成此操作。 例如,参见[1]
http://svn.zope.org/ Zope/branches/2.9/setup.py?rev=69978&view=auto
Unfortunately, I'd say that overriding install command is the way to go.
This can be done easily, using custom distribution command. For example, see [1]
http://svn.zope.org/Zope/branches/2.9/setup.py?rev=69978&view=auto