[Distutils] local development scenarios
Todd Greenwood-Geer
tgreenwoodgeer at yahoo.com
Fri Dec 9 05:27:58 CET 2005
Great, thanks Phillip. Now that you mention the part about the scripts
generation, I remember reading that in the docs. Thanks for clearing
things up.
Regarding the unit tests...let me add a bit more to the question.
Typically, as I'm developing a module, I embed doctests in the module.
This lets me maintain a known good state throughout my dev cycle. Then,
as I start to wrap things up, I create a standard unit test to wrap the
doctests. Finally, I reference a method in the unit test that gives back
the test suite (code sample attached). I reference this test suite in
the setup.py for the given egg. So the question is, given that my
friend/client is receiving eggs, how can they perform the equivalent of
'$python setup.py test'? Currently, I have suggested that they unzip the
egg and run the unittests dirctly from the unzipped files...something
like this:
- unzip foo.egg
- cd foo
- python src/foo/unittest.py
I'm attaching rest and html formatted copies of my blog tutorial entry
on using setup tools...feel free to comment on that as well.
small.py::
#example method with doctest compatible docstring
def removeme():
"""
>>> import small as m
>>> m.removeme()
'remove me'
"""
return 'remove me'
def _test():
import doctest
return doctest.testmod()
if __name__ == "__main__":
_test()
small_unittest.py::
import small
import unittest
import doctest
def getTestSuite():
suite = unittest.TestSuite()
for mod in small,:
suite.addTest(doctest.DocTestSuite(mod))
return suite
runner = unittest.TextTestRunner()
runner.run(getTestSuite())
setup.py::
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages
setup(name = "small",
version = "0.1",
description = "test",
author = "Todd Greenwood",
author_email = "t.greenwoodgeer at gmail.com",
url = "http://www.angelfire.com/planet/tango",
packages = find_packages('src'),
package_dir = {'':'src'},
package_data = {'small':['test/*.txt']},
test_suite = 'small.small_unittest.getTestSuite',
license = "GNU Lesser General Public License",
classifiers = [
"Development Status :: 1 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Library or Lesser
General Public License (LGPL)",
"Programming Language :: Python",
"Topic :: Database :: Front-Ends",
]
)
-Todd
Phillip J. Eby wrote:
> At 10:25 PM 12/7/2005 -0800, tgreenwood wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> I'm new to distutils/and the egg system. I have not researched the
>> archives as much as I should, so please excuse me if this is familiar
>> territory...
>>
>> Q: Is it possible for dependency checks to work for non pipy deployed
>> eggs?
>> - A.egg
>> - B.egg (setup_requires and install_requires A.egg)
>> - email A and B eggs to friend
>> - tell friend to : easy_install B
>> - but B.egg does not install A...in fact, in my test case, it fails b/c
>> it cannot find A in pipy
>
> This will work if the eggs are both in the current directory:
>
> easy_install -f. B
>
> -f (aka --find-links) specifies URLs or directories that will be scanned
> *before* going to PyPI to meet dependencies.
>
>
>> - in this example, what happens if friend does not have net connection
>> on target machine? how can they install from the eggs alone and get the
>> dep checking to work?
>
> No net connection is necessary if all dependencies can be found using -f
> directories.
>
>
>> Q: How does my friend run the unittests on the egg that they have just
>> installed? As I am developing, I frequently run the unittests and after
>> every bdist_egg build, I also run the unit tests that way, too. How can
>> the consumer do the same?
>
> Well, if it's a unit test suite that's contained within the egg, then
> they could use the unittest utility just as they normally would.
>
>
>> Q: One of my apps is a command line app, say foo.py is a command line
>> app that takes arg1, arg2,... How can the user run this app when it is
>> encased in an egg?
>
> EasyInstall generates wrapper scripts during installation that ensure
> the needed eggs are on sys.path and run the scripts. This works for
> both standard distutils scripts (specified using setup(scripts=[...]))
> and for entry point scripts (see the setuptools doc).
>
> The --script-dir argument to easy_install controls where scripts are
> installed; it defaults to the same as the installation directory if an
> installation directory is manually specified; otherwise it defaults to
> wherever the distutils are configured to install scripts.
>
>
>> Q: How do I define my own pipy? While I like the idea of deploying there
>> for the overall community, I don't want to send my half baked code into
>> the wild. But I'd like to try the general functionality of having a
>> deploy site for my beta customers. How can I set this up?
>
> Using -f with the URL of a web page with download links to your eggs or
> source distributions. See http://turbogears.org/download/ for one
> example. In the simplest case, a simple Apache directory listing will
> do the trick; see http://peak.telecommunity.com/snapshots/ for an
> example of that approach. Simply having someone use a URL like that
> with -f ensures that any download links on the page will be given
> precedence over PyPI listings, if it's possible to meet all requirements
> that way.
>
> Only if a dependency can't be satisfied by links on a -f page, will PyPI
> be consulted.
>
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: small_tutorial.rest
Url: http://mail.python.org/pipermail/distutils-sig/attachments/20051208/d322bcca/small_tutorial-0001.asc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/distutils-sig/attachments/20051208/d322bcca/small_tutorial-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://mail.python.org/pipermail/distutils-sig/attachments/20051208/d322bcca/signature-0001.pgp
More information about the Distutils-SIG
mailing list