source: isenes/mpl_buildout/trunk/recipes/numpy_venv.py @ 5439

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/isenes/mpl_buildout/trunk/recipes/numpy_venv.py@5439
Revision 5439, 1.3 KB checked in by spascoe, 11 years ago (diff)

Builds numpy inside a virtualenv

Line 
1"""
2A recipe to install numpy into a virtualenv environment.
3
4"""
5
6import logging, os, zc.buildout
7from zc.buildout.easy_install import install
8import pkg_resources
9
10from recipe import BaseRecipe
11
12class NumpyVenv(BaseRecipe):
13
14    def __init__(self, buildout, name, options):
15        self.name, self.options = name, options
16
17        #!TODO: support buildout.python option
18        options['executable'] = buildout['buildout']['executable']
19        options['virtualenv'] = os.path.join(
20            buildout['buildout']['parts-directory'],
21            name
22            )
23        options['eggs-directory'] = buildout['buildout']['eggs-directory']
24       
25        if 'eggs' not in options:
26            options['eggs'] = ''
27
28    def install(self):
29        path = self.options['virtualenv']
30
31        # First install numpy using buildout
32        install(self.options['eggs'].split(), self.options['eggs-directory'])
33
34        # Find the egg
35        e = pkg_resources.Environment([self.options['eggs-directory']])
36        dist = e['numpy'][0]
37                                     
38        # Add the egg to the virtualenv
39        self.options['eggs'] = '%s\n%s' % (self.options['eggs'],
40                                           dist.location)
41       
42        self.create_virtualenv(path)
43       
44        return path
45   
46    def update(self):
47        pass
48
49   
Note: See TracBrowser for help on using the repository browser.