重新分发依赖于第三方库的 PyObjC 应用程序
我编写了一个 PyObjC 应用程序,该应用程序依赖于 Python paramiko (ssh) 库。有没有一种方法可以将第三方库添加到我的应用程序中,以便用户在运行应用程序之前不需要 sudo easy_install paramiko
?
我可以看到可以将 python 框架添加到我的项目中,但我认为这不会包含我的 /Library/Python/2.5/site-packages/paramiko 路径中的内容。或者,由于该项目是纯Python,我想我可以将它合并到我的代码中,但这似乎不是包含库的正确方法(而且我有兴趣知道如果库我需要的不是纯Python)。
有没有好方法在 PyObjC 应用程序中包含第三方 python 库?
虽然我在 OS X 10.5.8 上使用 XCode 3.1.4,但其他版本的 XCode 的说明应该没问题。
I've written a PyObjC application that depends on the Python paramiko (ssh) library. Is there a way that I can add the third-party library to my application so that users do not need to sudo easy_install paramiko
before running the application?
I can see that it is possible to add the python framework to my project, but I don't think that'd include what is in my /Library/Python/2.5/site-packages/paramiko path. Alternatively, as the project is pure python, I imagine I can just incorporate it into my code, but that really doesn't seem like a proper way to include a library (and I'd be interested in knowing what to do if the library I needed were not pure python).
Is there a good way to include a third-party python library in a PyObjC application?
While I am using XCode 3.1.4 on OS X 10.5.8, instructions for other versions of XCode should be fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎有效。
在 Xcode 中,右键单击“资源”并选择“添加 -> 现有文件...”。浏览到您的库的路径,在本例中为 /Library/Python/2.5/site-packages/paramiko,然后单击“添加”按钮。将出现一张表,询问您希望如何将其添加到项目中。确保选中“将项目复制到目标组的文件夹(如果需要)”,并且使用“为任何添加的文件夹创建文件夹引用”而不是默认的“为任何添加的文件夹递归创建组”。 [我将其他两个设置保留为默认值。引用类型:默认并添加到目标:YourApplicationName(选中)]
当您构建程序时,它现在会将文件夹复制到项目的 Resources 文件夹中,
import paramiko
时将在其中找到文件正在运行。我还必须以同样的方式导入 Crypto 库(我相信它不是一个纯 python 库)。当我在另一个没有必要库的 OS X 10.5 机器上测试它时,它运行良好。
This appears to work.
In Xcode, right click on "Resources" and choose "Add -> Existing Files ...". Browse to the path for your library, in this case, /Library/Python/2.5/site-packages/paramiko, and hit the "Add" button. A sheet will come up asking for how you want to add it to the project. Make sure "Copy items into destination group's folder (if needed)" is checked, and, instead of the default "Recursively create groups for any added folders" use "Create Folder References for any added folders". [I left the other two settings at their defaults. Reference Type: Default and Add To Targets: YourApplicationName (checked)]
When you build the program, it will now copy the folder into the Resources folder of your project, where the files will be found when
import paramiko
is run. I also has to import the Crypto library in the same way (and I believe it is not a pure python library).When I tested it on another OS X 10.5 box which did not have the requisite libraries, it ran fine.