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/

Changed (Δ698 bytes):

raw changeset »

gp/recipe/pip/README.txt (13 lines added, 2 lines removed)

gp/recipe/pip/__init__.py (19 lines added, 10 lines removed)

Up to file-list gp/recipe/pip/README.txt:

@@ -10,8 +10,15 @@ The recipe supports the following option
10
10
   values it accepts, whether it is mandatory or optional and what the
11
11
   default value is if it is omitted.
12
12
13
venv
14
    Virtualenv id. The virtualenv is build in `parts/venv` (Default to pip)
13
virtualenv
14
15
    Virtualenv directory. The virtualenv is build in this directory (Default to
16
    `parts/pip`). You can also use an existing one. If a `virtualenv` option is
17
    found in the buildout section then this one is used except if the current
18
    section override it.
19
20
env
21
    extra environement vars used with subprocess
15
22
16
23
indexes
17
24
    Extra indexes url.
@@ -91,6 +98,10 @@ Here is a config file used to install De
91
98
92
99
  [eggs]
93
100
  recipe = gp.recipe.pip
101
  # needed to build static libs for lxml 
102
  env =
103
      STATIC_DEPS=true
104
94
105
  # packages to install with pip
95
106
  install =
96
107
      Cython

Up to file-list gp/recipe/pip/__init__.py:

@@ -31,7 +31,7 @@ class Recipe(object):
31
31
    def __init__(self, buildout, name, options):
32
32
        self.buildout, self.name, self.options = buildout, name, options
33
33
34
    def pip_install(self, part_dir, src_dir, extra_args):
34
    def pip_install(self, part_dir, build_dir, src_dir, extra_args):
35
35
        print 'pip install %s' % ' '.join(extra_args)
36
36
37
37
        # pop command line arguments
@@ -39,7 +39,7 @@ class Recipe(object):
39
39
                '-i', self.buildout['buildout'].get('index', pypi_url),
40
40
                '-E', part_dir,
41
41
                '--log', '%s-log.txt' % self.name,
42
                '-b', join(part_dir, 'build'),
42
                '-b', build_dir,
43
43
                '--src', src_dir,
44
44
               ]
45
45
@@ -90,20 +90,30 @@ class Recipe(object):
90
90
                env.update({
91
91
                    'CFLAGS' : "-arch ppc -arch i386 -isysroot %s -O2 -I%s" % (isysroot, include_dir),
92
92
                    'LDFLAGS' : "-arch ppc -arch i386 -isysroot %s -I%s" % (isysroot, include_dir),
93
                    'MACOSX_DEPLOYMENT_TARGET' : "10.5" in isysroot and "10.5" or "10.4"
93
                    'MACOSX_DEPLOYMENT_TARGET' : "10.5" in isysroot and "10.5" or "10.3"
94
94
                    })
95
95
96
96
        # call pip
97
        print env.keys()
97
        #print sorted(env.keys())
98
98
        #print 'PYTHONPATH=%s' % env['PYTHONPATH']
99
        print ' '.join(cmd)
99
        #print ' '.join(cmd)
100
100
        code = call(' '.join(cmd), shell=True, env=env)
101
101
        if code != 0:
102
102
            raise RuntimeError('An error occur during pip installation. See %s-log.txt' % self.name)
103
103
104
104
    def install(self):
105
        part_dir = join(self.buildout['buildout']['parts-directory'],
106
                        self.options.get('venv', 'pip'))
105
        part_dir = join(self.buildout['buildout']['parts-directory'], 'pip')
106
        if 'virtualenv' in self.buildout['buildout']:
107
            part_dir = self.buildout['buildout']['virtualenv']
108
        if 'virtualenv' in self.options:
109
            part_dir = self.options['virtualenv']
110
111
        build_dir = join(part_dir, 'build')
112
        if 'build-directory' in self.buildout['buildout']:
113
            build_dir = self.buildout['buildout']['build-directory']
114
        if 'build-directory' in self.options:
115
            build_dir = self.options['build-directory']
116
107
117
        src_dir = self.options.get('sources-directory',
108
118
                                   join(self.buildout['buildout']['directory'], 'src'))
109
119
@@ -117,12 +127,12 @@ class Recipe(object):
117
127
        # pip installs
118
128
119
129
        # venv
120
        self.pip_install(part_dir, src_dir, [])
130
        self.pip_install(part_dir, build_dir, src_dir, [])
121
131
122
132
        # VSC
123
133
        editables = [('-e', e) for e in to_list(self.options.get('editables', ''))]
124
134
        for e in editables:
125
            self.pip_install(part_dir, src_dir, e)
135
            self.pip_install(part_dir, build_dir, src_dir, e)
126
136
127
137
        # packages / bundles. add version if needed
128
138
        for i in to_list(self.options.get('install', '')):
@@ -172,7 +182,6 @@ class Recipe(object):
172
182
173
183
        # get eggs already in sys path and add them to extra_paths
174
184
        eggs_dir = self.buildout['buildout']['eggs-directory']
175
        extra_paths.extend('\n'.join([p for p in sys.path if p.startswith(eggs_dir)]))
176
185
        options['extra-paths'] = '\n'.join([p for p in sys.path if p.startswith(eggs_dir)])
177
186
178
187
        # run the recipe