def build_wheels(self, packages, clean_first=False, force_iterate=False): """Create python wheels from a list of packages. This method will build all of the wheels from a list of packages. Once the loop is completed the wheels items will be moved to the storage pool location. Upon the completion of the method the ``build_output`` directory will be removed. :param packages: List of packages to build. :type packages: ``list`` :param clean_first: Enable a search and clean for existing package :type clean_first: ``bol`` :param force_iterate: Force package iteration. :type force_iterate: ``bol`` """ try: if clean_first and self.args["link_dir"]: files = utils.get_file_names(self.args["link_dir"]) for package in packages: self._package_clean(package=package, files=files) if self.args["pip_bulk_operation"] and not force_iterate: req_file = os.path.join(self.args["link_dir"], "build_reqs.txt") LOG.info('Requirement file being written: "%s"', req_file) self.shell_cmds.mkdir_p(path=os.path.dirname(req_file)) with open(req_file, "wb") as f: f.writelines(["%s\n" % i for i in packages]) self._pip_build_wheels(packages_file=req_file) else: for package in packages: self._setup_build_wheels(package=package) self._store_pool() finally: utils.remove_dirs(directory=self.args["build_output"])
def _store_pool(self): """Create wheels within the storage pool directory.""" built_wheels = utils.get_file_names(path=self.args["build_output"]) # Iterate through the built wheels for built_wheel in built_wheels: _dst_wheel_file_name = os.path.basename(built_wheel) # Directory name is being "normalised" dst_wheel_file = os.path.join( self.args["storage_pool"], _dst_wheel_file_name.split("-")[0].lower().replace("_", "-"), _dst_wheel_file_name, ) # Create destination file if os.path.exists(dst_wheel_file): dst_size = os.path.getsize(dst_wheel_file) src_size = os.path.getsize(built_wheel) if dst_size != src_size: LOG.debug( "Wheel found but the sizes are different. The new" " wheel file will be copied over. Wheel file [ %s ]", dst_wheel_file, ) self._copy_file(dst_file=dst_wheel_file, src_file=built_wheel) else: LOG.debug("Wheel not found copying wheel into place [ %s ]", dst_wheel_file) # Ensure the directory exists self.shell_cmds.mkdir_p(path=os.path.dirname(dst_wheel_file)) self._copy_file(dst_file=dst_wheel_file, src_file=built_wheel) # Create link if self.args["link_dir"]: self._create_link(full_wheel_path=dst_wheel_file, wheel_name=os.path.basename(dst_wheel_file))
def _store_pool(self): """Create wheels within the storage pool directory.""" built_wheels = utils.get_file_names(path=self.args['build_output']) # Iterate through the built wheels for built_wheel in built_wheels: _dst_wheel_file_name = os.path.basename(built_wheel) # Directory name is being "normalised" dst_wheel_file = os.path.join( self.args['storage_pool'], _dst_wheel_file_name.split('-')[0].lower().replace('_', '-'), _dst_wheel_file_name) # Create destination file if os.path.exists(dst_wheel_file): dst_size = os.path.getsize(dst_wheel_file) src_size = os.path.getsize(built_wheel) if dst_size != src_size: LOG.debug( 'Wheel found but the sizes are different. The new' ' wheel file will be copied over. Wheel file [ %s ]', dst_wheel_file) self._copy_file(dst_file=dst_wheel_file, src_file=built_wheel) else: LOG.debug('Wheel not found copying wheel into place [ %s ]', dst_wheel_file) # Ensure the directory exists self.shell_cmds.mkdir_p(path=os.path.dirname(dst_wheel_file)) self._copy_file(dst_file=dst_wheel_file, src_file=built_wheel) # Create link if self.args['link_dir']: self._create_link(full_wheel_path=dst_wheel_file, wheel_name=os.path.basename(dst_wheel_file))
def build_wheels(self, packages, clean_first=False, force_iterate=False): """Create python wheels from a list of packages. This method will build all of the wheels from a list of packages. Once the loop is completed the wheels items will be moved to the storage pool location. Upon the completion of the method the ``build_output`` directory will be removed. :param packages: List of packages to build. :type packages: ``list`` :param clean_first: Enable a search and clean for existing package :type clean_first: ``bol`` :param force_iterate: Force package iteration. :type force_iterate: ``bol`` """ try: if clean_first and self.args['link_dir']: files = utils.get_file_names(self.args['link_dir']) for package in packages: self._package_clean(package=package, files=files) if self.args['pip_bulk_operation'] and not force_iterate: req_file = os.path.join(self.args['link_dir'], 'build_reqs.txt') LOG.info('Requirement file being written: "%s"', req_file) self.shell_cmds.mkdir_p(path=os.path.dirname(req_file)) with open(req_file, 'wb') as f: f.writelines(['%s\n' % i for i in packages]) self._pip_build_wheels(packages_file=req_file) else: for package in packages: self._setup_build_wheels(package=package) self._store_pool() finally: utils.remove_dirs(directory=self.args['build_output'])