Skip to content

Commit

Permalink
Improve "cook" to try loading littlechef module with "import" first.
Browse files Browse the repository at this point in the history
This makes it possible to run "cook" from a source code checkout without
installing the package first, which simplifies installation and development.
All previous trickery to load the module is retained and will be used as
a fallback.
  • Loading branch information
igal committed Mar 7, 2011
1 parent 5a7a264 commit a95b7ab
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cook
@@ -1,16 +1,21 @@
#!/usr/bin/env python
import re
import sys, os
from subprocess import call
from distutils.sysconfig import get_python_lib

fabfile = get_python_lib() + "/littlechef.py"

if not os.path.exists(fabfile):
fabfile = fabfile.replace('/usr/lib/', '/usr/local/lib/')
fabfile = None
try:
import littlechef
fabfile = re.sub(r'\.pyc$', '.py', littlechef.__file__)
except ImportError:
fabfile = get_python_lib() + "/littlechef.py"
if not os.path.exists(fabfile):
fabfile = __file__.replace('EGG-INFO/scripts/cook', '') + 'littlechef.py'
fabfile = fabfile.replace('/usr/lib/', '/usr/local/lib/')
if not os.path.exists(fabfile):
sys.exit("There was an installation error. Couldn't find littlechef.py, try reinstalling again")
fabfile = __file__.replace('EGG-INFO/scripts/cook', '') + 'littlechef.py'
if not os.path.exists(fabfile):
sys.exit("There was an installation error. Couldn't find littlechef.py, try reinstalling again")

args = ['fab', '-f', fabfile]

Expand Down

0 comments on commit a95b7ab

Please sign in to comment.