def main_build(dir_path, output_dir='.', platform=cc_platform, verbose=True): print('platform: %s' % platform) try: osname, unused_arch = platform.split('-') except ValueError: sys.exit("Error: invalid platform string '%s'" % platform) if osname in ('linux', 'osx'): if sys.platform == 'win32': sys.exit("Error: Cannot create .sh installer on Windows platform.") from constructor.shar import create elif osname == 'win': if sys.platform != 'win32': sys.exit("Error: Cannot create Windows .exe installer on " "non-Windows platform.") from constructor.winexe import create else: sys.exit("Error: invalid OS name '%s'" % osname) construct_path = join(dir_path, 'construct.yaml') info = construct.parse(construct_path, platform) construct.verify(info) info['_platform'] = platform info['_download_dir'] = join(expanduser('~'), '.conda', 'constructor', platform) if verbose: print('conda packages download: %s' % info['_download_dir']) for key in ('license_file', 'welcome_image', 'header_image', 'icon_image', 'pre_install', 'post_install'): if key in info: info[key] = abspath(join(dir_path, info[key])) for key in 'specs', 'packages': if key not in info: continue if isinstance(info[key], str): info[key] = list(yield_lines(join(dir_path, info[key]))) for key in 'channels', 'specs', 'exclude', 'packages': if key in info: # ensure strings in those lists are stripped info[key] = [line.strip() for line in info[key]] # ensure there are no empty strings if any((not s) for s in info[key]): sys.exit("Error: found empty element in '%s:'" % key) fcp.main(info, verbose=verbose) info['_outpath'] = join(output_dir, get_output_filename(info)) create(info) print("Succussfully created '%(_outpath)s'." % info)
def main_build(dir_path, output_dir='.', platform=cc_platform, verbose=True, cache_dir=DEFAULT_CACHE_DIR): print('platform: %s' % platform) cache_dir = abspath(expanduser(cache_dir)) try: osname, unused_arch = platform.split('-') except ValueError: sys.exit("Error: invalid platform string '%s'" % platform) construct_path = join(dir_path, 'construct.yaml') info = construct.parse(construct_path, platform) construct.verify(info) info['_platform'] = platform info['_download_dir'] = join(cache_dir, platform) set_installer_type(info) if info['installer_type'] == 'sh': if sys.platform == 'win32': sys.exit("Error: Cannot create .sh installer on Windows.") from constructor.shar import create elif info['installer_type'] == 'pkg': if sys.platform != 'darwin': sys.exit("Error: Can only create .pkg installer on OSX.") from constructor.osxpkg import create elif info['installer_type'] == 'exe': if sys.platform != 'win32': sys.exit("Error: Can only create .pkg installer on Windows.") from constructor.winexe import create if verbose: print('conda packages download: %s' % info['_download_dir']) for key in ('welcome_image_text', 'header_image_text'): if key not in info: info[key] = info['name'] for key in ('license_file', 'welcome_image', 'header_image', 'icon_image', 'pre_install', 'post_install'): if key in info: info[key] = abspath(join(dir_path, info[key])) for key in 'specs', 'packages': if key not in info: continue if isinstance(info[key], str): info[key] = list(yield_lines(join(dir_path, info[key]))) for key in 'channels', 'specs', 'exclude', 'packages', 'menu_packages': if key in info: # ensure strings in those lists are stripped info[key] = [line.strip() for line in info[key]] # ensure there are no empty strings if any((not s) for s in info[key]): sys.exit("Error: found empty element in '%s:'" % key) fcp.main(info, verbose=verbose) info['_outpath'] = join(output_dir, get_output_filename(info)) create(info, verbose=verbose) if 0: with open(join(output_dir, 'pkg-list.txt'), 'w') as fo: fo.write('# installer: %s\n' % basename(info['_outpath'])) for dist in info['_dists']: fo.write('%s\n' % dist) print("Successfully created '%(_outpath)s'." % info)