Python Eggs

This is a summary of the content from network.

1) What is Python egg file ?
It’s simply a way of distributing Python packages, similar to RPM or Java jar package.

2) Where do I find the Python eggs ?
You can find Python eggs on quite a few places on the web, e.g. at a package author’s website. The biggest repository of eggs is the Cheeseshop (or PyPI) though), an index for Python packages.

3) How do I install the egg files ?
In order to be able to install eggs you simply need to install easy_install which is easily done by downloading ez_install.py (you candownload it here).
Once you have done this you can simply install an egg by calling:
easy_install somepackage.egg

You can also give a URL to an egg and use
easy_install http://somehost.somedomain.com/somepackage.egg

Note: If an egg is not found at that location or in the directory you give, easy_install will automatically query the Cheeseshop for the egg location.

4) How to create our own Python eggs ?

  1. Install setuptools (Ubuntu/Debian)
    sudo apt-get install python-setuptools
    There are two manual ways to install it
    • $ wget http://peak.telecommunity.com/dist/ez_setup.py
      $ sudo python ez_setup.py
      Update setuptools:
      $ sudo python ez_setup.py -U setuptools
    • $ wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
      $ sudo sh setuptools-0.6c11-py2.6.egg
  2. Create egg files (example)
    • The following is the directory structure
      README
      eventlet
      examples
      setup.py
    • The setup.py now looks like as the following. From the setup.py, we can see we define some meta information for the eventlet package

      #!/usr/bin/env python
      from distutils.core import setup
      setup(
          name='eventlet',
          version='0.1',
          description='Coroutine-based networking library',
          author='Linden Lab',
          author_email='sldev@lists.secondlife.com',
          url='http://wiki.secondlife.com/wiki/Eventlet',
          packages=['eventlet'])

    • Now so far it’s great but we might miss some features of eggs here, namely the ability to package it as one file, to register it with the cheeseshop and to define dependencies. So to add this we have to do just a few changes to setup.py. (So we added those classifiers to put it into the right categories on Cheeseshop and most importantly we added the requirement “greenlet”. If you then install the egg setuptools will automatically install greenlet as well.)
      #!/usr/bin/env python
      from distutils.core import setup
      setup(
          name='eventlet',
          version='0.1',
          description='Coroutine-based networking library',
          author='Linden Lab',
          author_email='sldev@lists.secondlife.com',
          url='http://wiki.secondlife.com/wiki/Eventlet',
          packages=['eventlet'],
          long_description="""\
            eventlet is a coroutines-based network library for python ...
            """,
          classifiers=[
                "License :: OSI Approved :: GNU General Public License (GPL)",
                "Programming Language :: Python",
                "Development Status :: 4 - Beta",
                "Intended Audience :: Developers",
                "Topic :: Internet",
            ],
          keywords='networking eventlet nonblocking internet',
          license='GPL',
          install_requires=[
              'setuptools',
              'greenlet',
            ],
          )
    • Create an egg by calling the following command. (This will create an egg distribution file which you can find indist/eventlet-0.1-py2.4.egg (if you used Python 2.4)
      python setup.py bdist_egg
    • You can check the contents by calling unzip -t eventlet-0.1-py2.4.egg and as you can see it’s basically the contents of the eventlet directory plus an EGG_INFO directory with metadata. Also included are the .pyc files as it’s a binary distribution.
5) The other way to create egg file by using paster (Python Paste)
What we are interested in is especially paste.script which is some sort of template based automation system.
  1. Install PasteScript
    easy_install -U PasteScript
  2. Now that PasteScript is installed you can list the available templates:
      $ paster create --list-templates
      Available templates:
      archetype:          A Plone project that uses Archetypes
      basic_namespace:    A project with a namespace package
      basic_package:      A basic setuptools-enabled package
      basic_zope:         A Zope project
      nested_namespace:   A project with two nested namespaces.
      paste_deploy:       A web application deployed through paste.deploy
      plone:              A Plone project
      plone2.5_buildout:  A buildout for Plone 2.5 projects
      plone2.5_theme:     A Theme for Plone 2.5
      plone2_theme:       A Theme Product for Plone 2.1 & Plone 2.5
      plone3_buildout:    A buildout for Plone 3 projects
      plone3_portlet:     A Plone 3 portlet
      plone3_theme:       A Theme for Plone 3.0
      plone_app:          A Plone App project
      plone_hosting:      Plone hosting: buildout with ZEO and any Plone version
      tgbase:             tg base template
      tgbig:              For more complex projects
      tgwidget:           TurboGears widget projects
      turbogears:         web framework

    (I have Turbogears installed as well which is why here are more templates listed than you have)

  3. The interesting ones for Python are basic_package and basic_namespace. We will usebasic_package for now as it creates a package ready for egg distribution.
    paster create -t basic_package
    and it will ask us a lot of questions, basically all the metadata we have to put into the setup.py file. After it’s finished you should have a new directory with a basic egg supporting structure.

6) How to uninstall the egg file ?

  1. Enter the directory where the egg file installed
    $ cd /usr/local/lib/python2.6/dist-packages
    $ cat easy-install.pth | grep eventlet
    ./eventlet-0.1.0-py2.6.egg
    $ ls -F|grep eventlet
    eventlet-0.1.0-py2.6.egg/
  2. delete 'eventlet' from easy-install.pth and then delete the eventlet-0.1.0-py2.6.egg directory

Reference:
http://mrtopf.de/blog/en/a-small-introduction-to-python-eggs/
http://www.worldhello.net/2010/12/08/2178.html

Vivado2023是一款集成开发环境软件,用于设计和验证FPGA(现场可编程门阵列)和可编程逻辑器件。对于使用Vivado2023的用户来说,license是必不可少的。 Vivado2023的license是一种许可证,用于授权用户合法使用该软件。许可证分为多种类型,包括评估许可证、开发许可证和节点许可证等。每种许可证都有不同的使用条件和功能。 评估许可证是免费提供的,让用户可以在一段时间内试用Vivado2023的全部功能。用户可以使用这个许可证来了解软件的性能和特点,对于初学者和小规模项目来说是一个很好的选择。但是,使用评估许可证的用户在使用期限过后需要购买正式的许可证才能继续使用软件。 开发许可证是付费的,可以永久使用Vivado2023的全部功能。这种许可证适用于需要长期使用Vivado2023进行开发的用户,通常是专业的FPGA设计师或工程师。购买开发许可证可以享受Vivado2023的技术支持和更新服务,确保软件始终保持最新的版本和功能。 节点许可证是用于多设备或分布式设计的许可证,可以在多个计算机上安装Vivado2023,并共享使用。节点许可证适用于大规模项目或需要多个处理节点进行设计的用户,可以提高工作效率和资源利用率。 总之,Vivado2023 license是用户在使用Vivado2023时必须考虑的问题。用户可以根据自己的需求选择合适的许可证类型,以便获取最佳的软件使用体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值