Commits

Gael Pasgrimaud committed df317b2

allow to share virtualenv / build_dir

  • Participants
  • Parent commits 643f156

Comments (0)

Files changed (2)

File gp/recipe/pip/README.txt

    values it accepts, whether it is mandatory or optional and what the
    default value is if it is omitted.
 
-venv
-    Virtualenv id. The virtualenv is build in `parts/venv` (Default to pip)
+virtualenv
+
+    Virtualenv directory. The virtualenv is build in this directory (Default to
+    `parts/pip`). You can also use an existing one. If a `virtualenv` option is
+    found in the buildout section then this one is used except if the current
+    section override it.
+
+env
+    extra environement vars used with subprocess
 
 indexes
     Extra indexes url.
 
   [eggs]
   recipe = gp.recipe.pip
+  # needed to build static libs for lxml 
+  env =
+      STATIC_DEPS=true
+
   # packages to install with pip
   install =
       Cython

File gp/recipe/pip/__init__.py

     def __init__(self, buildout, name, options):
         self.buildout, self.name, self.options = buildout, name, options
 
-    def pip_install(self, part_dir, src_dir, extra_args):
+    def pip_install(self, part_dir, build_dir, src_dir, extra_args):
         print 'pip install %s' % ' '.join(extra_args)
 
         # pop command line arguments
                 '-i', self.buildout['buildout'].get('index', pypi_url),
                 '-E', part_dir,
                 '--log', '%s-log.txt' % self.name,
-                '-b', join(part_dir, 'build'),
+                '-b', build_dir,
                 '--src', src_dir,
                ]
 
                 env.update({
                     'CFLAGS' : "-arch ppc -arch i386 -isysroot %s -O2 -I%s" % (isysroot, include_dir),
                     'LDFLAGS' : "-arch ppc -arch i386 -isysroot %s -I%s" % (isysroot, include_dir),
-                    'MACOSX_DEPLOYMENT_TARGET' : "10.5" in isysroot and "10.5" or "10.4"
+                    'MACOSX_DEPLOYMENT_TARGET' : "10.5" in isysroot and "10.5" or "10.3"
                     })
 
         # call pip
-        print env.keys()
+        #print sorted(env.keys())
         #print 'PYTHONPATH=%s' % env['PYTHONPATH']
-        print ' '.join(cmd)
+        #print ' '.join(cmd)
         code = call(' '.join(cmd), shell=True, env=env)
         if code != 0:
             raise RuntimeError('An error occur during pip installation. See %s-log.txt' % self.name)
 
     def install(self):
-        part_dir = join(self.buildout['buildout']['parts-directory'],
-                        self.options.get('venv', 'pip'))
+        part_dir = join(self.buildout['buildout']['parts-directory'], 'pip')
+        if 'virtualenv' in self.buildout['buildout']:
+            part_dir = self.buildout['buildout']['virtualenv']
+        if 'virtualenv' in self.options:
+            part_dir = self.options['virtualenv']
+
+        build_dir = join(part_dir, 'build')
+        if 'build-directory' in self.buildout['buildout']:
+            build_dir = self.buildout['buildout']['build-directory']
+        if 'build-directory' in self.options:
+            build_dir = self.options['build-directory']
+
         src_dir = self.options.get('sources-directory',
                                    join(self.buildout['buildout']['directory'], 'src'))
 
         # pip installs
 
         # venv
-        self.pip_install(part_dir, src_dir, [])
+        self.pip_install(part_dir, build_dir, src_dir, [])
 
         # VSC
         editables = [('-e', e) for e in to_list(self.options.get('editables', ''))]
         for e in editables:
-            self.pip_install(part_dir, src_dir, e)
+            self.pip_install(part_dir, build_dir, src_dir, e)
 
         # packages / bundles. add version if needed
         for i in to_list(self.options.get('install', '')):
 
         # get eggs already in sys path and add them to extra_paths
         eggs_dir = self.buildout['buildout']['eggs-directory']
-        extra_paths.extend('\n'.join([p for p in sys.path if p.startswith(eggs_dir)]))
         options['extra-paths'] = '\n'.join([p for p in sys.path if p.startswith(eggs_dir)])
 
         # run the recipe