Mac OS X上框架与非框架构建Python之间的差异 [英] Differences between Framework and non-Framework builds of Python on Mac OS X

查看:113
本文介绍了Mac OS X上框架与非框架构建Python之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题



在Mac OS X上,Framework构建与Python的非构建(即标准UNIX构建)Python之间有什么区别?另外,每种方法的优缺点是什么?

初步研究



以下是我找到的信息在发布此问题之前:


  • [Pythonmac-SIG]为什么需要Python的框架构建


    • B。 Grainger:我似乎记得,如果你想用本地Mac GUI做任何事情,就需要Python的Framework构建,我的理解是否正确?

    • C。 Barker:非常多 - 要访问Mac GUI,一个应用程序需要在一个合适的Mac应用程序包中.Framework构建提供了这个功能。


  • < li>


    • 框架是一个包(一个结构化目录),它包含一个动态共享库以及相关的资源,例如nib文件,图像文件和头文件当你开发一个应用程序时,你的项目链接到一个或多个框架,例如,iPhone应用程序项目默认链接到Foundation,UIKit和Core Graphics框架,你的代码通过框架访问框架的功能应用程序编程接口(API),由框架通过其头文件发布,因为该库是动态共享的,所以多个应用程序可以访问框架c颂歌和资源同时。系统根据需要将框架的代码和资源加载到内存中,并在所有应用程序中共享资源的一个副本。


    • 框架编程指南:框架是什么?


      • 框架与静态链接库和其他类型的动态共享库相比具有以下优点:


        • 框架组将相关但相互独立的资源组合在一起。此分组使得安装,卸载和查找这些资源变得更加轻松。

        • 框架可以包含比库更多的资源类型。例如,一个框架可以包含任何相关的头文件和文档。
          一个框架的多个版本可以包含在同一个包中。这使得向后兼容旧程序成为可能。
        • 无论有多少进程正在使用,只有一个框架只读资源的副本在任何给定时间都驻留在内存中这些资源。这种资源共享减少了系统的内存占用,并有助于提高性能。





      背景



      在Mac OS X 10.6 Snow Leopard之前,我对此没有太多的了解,因为我只需下载并安装 Python 2.6.2 Mac安装程序磁盘映像,这是一个框架构建,并且使用virtualenv,pip等来开展业务。然而,随着Snow Leopard在64位,gcc等方面的变化,我注意到一些问题让我想自己编译/编译Python 2.6.2+从源代码开始,这引出了我将Python构建为MacOSX | Darwin框架的差异和优缺点的问题。

      >您已经列出了构建框架的所有重要优势(祝贺优秀的研究和报告!);唯一的缺点是很难安排一个正确的构建,但如果你从你引用的安装程序中的例子中获得线索,它应该是可行的。

      顺便说一句,这有什么问题Snow Leopard附带的系统Python?我还没有从Leopard升级(长篇故事......我有家庭执照升级DVD,但是需要雪豹在升级之前修复一些东西),所以我还没有第一手的经验,但我确实知道这是一个2.6版本,它有32位和64位版本......所以你为什么需要构建自己的框架?


      Question

      What are the differences between a Framework build and a non-Framework build (i.e., standard UNIX build) of Python on Mac OS X? Also, what are the advantages and disadvantages of each?

      Preliminary Research

      Here is the information that I found prior to posting this question:

      • [Pythonmac-SIG] Why is Framework build of Python needed
        • B. Grainger: "I seem to recall that a Framework build of Python is needed if you want to do anything with the native Mac GUI. Is my understanding correct?"
        • C. Barker: "Pretty much -- to access the Mac GUI, an app needs to be in a proper Mac application bundle. The Framework build supplies that."
      • Apple Developer Connection: Framework Definition
        • "A framework is a bundle (a structured directory) that contains a dynamic shared library along with associated resources, such as nib files, image files, and header files. When you develop an application, your project links to one or more frameworks. For example, iPhone application projects link by default to the Foundation, UIKit, and Core Graphics frameworks. Your code accesses the capabilities of a framework through the application programming interface (API), which is published by the framework through its header files. Because the library is dynamically shared, multiple applications can access the framework code and resources simultaneously. The system loads the code and resources of a framework into memory, as needed, and shares the one copy of a resource among all applications."
      • Framework Programming Guide: What are Frameworks?
        • "Frameworks offer the following advantages over static-linked libraries and other types of dynamic shared libraries:
          • Frameworks group related, but separate, resources together. This grouping makes it easier to install, uninstall, and locate those resources.
          • Frameworks can include a wider variety of resource types than libraries. For example, a framework can include any relevant header files and documentation. Multiple versions of a framework can be included in the same bundle. This makes it possible to be backward compatible with older programs.
          • Only one copy of a framework’s read-only resources reside physically in-memory at any given time, regardless of how many processes are using those resources. This sharing of resources reduces the memory footprint of the system and helps improve performance."

      Background

      Prior to Mac OS X 10.6 Snow Leopard, I hadn't thought much about this, as I simply would download and install the Python 2.6.2 Mac Installer Disk Image, which is a framework build, and go about my business using virtualenv, pip, etc. However, with the changes in Snow Leopard to 64-bit, gcc, etc., I've noticed some issues that have made me want to build/compile Python 2.6.2+ myself from source, which leads me to my question of the differences and advantages/disadvantages of building Python as a MacOSX|Darwin framework.

      解决方案

      You've already listed all important advantages of making a framework (congratulations for excellent research and reporting thereof!); the only flip side is that it's harder to arrange to build one properly, but if you take your clues from the examples in the installer you quote, it should be doable.

      BTW, what's wrong with the system Python that comes with Snow Leopard? I haven't upgraded from Leopard yet (long story... I do have the "family license" upgrade DVD, but need Snow Leopard to fix some things before I can upgrade), so I have no first-hand experience with that yet, but I do know it's a 2.6 build and it comes in both 32-bit and 64-bit versions... so why do you need to build your own framework?

      这篇关于Mac OS X上框架与非框架构建Python之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆