diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-10-01 18:55:08 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-10-01 18:55:08 -0400 |
commit | 907a37e75e7011ba5cbca0300981800cb2884410 (patch) | |
tree | 44eed47049606eb3036c4da1a85dcc9fbda92ced /mako/util.py | |
parent | a6b60799419dd5d304ad2203f6309157bd73c240 (diff) | |
download | external_python_mako-907a37e75e7011ba5cbca0300981800cb2884410.tar.gz external_python_mako-907a37e75e7011ba5cbca0300981800cb2884410.tar.bz2 external_python_mako-907a37e75e7011ba5cbca0300981800cb2884410.zip |
pkg_resources hoops
Diffstat (limited to 'mako/util.py')
-rw-r--r-- | mako/util.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/mako/util.py b/mako/util.py index 5518b4d..6bc100b 100644 --- a/mako/util.py +++ b/mako/util.py @@ -64,7 +64,27 @@ if py24: else: def exception_name(exc): return exc.__class__.__name__ - + +def get_pkg_resources_distribution(): + """Return a pkg_resources.Distribution for Mako. + + Pulls all kinds of strings to ensure one is + available even if Mako is not installed. + + """ + import pkg_resources + try: + dist = pkg_resources.get_distribution("mako") + except: + import mako + dist = pkg_resources.Distribution( + project_name="mako", location="mako", version=mako.__version__ + ) + dist.activate() + pkg_resources.working_set.add(dist) + dist = pkg_resources.get_distribution("mako") + return dist + def verify_directory(dir): """create and/or verify a filesystem directory.""" |