Egg

From Wikinico

Jump to: navigation, search

Create the egg

setup.py

#from distutils.core import setup
from setuptools import setup

setup( name='egg_name', version='1.0', packages=['package_A', 'package_B', 'package_C', 'package_D'], )

To create the egg:

python setup.py bdist_egg

http://www.packtpub.com/article/writing-a-package-in-python

Develop with eggs

In each module create a file : EggManager.py

class EggManager( object ):
    @staticmethod
    def smith_use_egg():
        return True

    @staticmethod
    def smith():
        return 'smith==1.4'


In each file external to smith using something in smith:

from myclientmodule.EggManager import EggManager
from pkg_resources import require

if EggManager.smith_use_egg():
    require( EggManager.smith() )

import smith
Personal tools