-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-standalone
executable file
·38 lines (33 loc) · 968 Bytes
/
build-standalone
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/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 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(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()