[Distutils] unpacking files from and egg only for testing

Alexander Michael lxander.m at gmail.com
Sun May 13 17:44:29 CEST 2007


On 5/13/07, Alexander Schmolck <a.schmolck at gmx.net> wrote:
> Hi,
>
> I'm currently working on a package <http://www.scipy.org/MlabWrap> making the
> move from distutils to setuptools and I've got the following problem: although
> the code itself should work fine out of an egg, testing requires some a
> directory with some files to be created for matlab. Since it's only needed for
> testing I don't want to clutter the installers HD.
>
> How should I best handle this? Currently I'm just using ``zip_safe=False``,
> but a more elegant solution would seem to be for the test-code to temporarily
> unpack the relevant files from the egg into some temp-dir run the tests and
> delete the temp files again. I figure other projects might face a similar
> situation and I was wondering if some good solution is already available, or
> if I just should hack something together.

I don't think setuptools/pkg_resources/eggs are designed to handle
running tests like this after (end-user) installation. There is
support for running unittests during development as part of package
building. Does the end user *need* to run these tests to determine the
correct package configuration for their machine? If not, you should
probably wrap up the tests into a test suite and use the setuptools
test functionality
(<http://peak.telecommunity.com/DevCenter/setuptools#test-build-package-and-run-a-unittest-suite>)
 along with tempfile
(<http://docs.python.org/lib/module-tempfile.html>), otherwise I don't
think (but could have missed something) that eggs support running
arbitrary code at install time to do such configuration (hence
Enthought's postinstall extensions). If the latter, perhaps someone
else can be of more help.

Alex


More information about the Distutils-SIG mailing list