18
18
use the -c option to specify an alternate configuration file.
19
19
"""
20
20
21
- import os , shutil , sys , tempfile
21
+ import os
22
+ import shutil
23
+ import sys
24
+ import tempfile
25
+
22
26
from optparse import OptionParser
23
27
24
28
tmpeggs = tempfile .mkdtemp ()
31
35
Simply run this script in a directory containing a buildout.cfg, using the
32
36
Python that you want bin/buildout to use.
33
37
34
- Note that by using --setup-source and --download-base to point to
35
- local resources, you can keep this script from going over the network.
38
+ Note that by using --find-links to point to local resources, you can keep
39
+ this script from going over the network.
36
40
'''
37
41
38
42
parser = OptionParser (usage = usage )
48
52
"bootstrap and buildout will get the newest releases "
49
53
"even if they are alphas or betas." ))
50
54
parser .add_option ("-c" , "--config-file" ,
51
- help = ("Specify the path to the buildout configuration "
52
- "file to be used." ))
55
+ help = ("Specify the path to the buildout configuration "
56
+ "file to be used." ))
53
57
parser .add_option ("-f" , "--find-links" ,
54
- help = ("Specify a URL to search for buildout releases" ))
58
+ help = ("Specify a URL to search for buildout releases" ))
55
59
56
60
57
61
options , args = parser .parse_args ()
58
62
59
63
######################################################################
60
- # load/install distribute
64
+ # load/install setuptools
61
65
62
66
to_reload = False
63
67
try :
64
- import pkg_resources , setuptools
65
- if not hasattr (pkg_resources , '_distribute' ):
66
- to_reload = True
67
- raise ImportError
68
+ import pkg_resources
69
+ import setuptools
68
70
except ImportError :
69
71
ez = {}
70
72
73
75
except ImportError :
74
76
from urllib2 import urlopen
75
77
76
- exec (urlopen ('http://python-distribute.org/distribute_setup.py' ).read (), ez )
77
- setup_args = dict (to_dir = tmpeggs , download_delay = 0 , no_fake = True )
78
+ # XXX use a more permanent ez_setup.py URL when available.
79
+ exec (urlopen ('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py'
80
+ ).read (), ez )
81
+ setup_args = dict (to_dir = tmpeggs , download_delay = 0 )
78
82
ez ['use_setuptools' ](** setup_args )
79
83
80
84
if to_reload :
89
93
######################################################################
90
94
# Install buildout
91
95
92
- ws = pkg_resources .working_set
96
+ ws = pkg_resources .working_set
93
97
94
98
cmd = [sys .executable , '-c' ,
95
99
'from setuptools.command.easy_install import main; main()' ,
104
108
if find_links :
105
109
cmd .extend (['-f' , find_links ])
106
110
107
- distribute_path = ws .find (
108
- pkg_resources .Requirement .parse ('distribute ' )).location
111
+ setuptools_path = ws .find (
112
+ pkg_resources .Requirement .parse ('setuptools ' )).location
109
113
110
114
requirement = 'zc.buildout'
111
115
version = options .version
112
116
if version is None and not options .accept_buildout_test_releases :
113
117
# Figure out the most recent final version of zc.buildout.
114
118
import setuptools .package_index
115
119
_final_parts = '*final-' , '*final'
120
+
116
121
def _final_version (parsed_version ):
117
122
for part in parsed_version :
118
123
if (part [:1 ] == '*' ) and (part not in _final_parts ):
119
124
return False
120
125
return True
121
126
index = setuptools .package_index .PackageIndex (
122
- search_path = [distribute_path ])
127
+ search_path = [setuptools_path ])
123
128
if find_links :
124
129
index .add_find_links ((find_links ,))
125
130
req = pkg_resources .Requirement .parse (requirement )
@@ -142,7 +147,7 @@ def _final_version(parsed_version):
142
147
cmd .append (requirement )
143
148
144
149
import subprocess
145
- if subprocess .call (cmd , env = dict (os .environ , PYTHONPATH = distribute_path )) != 0 :
150
+ if subprocess .call (cmd , env = dict (os .environ , PYTHONPATH = setuptools_path )) != 0 :
146
151
raise Exception (
147
152
"Failed to execute command:\n %s" ,
148
153
repr (cmd )[1 :- 1 ])
0 commit comments