Skip to content
Browse files

Updated script generators to show a nice warning if setuptools/distri…

…bute can't be found during execution.
  • Loading branch information...
1 parent 936c458 commit a50ac009c8f9d68fe72d12014ebf7e2822305877 @jezdez jezdez committed Apr 4, 2011
Showing with 27 additions and 3 deletions.
  1. +13 −1 contrib/build-installer
  2. +13 −1 contrib/build-standalone
  3. +1 −1 contrib/packager/template.py
View
14 contrib/build-installer
@@ -7,9 +7,21 @@ from packager import generate_script
here = os.path.dirname(os.path.abspath(__file__))
file_name = os.path.join(here, 'get-pip.py')
+entry = """
+import sys
+try:
+ import setuptools
+ import pkg_resources
+except ImportError:
+ raise SystemExit("An error occured while trying to run %s. Make sure "
+ "you have setuptools or distribute installed." % __file__)
+import pip
+pip.bootstrap()
+"""
+
def main():
sys.stdout.write("Creating pip bootstrapper...")
- script = generate_script('import pip; pip.bootstrap()', ['pip'])
+ script = generate_script(entry, ['pip'])
f = open(file_name, 'w')
try:
f.write(script)
View
14 contrib/build-standalone
@@ -7,9 +7,21 @@ from packager import generate_script
here = os.path.dirname(os.path.abspath(__file__))
file_name = os.path.join(here, 'run-pip.py')
+entry = """
+import sys
+try:
+ import setuptools
+ import pkg_resources
+except ImportError:
+ raise SystemExit("An error occured while trying to run %s. Make sure "
+ "you have setuptools or distribute installed." % __file__)
+import pip
+pip.main()
+"""
+
def main():
sys.stdout.write("Creating standalone pip...")
- script = generate_script('import pip; pip.main()', ['pip'])
+ script = generate_script(entry, ['pip'])
f = open(file_name, 'w')
try:
f.write(script)
View
2 contrib/packager/template.py
@@ -40,7 +40,7 @@ def unpack(sources):
temp_dir = unpack(sources)
sys.path.insert(0, temp_dir)
- entry = "@ENTRY@"
+ entry = """@ENTRY@"""
do_exec(entry, locals())
finally:
shutil.rmtree(temp_dir)

0 comments on commit a50ac00

Please sign in to comment.
Something went wrong with that request. Please try again.