[Distutils] Importable wheels using distlib/distil
Vinay Sajip
vinay_sajip at yahoo.co.uk
Thu Mar 28 17:02:36 CET 2013
Jim Fulton <jim <at> zope.com> writes:
> >> It would be far better IMO to just unzip the wheel and put that in
> >> your path. (I'm hoping that wheels used this way are a suitable
> >> replacement for eggs.)
> >
> > Well that's tantamount to installing the wheel,
>
> Not really. If you just unzip the wheel and add it to your path,
> you can stop using it by just removing from your path. If you
> install the wheel, it's contents will be poured into site-packages
> (and other places). It's much heavier than just adding the
> wheel (zipped or unzipped) to your path.
>
[snip]
> by adding (unzipped) eggs to sys.path. Various plugin
> systems (including buildout itself with extensions and recipes)
> do this dynamically at run time. It's very useful.
Thanks for the feedback. How about if I change mount()/unmount() to:
def mount(self, append=False, destdir=None):
"""
Unzip the wheel's contents to the specified directory, or to
a temporary directory if destdir is None. Add this directory to
sys.path, either appending or prepending according to whether
append is True or False.
Before doing this, check that the wheel is compatible with the
Python making the call to mount().
If successful, this makes the contents of the wheel's root directory
- both Python packages and C extensions - importable via normal Python
import mechanisms.
"""
def unmount(self):
"""
Remove the directory that was used for mounting from sys.path,
thus making the wheel's code no longer importable.
Return this directory. Note that the caller is responsible for
deleting this directory and its contents, which might not be
possible - e.g. in Windows, if a shared library has been
imported and is linked to the running Python process, there will be
an open handle to the shared library which will prevent its deletion.
"""
Regards,
Vinay Sajip
More information about the Distutils-SIG
mailing list