gawel / gp.recipe.pip
zc.buildout recipe for pip
Clone this repository (size: 42.5 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/gawel/gprecipepip/
| commit 29: | 552c04d14911 |
| parent 28: | 1405684b9727 |
| branch: | default |
fix pypi_url but still have problem with latest pip version...
Changed (Δ2.1 KB):
raw changeset »
bootstrap.py (87 lines added, 18 lines removed)
gp/recipe/pip/__init__.py (3 lines added, 2 lines removed)
gp/recipe/pip/tests/test_docs.py (1 lines added, 0 lines removed)
setup.py (1 lines added, 1 lines removed)
| … | … | @@ -21,32 +21,101 @@ use the -c option to specify an alternat |
21 |
21 |
""" |
22 |
22 |
|
23 |
23 |
import os, shutil, sys, tempfile, urllib2 |
24 |
from optparse import OptionParser |
|
24 |
25 |
|
25 |
26 |
tmpeggs = tempfile.mkdtemp() |
26 |
27 |
|
27 |
ez = {} |
|
28 |
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' |
|
29 |
).read() in ez |
|
30 |
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) |
|
28 |
is_jython = sys.platform.startswith('java') |
|
31 |
29 |
|
32 |
|
|
30 |
# parsing arguments |
|
31 |
parser = OptionParser() |
|
32 |
parser.add_option("-v", "--version", dest="version", |
|
33 |
help="use a specific zc.buildout version") |
|
34 |
parser.add_option("-d", "--distribute", |
|
35 |
action="store_true", dest="distribute", default=False, |
|
36 |
help="Use Disribute rather than Setuptools.") |
|
37 |
||
38 |
parser.add_option("-c", None, action="store", dest="config_file", |
|
39 |
help=("Specify the path to the buildout configuration " |
|
40 |
"file to be used.")) |
|
41 |
||
42 |
options, args = parser.parse_args() |
|
43 |
||
44 |
# if -c was provided, we push it back into args for buildout' main function |
|
45 |
if options.config_file is not None: |
|
46 |
args += ['-c', options.config_file] |
|
47 |
||
48 |
if options.version is not None: |
|
49 |
VERSION = '==%s' % options.version |
|
50 |
else: |
|
51 |
VERSION = '' |
|
52 |
||
53 |
USE_DISTRIBUTE = options.distribute |
|
54 |
args = args + ['bootstrap'] |
|
55 |
||
56 |
to_reload = False |
|
57 |
try: |
|
58 |
import pkg_resources |
|
59 |
if not hasattr(pkg_resources, '_distribute'): |
|
60 |
to_reload = True |
|
61 |
raise ImportError |
|
62 |
except ImportError: |
|
63 |
ez = {} |
|
64 |
if USE_DISTRIBUTE: |
|
65 |
exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py' |
|
66 |
).read() in ez |
|
67 |
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True) |
|
68 |
else: |
|
69 |
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' |
|
70 |
).read() in ez |
|
71 |
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) |
|
72 |
||
73 |
if to_reload: |
|
74 |
reload(pkg_resources) |
|
75 |
else: |
|
76 |
import pkg_resources |
|
77 |
||
78 |
if sys.platform == 'win32': |
|
79 |
def quote(c): |
|
80 |
if ' ' in c: |
|
81 |
return '"%s"' % c # work around spawn lamosity on windows |
|
82 |
else: |
|
83 |
return c |
|
84 |
else: |
|
85 |
def quote (c): |
|
86 |
return c |
|
33 |
87 |
|
34 |
88 |
cmd = 'from setuptools.command.easy_install import main; main()' |
35 |
if sys.platform == 'win32': |
|
36 |
cmd = '"%s"' % cmd # work around spawn lamosity on windows |
|
89 |
ws = pkg_resources.working_set |
|
37 |
90 |
|
38 |
ws = pkg_resources.working_set |
|
39 |
assert os.spawnle( |
|
40 |
os.P_WAIT, sys.executable, sys.executable, |
|
41 |
'-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout', |
|
42 |
dict(os.environ, |
|
43 |
PYTHONPATH= |
|
44 |
ws.find(pkg_resources.Requirement.parse('setuptools')).location |
|
45 |
), |
|
46 |
) == 0 |
|
91 |
if USE_DISTRIBUTE: |
|
92 |
requirement = 'distribute' |
|
93 |
else: |
|
94 |
requirement = 'setuptools' |
|
95 |
||
96 |
if is_jython: |
|
97 |
import subprocess |
|
98 |
||
99 |
assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', |
|
100 |
quote(tmpeggs), 'zc.buildout' + VERSION], |
|
101 |
env=dict(os.environ, |
|
102 |
PYTHONPATH= |
|
103 |
ws.find(pkg_resources.Requirement.parse(requirement)).location |
|
104 |
), |
|
105 |
).wait() == 0 |
|
106 |
||
107 |
else: |
|
108 |
assert os.spawnle( |
|
109 |
os.P_WAIT, sys.executable, quote (sys.executable), |
|
110 |
'-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION, |
|
111 |
dict(os.environ, |
|
112 |
PYTHONPATH= |
|
113 |
ws.find(pkg_resources.Requirement.parse(requirement)).location |
|
114 |
), |
|
115 |
) == 0 |
|
47 |
116 |
|
48 |
117 |
ws.add_entry(tmpeggs) |
49 |
ws.require('zc.buildout' |
|
118 |
ws.require('zc.buildout' + VERSION) |
|
50 |
119 |
import zc.buildout.buildout |
51 |
zc.buildout.buildout.main( |
|
120 |
zc.buildout.buildout.main(args) |
|
52 |
121 |
shutil.rmtree(tmpeggs) |
Up to file-list gp/recipe/pip/__init__.py:
| … | … | @@ -7,13 +7,14 @@ from zc.recipe.egg import Scripts |
7 |
7 |
from subprocess import call |
8 |
8 |
from copy import deepcopy |
9 |
9 |
from os.path import join |
10 |
from pip import pypi_url |
|
11 |
10 |
import glob |
12 |
11 |
import sys |
13 |
12 |
import os |
14 |
13 |
|
15 |
14 |
PYTHON = 'python%s' % sys.version[0:3] |
16 |
15 |
|
16 |
PYPI_URL='http://pypi.python.org/simple' |
|
17 |
||
17 |
18 |
def to_list(value): |
18 |
19 |
value = value.split('\n') |
19 |
20 |
value = [v.strip() for v in value] |
| … | … | @@ -35,7 +36,7 @@ class Recipe(Scripts): |
35 |
36 |
|
36 |
37 |
# pop command line arguments |
37 |
38 |
args = ['install', |
38 |
'-i', self.buildout['buildout'].get('index', |
|
39 |
'-i', self.buildout['buildout'].get('index', PYPI_URL), |
|
39 |
40 |
'-E', part_dir, |
40 |
41 |
'--log', '%s-log.txt' % self.name, |
41 |
42 |
'-b', build_dir, |
Up to file-list gp/recipe/pip/tests/test_docs.py:
| … | … | @@ -20,6 +20,7 @@ def setUp(test): |
20 |
20 |
# Install the recipe in develop mode |
21 |
21 |
zc.buildout.testing.install_develop('pip', test) |
22 |
22 |
zc.buildout.testing.install_develop('virtualenv', test) |
23 |
zc.buildout.testing.install_develop('distribute', test) |
|
23 |
24 |
zc.buildout.testing.install_develop('zc.recipe.egg', test) |
24 |
25 |
zc.buildout.testing.install_develop('gp.recipe.pip', test) |
25 |
26 |
