def install(self): options = self.options install_location = self.buildout['buildout']['eggs-directory'] if not os.path.exists(options['location']): os.mkdir(options['location']) # Only do expensive download/compilation when there's no existing egg. path = [install_location] req_string = self.options['egg'] # 'lxml' or 'lxml == 2.0.9' version_part = self.buildout['buildout'].get('versions') if version_part: version_req = self.buildout[version_part].get('lxml') if version_req: # [versions] wins and is often the place where it is specified. req_string = 'lxml == %s' % version_req req = pkg_resources.Requirement.parse(req_string) matching_dists = [ d for d in pkg_resources.Environment(path)['lxml'] if d in req ] if matching_dists and not self.force: # We have found existing lxml eggs that match our requirements. # If we specified an exact version, we'll trust that the matched # egg is good. We don't currently accept matches for not-pinned # versions as that would mean lots of code duplication with # easy_install (handling newest=t/f and so). specs = req.specs if len(specs) == 1 and specs[0][0] == '==': self.logger.info( "Using existing %s. Delete it if that one " "isn't statically compiled.", matching_dists[0].location) return () # build dependent libs if requested if self.build_xml2: self.build_libxml2() else: self.logger.warn("Using configured libxml2 at %s" % self.xml2_location) if self.build_xslt: self.build_libxslt() else: self.logger.warn("Using configured libxslt at %s" % self.xslt_location) # get the config executables self.get_configs(os.path.join(self.xml2_location, "bin"), os.path.join(self.xslt_location, "bin")) if self.static_build: self.remove_dynamic_libs(self.xslt_location) self.remove_dynamic_libs(self.xml2_location) # build LXML dest = options.get("location") if not os.path.exists(dest): os.mkdir(dest) options["include-dirs"] = '\n'.join([ os.path.join(self.xml2_location, "include", "libxml2"), os.path.join(self.xslt_location, "include") ]) options["library-dirs"] = '\n'.join([ os.path.join(self.xml2_location, "lib"), os.path.join(self.xslt_location, "lib") ]) options["rpath"] = '\n'.join([ os.path.join(self.xml2_location, "lib"), os.path.join(self.xslt_location, "lib") ]) if "darwin" in sys.platform: self.logger.warn( "Adding ``iconv`` to libs due to a lxml setup bug.") options["libraries"] = "iconv" self.lxml_custom = Custom(self.buildout, self.name, self.options) self.lxml_custom.environment = self.lxml_build_env() self.lxml_custom.options["_d"] = install_location self.logger.info("Building lxml ...") self.lxml_dest = self.lxml_custom.install() return ()