1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
pip/contrib/build-standalone
2013-06-01 09:16:04 -07:00

38 lines
969 B
Python
Executable file

#!/usr/bin/env python
import os
import sys
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 occurred 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(entry, ['pip'])
f = open(file_name, 'w')
try:
f.write(script)
finally:
f.close()
sys.stdout.write('done.\n')
if hasattr(os, 'chmod'):
oldmode = os.stat(file_name).st_mode & 07777
newmode = (oldmode | 0555) & 07777
os.chmod(file_name, newmode)
sys.stdout.write('Made resulting file %s executable.\n\n' % file_name)
if __name__ == '__main__':
main()