def appimage(is_stable=0): ''' Build AppImage package ''' builder = BuilderAppImage(is_stable=tobool(is_stable)) builder.build() print_info('AppImage created: {}'.format(builder.get_appimage_files()))
def _remove_files(self): toRemove = [os.path.join(self._dist_dir, u'outwiker', fname) for fname in self.get_remove_list()] for fname in toRemove: print_info(u'Remove: {}'.format(fname)) remove(fname)
def upload(self, plugins: List[str]): ''' Upload plugin to site ''' for pluginname in plugins: path_to_plugin_local = os.path.join(self.build_plugins_dir, pluginname) if not os.path.exists(path_to_plugin_local): continue path_to_xml_changelog = getPluginChangelogPath(pluginname) changelog_xml_content = readTextFile(path_to_xml_changelog) changelog = ChangeLogFactory.fromString(changelog_xml_content, '') latest_version = changelog.latestVersion assert latest_version is not None print_info('Uploading...') for download in latest_version.downloads: url_elements = urlparse(download.href) server_src = '{scheme}://{netloc}/'.format( scheme=url_elements.scheme, netloc=url_elements.netloc) upload_url = download.href.replace(server_src, self.deploy_home_path) path_to_upload = os.path.dirname(upload_url) archive_name = os.path.basename(upload_url) path_to_archive_local = os.path.join(path_to_plugin_local, archive_name) with cd(path_to_upload): put(path_to_archive_local, archive_name)
def _copy_sources_to_temp(self): print_info('Copy sources to {}...'.format(self.temp_sources_dir)) shutil.copytree('src', self.temp_sources_dir, ignore=shutil.ignore_patterns( '__pycache__', '.pytest_cache', '.mypy_cache', 'OutWiker.egg-info', 'outwiker.egg-info', 'tests'))
def appimage(is_stable=0): ''' Build AppImage package ''' builder = BuilderAppImage(is_stable=tobool(is_stable)) builder.build() print_info('AppImage created: {}'.format(builder.get_appimage_files()))
def _build_installer(self): if not self._create_installer: return print_info(u'Create installer...') if self.is_stable: installerName = u'outwiker_{}_win'.format(self.facts.version_items[0]) else: installerName = u'outwiker_win_unstable'.format(self.facts.version) installer_path = os.path.join(self.facts.temp_dir, installerName) installer_template = readTextFile(os.path.join(NEED_FOR_BUILD_DIR, u'windows', u'outwiker_setup.iss.tpl')) installer_text = Template(installer_template).safe_substitute( version=self.facts.version, resultname=installerName ) installer_script_path = os.path.join(self.facts.temp_dir, u'outwiker_setup.iss') writeTextFile(installer_script_path, installer_text) with lcd(self.facts.temp_dir): local("iscc outwiker_setup.iss") shutil.move(installer_path + u'.exe', self.build_dir)
def _build_installer(self): if not self._create_installer: return print_info(u'Create installer...') if self.is_stable: installerName = u'outwiker_{}_win'.format( self.facts.version_items[0]) else: installerName = u'outwiker_win_unstable'.format(self.facts.version) installer_path = os.path.join(self.facts.temp_dir, installerName) installer_template = readTextFile( os.path.join(NEED_FOR_BUILD_DIR, u'windows', u'outwiker_setup.iss.tpl')) installer_text = Template(installer_template).safe_substitute( version=self.facts.version, resultname=installerName) installer_script_path = os.path.join(self.facts.temp_dir, u'outwiker_setup.iss') writeTextFile(installer_script_path, installer_text) with lcd(self.facts.temp_dir): local("iscc outwiker_setup.iss") shutil.move(installer_path + u'.exe', self.build_dir)
def deb_binary(is_stable=False): ''' Create binary deb package ''' builder = BuilderDebBinaryFactory.get_default(DEB_BINARY_BUILD_DIR, tobool(is_stable)) builder.build() print_info('Deb created: {}'.format(builder.get_deb_files()))
def snap_publish(): builder = BuilderSnap(False) snap_files = builder.get_snap_files() for snap_file in snap_files: print_info('Publish snap: {fname}'.format(fname=snap_file)) local('snapcraft push "{fname}"'.format(fname=snap_file)) local('snapcraft sign-build "{fname}"'.format(fname=snap_file))
def deb_binary(is_stable=False): ''' Create binary deb package ''' builder = BuilderDebBinaryFactory.get_default(DEB_BINARY_BUILD_DIR, tobool(is_stable)) builder.build() print_info('Deb created: {}'.format(builder.get_deb_files()))
def _print_linter_report(report: LinterReport): if report.status == LinterStatus.OK: print_info(' ' + report.message) elif report.status == LinterStatus.WARNING: print_warning(' ' + report.message) elif report.status == LinterStatus.ERROR: print_error(' ' + report.message) else: raise AssertionError
def _remove_files(self): toRemove = [ os.path.join(self._dist_dir, u'outwiker', fname) for fname in self.get_remove_list() ] for fname in toRemove: print_info(u'Remove: {}'.format(fname)) remove(fname)
def _copy_additional_files(self): root_dir = os.path.join(self._dist_dir, u'outwiker') for fname, subpath in self.get_additional_files(): dest_dir = os.path.join(root_dir, subpath) if not os.path.exists(dest_dir): os.makedirs(dest_dir) print_info(u'Copy: {} -> {}'.format(fname, dest_dir)) shutil.copy(fname, dest_dir)
def _copy_additional_files(self): root_dir = os.path.join(self._dist_dir, u'outwiker') for fname, subpath in self.get_additional_files(): dest_dir = os.path.join(root_dir, subpath) if not os.path.exists(dest_dir): os.makedirs(dest_dir) print_info(u'Copy: {} -> {}'.format(fname, dest_dir)) shutil.copy(fname, dest_dir)
def _build(self): print_info(u'Create full sources archive...') local('git archive --prefix={}/ -o "{}" HEAD'.format( self._full_archive_name, self._full_archive_path)) print_info(u'Create minimal sources archive...') with lcd(self.temp_sources_dir): local(u'7z a -r -aoa -xr!__pycache__ -xr!*.pyc -xr!.ropeproject -xr!tests.py -xr!profile.py -xr!setup_tests.py -xr!tests_*.py -xr!setup.py -xr!test -xr!profiles "{}" ./*'.format(self._min_archive_path))
def _strip_binary(self): strip_path = Path(self._dest_dir) files_for_strip = (list(strip_path.glob('libwx*.so.*')) + list(strip_path.glob('wx.*so'))) for fname in files_for_strip: print_info(u'Strip {}'.format(fname)) if os.path.exists(str(fname)): local(u'strip -s -o "{fname}" "{fname}"'.format(fname=fname))
def _strip_binary(self): strip_path = Path(self._dest_dir) files_for_strip = (list(strip_path.glob('libwx*.so.*')) + list(strip_path.glob('wx.*so'))) for fname in files_for_strip: print_info(u'Strip {}'.format(fname)) if os.path.exists(str(fname)): local(u'strip -s -o "{fname}" "{fname}"'.format(fname=fname))
def _build(self): print_info(u'Create full sources archive...') local('git archive --prefix={}/ -o "{}" HEAD'.format( self._full_archive_name, self._full_archive_path)) print_info(u'Create minimal sources archive...') with lcd(self.temp_sources_dir): local( u'7z a -r -aoa -xr!*.pyc -xr!.ropeproject -xr!tests.py -xr!profile.py -xr!setup_tests.py -xr!tests_*.py -xr!setup.py -xr!test -xr!profiles "{}" ./*' .format(self._min_archive_path))
def snap_publish(): ''' Publish created snap package ''' builder = BuilderSnap(False) snap_files = builder.get_snap_files() for snap_file in snap_files: print_info('Publish snap: {fname}'.format(fname=snap_file)) local('snapcraft push "{fname}"'.format(fname=snap_file)) local('snapcraft sign-build "{fname}"'.format(fname=snap_file))
def _copy_plugins(self): """ Copy plugins to build folder """ print_info(u'Copy plugins...') src_pluginsdir = u"plugins" for plugin in self._plugins_list: shutil.copytree( os.path.join(src_pluginsdir, plugin, plugin), os.path.join(self._dest_plugins_dir, plugin), )
def build(self): params = self.get_params() command = u'pyinstaller runoutwiker.py ' + u' '.join(params) with lcd(self._src_dir): local(command) self._remove_files() print_info(u'Copy files to dest path.') shutil.copytree(os.path.join(self._dist_dir, u'outwiker'), self._dest_dir)
def _create_binary(self): """ Build with PyInstaller """ print_info(u'Create binary files...') src_dir = self.temp_sources_dir dest_dir = self._executable_dir temp_dir = self.facts.temp_dir builder = PyInstallerBuilderWindows(src_dir, dest_dir, temp_dir) builder.build()
def _create_binary(self): """ Build with PyInstaller """ print_info(u'Create binary files...') src_dir = self.temp_sources_dir dest_dir = self._executable_dir temp_dir = self.facts.temp_dir builder = PyInstallerBuilderWindows(src_dir, dest_dir, temp_dir) builder.build()
def _copy_plugins(self): """ Copy plugins to build folder """ print_info(u'Copy plugins...') src_pluginsdir = u"plugins" for plugin in self._plugins_list: shutil.copytree( os.path.join(src_pluginsdir, plugin, plugin), os.path.join(self._dest_plugins_dir, plugin), )
def _copy_plugins(self, plugins_dir): print_info('Copy plugins:') if not os.path.exists(plugins_dir): os.mkdir(plugins_dir) for plugin_name in PLUGINS_LIST: print_info(' {}'.format(plugin_name)) src_dir = os.path.join(self.facts.src_plugins_dir, plugin_name, plugin_name) shutil.copytree(src_dir, os.path.join(plugins_dir, plugin_name), ignore=shutil.ignore_patterns('__pycache__'))
def upload_plugins(*plugins_list): ''' Upload plugin to site ''' if len(plugins_list) == 0: plugins_list = PLUGINS_LIST version_str = getOutwikerVersionStr() build_plugins_dir = os.path.join(BUILD_DIR, version_str, PLUGINS_DIR) uploader = PluginsUploader(build_plugins_dir, DEPLOY_HOME_PATH) print_info('Uploading plug-ins to {}...'.format(DEPLOY_SERVER_NAME)) uploader.upload(plugins_list)
def _create_archives_without_plugins(self): if not self._create_archives: return print_info(u'Create archives without plugins...') with lcd(self._executable_dir): path_zip = os.path.abspath( os.path.join(self.build_dir, self._resultBaseName + u'.zip')) path_7z = os.path.abspath( os.path.join(self.build_dir, self._resultBaseName + u'.7z')) local(u'7z a "{}" .\* .\plugins -r -aoa'.format(path_zip)) local(u'7z a "{}" .\* .\plugins -r -aoa'.format(path_7z))
def build(self): params = self.get_params() command = u'pyinstaller runoutwiker.py ' + u' '.join(params) with lcd(self._src_dir): local(command) self._remove_files() self._copy_additional_files() print_info(u'Copy files to dest path.') shutil.copytree( os.path.join(self._dist_dir, u'outwiker'), self._dest_dir )
def upload_plugin(*args): ''' Upload plugin to site ''' if len(args) == 0: args = PLUGINS_LIST version_str = getOutwikerVersionStr() for pluginname in args: path_to_plugin_local = os.path.join(BUILD_DIR, version_str, PLUGINS_DIR, pluginname) if not os.path.exists(path_to_plugin_local): continue path_to_xml_local = os.path.join(path_to_plugin_local, PLUGIN_VERSIONS_FILENAME) xml_content_local = readTextFile(path_to_xml_local) appinfo_local = XmlVersionParser().parse(xml_content_local) url = appinfo_local.updatesUrl try: appinfo_remote = downloadAppInfo(url) except Exception: appinfo_remote = None if (appinfo_remote is not None and appinfo_local.currentVersion < appinfo_remote.currentVersion): print_error(u'Error. New version < Prev version') sys.exit(1) elif (appinfo_remote is not None and appinfo_local.currentVersion == appinfo_remote.currentVersion): print_warning(u'Warning: Uploaded the same version') print_info(u'Uploading...') path_to_upload = os.path.dirname( appinfo_local.updatesUrl.replace(DEPLOY_SITE + u'/', DEPLOY_HOME_PATH)) version_local = str(appinfo_local.currentVersion) archive_name = u'{}-{}.zip'.format(pluginname, version_local) path_to_archive_local = os.path.join(path_to_plugin_local, archive_name) with cd(path_to_upload): put(path_to_archive_local, archive_name) put(path_to_xml_local, PLUGIN_VERSIONS_FILENAME) site_versions()
def locale_plugin(pluginname=None): ''' Create or update the localization file for pluginname plug-in ''' plugins = [pluginname] if pluginname else PLUGINS_LIST for name in plugins: print_info(name) with lcd(os.path.join("plugins", name, name)): local(r'find . -iname "*.py" | xargs xgettext -o locale/{}.pot'.format(name)) for lang in LANGUAGES: if os.path.exists(os.path.join('plugins', name, name, 'locale', lang)): local(r'msgmerge -U -N --backup=none locale/{lang}/LC_MESSAGES/{pluginname}.po locale/{pluginname}.pot'.format( pluginname=name, lang=lang))
def locale_plugin(pluginname=None): ''' Create or update the localization file for pluginname plug-in ''' plugins = [pluginname] if pluginname else PLUGINS_LIST for name in plugins: print_info(name) with lcd(os.path.join("plugins", name, name)): local(r'find . -iname "*.py" | xargs xgettext -o locale/{}.pot'.format(name)) for lang in LANGUAGES: if os.path.exists(os.path.join('plugins', name, name, 'locale', lang)): local(r'msgmerge -U -N --backup=none locale/{lang}/LC_MESSAGES/{pluginname}.po locale/{pluginname}.pot'.format( pluginname=name, lang=lang))
def upload_plugin(*args): ''' Upload plugin to site ''' if len(args) == 0: args = PLUGINS_LIST version_str = getOutwikerVersionStr() for pluginname in args: path_to_plugin_local = os.path.join(BUILD_DIR, version_str, PLUGINS_DIR, pluginname) if not os.path.exists(path_to_plugin_local): continue path_to_xml_local = os.path.join(path_to_plugin_local, PLUGIN_VERSIONS_FILENAME) xml_content_local = readTextFile(path_to_xml_local) appinfo_local = XmlVersionParser().parse(xml_content_local) url = appinfo_local.updatesUrl try: appinfo_remote = downloadAppInfo(url) except Exception: appinfo_remote = None if (appinfo_remote is not None and appinfo_local.currentVersion < appinfo_remote.currentVersion): print_error(u'Error. New version < Prev version') sys.exit(1) elif (appinfo_remote is not None and appinfo_local.currentVersion == appinfo_remote.currentVersion): print_warning(u'Warning: Uploaded the same version') print_info(u'Uploading...') path_to_upload = os.path.dirname(appinfo_local.updatesUrl.replace(DEPLOY_SITE + u'/', DEPLOY_HOME_PATH)) version_local = str(appinfo_local.currentVersion) archive_name = u'{}-{}.zip'.format(pluginname, version_local) path_to_archive_local = os.path.join(path_to_plugin_local, archive_name) with cd(path_to_upload): put(path_to_archive_local, archive_name) put(path_to_xml_local, PLUGIN_VERSIONS_FILENAME) site_versions()
def build(self): self._createRootDir() print_info(u'Clearing...') self.clear() self._remove(self.facts.temp_dir) os.mkdir(self.facts.temp_dir) if not os.path.exists(self.build_dir): os.makedirs(self.build_dir) self._copy_sources_to_temp() self._copy_versions_file() print_info(u'Build to {}'.format(self.build_dir)) self._build() self._postBuild()
def _check_outwiker_errors(): print_info('Start OutWiker information checking...') changelog_outwiker_fname = os.path.join(NEED_FOR_BUILD_DIR, OUTWIKER_VERSIONS_FILENAME) versions_outwiker = readTextFile(changelog_outwiker_fname) linter = LinterForOutWiker() status_outwiker, reports_outwiker = linter.check_all(versions_outwiker) for report in reports_outwiker: _print_linter_report(report) if status_outwiker == LinterStatus.OK: print_info('OutWiker information is OK') else: print_error('Outwiker information problems found') return status_outwiker
def upload_distribs(is_stable=False): ''' Upload binary version to site ''' facts = BuildFacts() version = getOutwikerVersion() if is_stable: deploy_path = DEPLOY_STABLE_PATH else: deploy_path = DEPLOY_UNSTABLE_PATH windows_binary_path = os.path.join(PATH_TO_WINDOWS_DISTRIBS, facts.version) binary_uploader = DistribsUploader(version, is_stable, windows_binary_path, deploy_path) print_info('Uploading distribs to {}...'.format(DEPLOY_SERVER_NAME)) binary_uploader.deploy()
def snap_publish(*channels): ''' Publish created snap package channels - comma separated list of channels the snap would be released: edge, beta, candidate, release ''' builder = BuilderSnap(False) snap_files = builder.get_snap_files() for snap_file in snap_files: print_info('Publish snap: {fname}'.format(fname=snap_file)) if channels: channels_str = ','.join(channels) command = 'snapcraft upload "{fname}" --release {channels}'.format( fname=snap_file, channels=channels_str) else: command = 'snapcraft upload "{fname}"'.format(fname=snap_file) local(command)
def _create_archives_with_plugins(self): if not self._create_archives: return print_info(u'Create archives with plugins...') with lcd(self._executable_dir): path_zip = os.path.abspath( os.path.join( self.build_dir, self._resultWithPluginsBaseName + u'.zip') ) path_7z = os.path.abspath( os.path.join( self.build_dir, self._resultWithPluginsBaseName + u'.7z') ) local(u'7z a "{}" .\* .\plugins -r -aoa -xr!*.pyc -xr!.ropeproject'.format(path_zip)) local(u'7z a "{}" .\* .\plugins -r -aoa -xr!*.pyc -xr!.ropeproject'.format(path_7z))
def build(self): super(PyInstallerBuilderLinux, self).build() files_for_strip = [ u'wx._aui.so', u'wx._combo.so', u'wx._controls_.so', u'wx._core_.so', u'wx._gdi_.so', u'wx._html.so', u'wx._html2.so', u'wx._misc_.so', u'wx._stc.so', u'wx._windows_.so', ] for fname in files_for_strip: print_info(u'Strip {}'.format(fname)) with lcd(self._dest_dir): assert os.path.exists(os.path.join(self._dest_dir, fname)) local(u'strip -s -o "{fname}" "{fname}"'.format(fname=fname))
def _create_archives_with_plugins(self): if not self._create_archives: return print_info('Create archives with plugins...') with self.context.cd(self._executable_dir): path_zip = os.path.abspath( os.path.join( self.build_dir, self._resultWithPluginsBaseName + '.zip') ) path_7z = os.path.abspath( os.path.join( self.build_dir, self._resultWithPluginsBaseName + '.7z') ) self.context.run( r'7z a "{}" .\* .\plugins -r -aoa -xr!__pycache__ -xr!.ropeproject'.format(path_zip)) self.context.run( r'7z a "{}" .\* .\plugins -r -aoa -xr!__pycache__ -xr!.ropeproject'.format(path_7z))
def _build(self): print_info('Is stable: {}'.format(self.is_stable)) print_info('Create installer: {}'.format(self._create_installer)) print_info('Create archives: {}'.format(self._create_archives)) self._copy_necessary_files() self._create_plugins_dir() self._create_binary() self._clear_dest_plugins_dir() self._create_archives_without_plugins() self._copy_plugins() self._build_installer() self._create_archives_with_plugins() self._move_executable_dir()
def _check_plugins_errors(): print_info('Start plug-ins information checking...') linter = LinterForPlugin() sum_status = LinterStatus.OK for plugin in PLUGINS_LIST: print_info(' ' + plugin) changelog_fname = os.path.join(PLUGINS_DIR, plugin, PLUGIN_VERSIONS_FILENAME) changelog = readTextFile(changelog_fname) status, reports = linter.check_all(changelog) sum_status = sum_status & status for report in reports: _print_linter_report(report) if sum_status == LinterStatus.OK: print_info('Plug-ins information is OK') else: print_error('Plug-ins information problems found') return sum_status
def _move_executable_dir(self): print_info(u'Move result directory to {}...'.format(self.build_dir)) shutil.move(self._executable_dir, self.build_dir)
def _move_executable_dir(self): print_info(u'Move result directory to {}...'.format(self.build_dir)) shutil.move(self._executable_dir, self.build_dir)
def _copy_necessary_files(self): print_info(u'Copy necessary files...') shutil.copy(u'copyright.txt', self.facts.temp_dir) shutil.copy(u'LICENSE.txt', self.facts.temp_dir)
def _build_snap(self): print_info('Build snap') with lcd(self.facts.temp_dir): local('sudo snapcraft')
def _build_snap(self): print_info('Build snap') with lcd(self.facts.temp_dir): local('snapcraft cleanbuild')
def _copy_necessary_files(self): print_info(u'Copy necessary files...') shutil.copy(u'copyright.txt', self.facts.temp_dir) shutil.copy(u'LICENSE.txt', self.facts.temp_dir)