2238
Comment:
|
3911
|
Deletions are marked like this. | Additions are marked like this. |
Line 83: | Line 83: |
5. Create a simple buildout around an egg and experiment with it. 1. Create an empty buildout area. | $ virtualenv --no-site-packages pycon | $ cd pycon | $ buildout init 2. Put into it a simple egg by creating a "buildout.cfg" file: | [buildout] | parts = mypython | prefer-final = true | | [mypython] | recipe = zc.recipe.egg | interpreter = dbpython | eggs = SQLObject 3. Invoke "bin/buildout" and examine the output messages, the directory structure and the *dbpython* script. Test for what version got installed and where it came from. | $ bin/dbpython | >>> import sqlobject | >>> sqlobject.__file__ | '/var/tmp/buildout/eggs/SQLObject-0.10.0-py2.5.egg/sqlobject/__init__.py' 4. Force it to use a specific version of SQLObject. | eggs = SQLObject==0.9 Test for what version got installed and where it came from. | $ bin/dbpython | >>> import sqlobject | >>> sqlobject.__file__ | '/var/tmp/buildout/eggs/SQLObject-0.9.0-py2.5.egg/sqlobject/__init__.py' 5. Remove that constraint and grab its source distribution. | $ bin/easy_install --editable -b . SQLObject Alter "buildout.cfg" file to make it a development egg: | develop = sqlobject Test for what version got installed and where it came from. | $ bin/dbpython | >>> import sqlobject | >>> sqlobject.__file__ | '/tmp/kkk/sqlobject/sqlobject/__init__.py' 6. ??? |
Eggs and Buildout Deployment in Python
Slides:
- Virtualenv
- Distutils
- Setuptools
- Buildout
Exercises:
Installing Tools for the Class
$ cd /tmp$ sudo python ez_setup.py$ sudo easy_install virtualenv$ sudo easy_install zc.buildoutInstantiating a Sandbox or Two
$ virtualenv pycon -or-$ virtualenv --no-site-packages pycon$ cd pycon$ bin/python$ source bin/activate -or- activate.bat$ deactivate
- explore:
- directory tree
- sys.path
- for each kind of sandbox
Processing Distributions
Grab a source distribution
$ /sandbox/bin/easy_install --editable --build-directory . SQLObject==0.9.5$ /sandbox/bin/easy_install --editable --build-directory . SQLObject==devExamine its directory structure and common files.
Query the list of available distribution formats.
$ cd sqlobject$ /sandbox/bin/python setup.py sdist --help-formats$ /sandbox/bin/python setup.py bdist --help-formatsBuild and package it as a binary distribution.
$ /sandbox/bin/python setup.py build$ /sandbox/bin/python setup.py install$ /sandbox/bin/python setup.py bdist --formats=tar,egg,rpmExamine the run output and the table-of-contents of the distribution archive afterward. Note the way that metadata is stored.
Repackage it as a source distribution
$ /sandbox/bin/python setup.py sdist --formats=zipExamine the run output and the table-of-contents of the source archive. Note the different way that metadata is stored.
Try to import it, then run the "develop" cmd and try again.
$ cd /sandbox$ /sandbox/bin/python$ import sqlobject$ cd /sandbox/sqlobject$ /sandbox/bin/python setup.py develop- ???
Create a simple buildout around an egg and experiment with it.
Create an empty buildout area.
$ virtualenv --no-site-packages pycon$ cd pycon$ buildout initPut into it a simple egg by creating a "buildout.cfg" file:
[buildout]parts = mypythonprefer-final = true[mypython]recipe = zc.recipe.egginterpreter = dbpythoneggs = SQLObjectInvoke "bin/buildout" and examine the output messages, the directory structure and the dbpython script.
Test for what version got installed and where it came from.
$ bin/dbpython>>> import sqlobject>>> sqlobject.__file__'/var/tmp/buildout/eggs/SQLObject-0.10.0-py2.5.egg/sqlobject/__init__.py'Force it to use a specific version of SQLObject.
eggs = SQLObject==0.9Test for what version got installed and where it came from.
$ bin/dbpython>>> import sqlobject>>> sqlobject.__file__'/var/tmp/buildout/eggs/SQLObject-0.9.0-py2.5.egg/sqlobject/__init__.py'Remove that constraint and grab its source distribution.
$ bin/easy_install --editable -b . SQLObjectAlter "buildout.cfg" file to make it a development egg:
develop = sqlobjectTest for what version got installed and where it came from.
$ bin/dbpython>>> import sqlobject>>> sqlobject.__file__'/tmp/kkk/sqlobject/sqlobject/__init__.py'- ???