diff --git a/.gitignore b/.gitignore index bddaa796..4f1beb72 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ sdist/ var/ #package/ # We are using this name in the source hopefully doesn't come back to bite us. package/*.exe +res/macos/*.dmg *.egg-info/ .installed.cfg *.egg @@ -67,4 +68,5 @@ target/ # Intellij projects .idea/ - +# Internal workflow zip +internal_workflow.zip diff --git a/docs/manual/MAP-install-setup.rst b/docs/manual/MAP-install-setup.rst index 5ca80d3c..ac10cdb0 100644 --- a/docs/manual/MAP-install-setup.rst +++ b/docs/manual/MAP-install-setup.rst @@ -4,11 +4,15 @@ MAP Client Installation and Setup Guide ======================================= -This document describes how to install and setup the MAP Client software for use on your machine. The MAP Client software is a Python application that uses the PySide Qt library bindings. +This document describes how to install and setup the MAP Client software for use on your machine. +The MAP Client software is a Python application that uses the PySide Qt library bindings. -The `Installation`_ section details getting the MAP Client and it's dependencies installed on your system. There are two main ways of getting the MAP Client installed on your operating system. This document will cover both of those methods. For users and plugin developers the suggested method is to `Install Using Pip`_, for developers of the MAP Client framework the suggested method is to `Install Using Bazaar`_. +The `Installation`_ section details getting the MAP Client and it's dependencies installed on your system. +There are two main ways of getting the MAP Client installed on your operating system. This document will cover both of those methods. +For users and plugin developers the suggested method is to `Install Using Pip`_, for developers of the MAP Client framework the suggested method is to `Install Using Bazaar`_. -The `Install Using Pip`_ method is covered first followed by the instructions on how to `Install Using Bazaar`_. For most operating systems Python is already installed but for some, most notably Windows based operating systems, it is not. For instructions on installing Python for Windows based operating systems see the `Installing Python on Windows`_ section. +The `Install Using Pip`_ method is covered first followed by the instructions on how to `Install Using Pre-Built Binary`_. +For most operating systems Python is already installed but for some, most notably Windows based operating systems, it is not. For instructions on installing Python for Windows based operating systems see the `Installing Python on Windows`_ section. The `Setup`_ section details getting the MAP Client setup with external plugins. @@ -16,6 +20,16 @@ The `Setup`_ section details getting the MAP Client setup with external plugins. Installation ------------ +Install Using Pre-Built Binary +------------------------------ + +For both Windows and macOS there are installer applications available from: + + https://github.com/MusculoskeletalAtlasProject/mapclient/releases/download/v0.15.0.rc.2/MAP-Client-0.15.0.exe + +Download and install the package. + + Install Using Pip ================= diff --git a/res/macos/MAP-Client.icns b/res/macos/MAP-Client.icns new file mode 100644 index 00000000..e66bceb8 Binary files /dev/null and b/res/macos/MAP-Client.icns differ diff --git a/res/macos/create_installer.sh b/res/macos/create_installer.sh new file mode 100755 index 00000000..5a33f794 --- /dev/null +++ b/res/macos/create_installer.sh @@ -0,0 +1,22 @@ +#!/bin/sh +version=0.15.0 +variant=-mapping-tools + +app_name=MAP-Client$variant +app_name_with_version=MAP-Client$variant-$version +dmg_name=$app_name_with_version.dmg +test -f $dmg_name && rm $dmg_name +# --volicon "application_icon.icns" \ +create-dmg \ + --volname "$app_name_with_version" \ + --volicon "MAP-Client.icns" \ + --background "map-client-dmg-background.png" \ + --window-pos 200 120 \ + --window-size 800 400 \ + --icon-size 100 \ + --icon "$app_name.app" 200 190 \ + --hide-extension "$app_name.app" \ + --app-drop-link 600 185 \ + "$dmg_name" \ + "../pyinstaller/dist/" + diff --git a/res/macos/map-client-dmg-background.png b/res/macos/map-client-dmg-background.png new file mode 100644 index 00000000..3d419768 Binary files /dev/null and b/res/macos/map-client-dmg-background.png differ diff --git a/res/pyinstaller/create_application.py b/res/pyinstaller/create_application.py index a05f73f9..74468f15 100644 --- a/res/pyinstaller/create_application.py +++ b/res/pyinstaller/create_application.py @@ -2,16 +2,16 @@ import platform import PySide2 as RefMod import PyInstaller.__main__ -from PyInstaller.utils.hooks import collect_data_files +variant = '-mapping-tools' here = os.path.dirname(__file__) run_command = [ '../../src/mapclient/application.py', - '-n', 'MAP-Client', - #'--debug', 'noarchive', - #'--windowed', + '-n', f'MAP-Client{variant}', + '--debug', 'noarchive', + '--windowed', '--noconfirm', '--hidden-import', 'scipy', '--hidden-import', 'scipy.interpolate', @@ -36,11 +36,19 @@ rel_rcc_exe = os.path.relpath(rcc_exe, here) # os.path.join(here, 'dist', 'MAPClient')) rel_uic_exe = os.path.relpath(uic_exe, here) # os.path.join(here, 'dist', 'MAPClient')) + macos_icon = os.path.join('..', 'macos', 'MAP-Client.icns') + run_command.append(f'--icon={macos_icon}') + run_command.append(f'--add-binary={rel_rcc_exe}:PySide2/') run_command.append(f'--add-binary={rel_uic_exe}:PySide2/') elif platform.system() == "Windows": win_icon = os.path.join('..', 'win', 'MAP-Client.ico') run_command.append(f'--icon={win_icon}') +internal_workflow_zip = os.path.abspath(os.path.join('..', '..', 'src', 'internal_workflow.zip')) +if os.path.isfile(internal_workflow_zip): + data = os.pathsep.join([internal_workflow_zip, '.']) + run_command.append(f'--add-data={data}') + print('Running command: ', run_command) PyInstaller.__main__.run(run_command) diff --git a/res/pyinstaller/hooks/hook-mapclientplugins.py b/res/pyinstaller/hooks/hook-mapclientplugins.py index 3364c346..6b79b2d4 100644 --- a/res/pyinstaller/hooks/hook-mapclientplugins.py +++ b/res/pyinstaller/hooks/hook-mapclientplugins.py @@ -1,4 +1,9 @@ -from PyInstaller.utils.hooks import collect_data_files +from pkgutil import walk_packages -datas = collect_data_files('mapclientplugins', include_py_files=True, excludes=['__pycache__']) -hiddenimports = ['imghdr'] +import mapclientplugins + + +# I don't think this will work if the plugin is zipped in an archive. +hiddenimports = ['mapclientplugins'] +for module_loader, name, ispkg in walk_packages(mapclientplugins.__path__, 'mapclientplugins.'): + hiddenimports.append(name) diff --git a/src/mapclient/application.py b/src/mapclient/application.py index 9eaf497e..5bf6162c 100755 --- a/src/mapclient/application.py +++ b/src/mapclient/application.py @@ -26,18 +26,22 @@ import locale import logging +import zipfile from logging import handlers +from mapclient.core.utils import is_frozen, find_file +from mapclient.settings.definitions import INTERNAL_WORKFLOW_ZIP, INTERNAL_WORKFLOW_AVAILABLE, INTERNAL_WORKFLOW_DIR, UNSET_FLAG + os.environ['ETS_TOOLKIT'] = 'qt4' # With PEP366 we need to conditionally import the settings module based on # whether we are executing the file directly of indirectly. This is my # workaround. if __package__: from .settings import info - from .settings.general import get_log_location + from .settings.general import get_log_location, get_default_internal_workflow_dir else: from mapclient.settings import info - from mapclient.settings.general import get_log_location + from mapclient.settings.general import get_log_location, get_default_internal_workflow_dir logger = logging.getLogger('mapclient.application') @@ -120,11 +124,14 @@ def windows_main(app_args): window.setup_application() if not window.check_application_setup(): - window._show_options_dialog(current_tab=1) + window.show_options_dialog(current_tab=1) window.load_packages() window.load_plugins() + om = model.optionsManager() + prepare_internal_workflow(app_args, om) + if app_args.workflow: window.open_workflow(app_args.workflow) @@ -138,6 +145,49 @@ def windows_main(app_args): return app.exec_() +def prepare_internal_workflow(app_args, om): + # Determine if we have an internal workflow. + if is_frozen(): + internal_workflow_zip = os.path.join(sys._MEIPASS, INTERNAL_WORKFLOW_ZIP) + else: + file_dir = os.path.dirname(os.path.abspath(__file__)) + internal_workflow_zip = os.path.realpath(os.path.join(file_dir, '..', INTERNAL_WORKFLOW_ZIP)) + + if os.path.isfile(internal_workflow_zip): + # We have an internal workflow set the option as active. + om.setOption(INTERNAL_WORKFLOW_AVAILABLE, True) + + # Work out internal workflow directory and create if it doesn't exist. + internal_workflow_dir = om.getOption(INTERNAL_WORKFLOW_DIR) + if internal_workflow_dir == UNSET_FLAG or not os.path.isdir(internal_workflow_dir): + internal_workflow_dir = get_default_internal_workflow_dir() + if not os.path.isdir(internal_workflow_dir): + logger.info(f"Creating internal workflow(s) directory '{internal_workflow_dir}'") + os.mkdir(internal_workflow_dir) + + om.setOption(INTERNAL_WORKFLOW_DIR, internal_workflow_dir) + + # Test if a workflow is present. + workflow_file = find_file('.workflow.conf', internal_workflow_dir) + if workflow_file is None: + # No workflow exists in the workflow directory so we will + # unzip the stored workflow(s) into this location. + logger.info("Decompressing internal workflow(s) ...") + archive = zipfile.ZipFile(internal_workflow_zip) + archive.extractall(f"{internal_workflow_dir}") + + # Should definitely have a workflow now. + workflow_file = find_file('.workflow.conf', internal_workflow_dir) + default_workflow_directory = os.path.dirname(workflow_file) + + # Set workflow to internal workflow if None is currently present. + if app_args.workflow is None: + app_args.workflow = default_workflow_directory + logger.info("Loading internal default workflow.") + else: + om.setOption(INTERNAL_WORKFLOW_AVAILABLE, False) + + class ConsumeOutput(object): def __init__(self): self.messages = list() @@ -146,7 +196,7 @@ def write(self, message): self.messages.append(message) -def non_gui_main(app_args): +def sans_gui_main(app_args): locale.setlocale(locale.LC_ALL, '') from PySide2 import QtGui @@ -169,9 +219,13 @@ def non_gui_main(app_args): wm = model.workflowManager() pm = model.pluginManager() pam = model.package_manager() + om = model.optionsManager() pam.load() pm.load() + + prepare_internal_workflow(app_args, om) + try: wm.load(app_args.workflow) except Exception: @@ -202,7 +256,7 @@ def main(): sys.exit(-2) if args.headless and args.workflow: - sys.exit(non_gui_main(args)) + sys.exit(sans_gui_main(args)) else: sys.exit(windows_main(args)) diff --git a/src/mapclient/core/managers/optionsmanager.py b/src/mapclient/core/managers/optionsmanager.py index 57b449fa..614756b4 100644 --- a/src/mapclient/core/managers/optionsmanager.py +++ b/src/mapclient/core/managers/optionsmanager.py @@ -5,26 +5,29 @@ """ from mapclient.core.utils import which from mapclient.settings.general import get_virtualenv_directory -from mapclient.settings.definitions import SHOW_STEP_NAMES, INTERNAL_EXE, \ - DONT_CREATE_VIRTUAL_ENV, OPTIONS_SETTINGS_TAG, \ +from mapclient.settings.definitions import SHOW_STEP_NAMES, INTERNAL_EXE, UNSET_FLAG, \ + DONT_CREATE_VIRTUAL_ENV, OPTIONS_SETTINGS_TAG, INTERNAL_WORKFLOW_AVAILABLE, INTERNAL_WORKFLOW_DIR, \ VIRTUAL_ENV_PATH, GIT_EXE, PYSIDE_UIC_EXE, PYSIDE_RCC_EXE, PREVIOUS_PW_WRITE_STEP_LOCATION, \ PREVIOUS_PW_ICON_LOCATION, CHECK_TOOLS_ON_STARTUP, USE_EXTERNAL_GIT, USE_EXTERNAL_RCC, USE_EXTERNAL_UIC def _is_boolean(option): - return option in [SHOW_STEP_NAMES, CHECK_TOOLS_ON_STARTUP, DONT_CREATE_VIRTUAL_ENV, USE_EXTERNAL_GIT, USE_EXTERNAL_RCC, USE_EXTERNAL_UIC] + return option in [SHOW_STEP_NAMES, CHECK_TOOLS_ON_STARTUP, DONT_CREATE_VIRTUAL_ENV, + USE_EXTERNAL_GIT, USE_EXTERNAL_RCC, USE_EXTERNAL_UIC, INTERNAL_WORKFLOW_AVAILABLE] class OptionsManager(object): def __init__(self): - self._options = {SHOW_STEP_NAMES: True, DONT_CREATE_VIRTUAL_ENV: False, CHECK_TOOLS_ON_STARTUP: True, - USE_EXTERNAL_GIT: False, USE_EXTERNAL_RCC: False, USE_EXTERNAL_UIC: False, - VIRTUAL_ENV_PATH: get_virtualenv_directory(), GIT_EXE: which('git'), - PYSIDE_RCC_EXE: INTERNAL_EXE, PYSIDE_UIC_EXE: INTERNAL_EXE, - - PREVIOUS_PW_WRITE_STEP_LOCATION: '', PREVIOUS_PW_ICON_LOCATION: ''} # Set default values + self._options = { + SHOW_STEP_NAMES: True, DONT_CREATE_VIRTUAL_ENV: False, CHECK_TOOLS_ON_STARTUP: True, + USE_EXTERNAL_GIT: False, USE_EXTERNAL_RCC: False, USE_EXTERNAL_UIC: False, + VIRTUAL_ENV_PATH: get_virtualenv_directory(), GIT_EXE: which('git'), + PYSIDE_RCC_EXE: INTERNAL_EXE, PYSIDE_UIC_EXE: INTERNAL_EXE, + PREVIOUS_PW_WRITE_STEP_LOCATION: '', PREVIOUS_PW_ICON_LOCATION: '', + INTERNAL_WORKFLOW_AVAILABLE: False, INTERNAL_WORKFLOW_DIR: UNSET_FLAG, + } def getOptions(self): return self._options @@ -56,5 +59,3 @@ def readSettings(self, settings): else: self._options[option] = settings.value(option) settings.endGroup() - - diff --git a/src/mapclient/core/utils.py b/src/mapclient/core/utils.py index 1fa74fba..2445f3c3 100644 --- a/src/mapclient/core/utils.py +++ b/src/mapclient/core/utils.py @@ -29,7 +29,7 @@ def is_frozen(): - return getattr(sys, 'frozen', False) # new py2exe + return getattr(sys, 'frozen', False) def convertExceptionToMessage(e): diff --git a/src/mapclient/settings/definitions.py b/src/mapclient/settings/definitions.py index 74ab63a0..1197ced5 100644 --- a/src/mapclient/settings/definitions.py +++ b/src/mapclient/settings/definitions.py @@ -52,4 +52,10 @@ PREVIOUS_PW_WRITE_STEP_LOCATION = 'previous_write_step_location' PREVIOUS_PW_ICON_LOCATION = 'previous_icon_location' +UNSET_FLAG = '' INTERNAL_EXE = '' + +INTERNAL_WORKFLOWS_DIR = 'MAPClient-Workflows' +INTERNAL_WORKFLOW_ZIP = 'internal_workflow.zip' +INTERNAL_WORKFLOW_AVAILABLE = 'internal_workflow_available' +INTERNAL_WORKFLOW_DIR = 'lineEditInternalWorkflowDirectory' diff --git a/src/mapclient/settings/general.py b/src/mapclient/settings/general.py index b17a0fd8..3d2c85ee 100644 --- a/src/mapclient/settings/general.py +++ b/src/mapclient/settings/general.py @@ -18,8 +18,10 @@ along with MAP Client. If not, see .. """ import os +import tempfile from PySide2 import QtCore +from mapclient.settings.definitions import INTERNAL_WORKFLOWS_DIR from mapclient.settings.info import VERSION_STRING @@ -50,6 +52,10 @@ def get_virtualenv_directory(): return _get_app_directory('venv_' + VERSION_STRING) +def get_default_internal_workflow_dir(): + return os.path.join(tempfile.gettempdir(), INTERNAL_WORKFLOWS_DIR) + + def get_virtualenv_site_packages_directory(virtualenv_dir): print('Confirm path on other OSes, so far only checked on Windows.') return os.path.join(virtualenv_dir, 'Lib', 'site-packages') diff --git a/src/mapclient/tools/pluginwizard/skeletonstrings.py b/src/mapclient/tools/pluginwizard/skeletonstrings.py index 8f0b72aa..e038922b 100644 --- a/src/mapclient/tools/pluginwizard/skeletonstrings.py +++ b/src/mapclient/tools/pluginwizard/skeletonstrings.py @@ -338,6 +338,7 @@ def validate(self): SETUP_DIR = os.path.dirname(os.path.abspath(__file__)) + # List all of your Python package dependencies in the # requirements.txt file @@ -348,6 +349,7 @@ def readfile(filename, split=False): return stream.read().split("\\n") return stream.read() + readme = readfile("README.rst", split=True)[3:] # skip title # For requirements not hosted on PyPi place listings # into the 'requirements.txt' file. @@ -364,14 +366,16 @@ def run(self): subprocess.call(['pip', 'install', '-r', os.path.join(SETUP_DIR, 'requirements.txt')]) -setup(name=%(name)r, +setup( + name=%(name)r, version=%(version)r, description=%(description)r, long_description='\\n'.join(readme) + source_license, + long_description_content_type='text/x-rst', classifiers=[ - "Development Status :: 3 - Alpha", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", ], cmdclass={'install': InstallCommand,}, author=%(author)r, @@ -382,7 +386,7 @@ def run(self): include_package_data=True, zip_safe=False, install_requires=requires, - ) +) """ @@ -392,193 +396,6 @@ def run(self): APACHE_LICENSE = """\ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{{}}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. Copyright {yyyy} {name_of_copyright_owner} diff --git a/src/mapclient/view/mainwindow.py b/src/mapclient/view/mainwindow.py index 5d1dcc4e..5e3989b4 100644 --- a/src/mapclient/view/mainwindow.py +++ b/src/mapclient/view/mainwindow.py @@ -191,7 +191,7 @@ def _make_connections(self): self._action_Quit.triggered.connect(self.quit_application) self._action_About.triggered.connect(self.about) self._action_LogInformation.triggered.connect(self._show_log_information_dialog) - self._action_Options.triggered.connect(self._show_options_dialog) + self._action_Options.triggered.connect(self.show_options_dialog) self._action_PluginManager.triggered.connect(self._show_plugin_manager_dialog) self._action_PackageManager.triggered.connect(self._show_package_manager_dialog) self._action_PluginWizard.triggered.connect(self._show_plugin_wizard_dialog) @@ -305,7 +305,7 @@ def _show_log_information_dialog(self): dlg.setModal(True) dlg.exec_() - def _show_options_dialog(self, current_tab=0): + def show_options_dialog(self, current_tab=0): from mapclient.view.managers.options.optionsdialog import OptionsDialog om = self._model.optionsManager() diff --git a/src/mapclient/view/managers/options/optionsdialog.py b/src/mapclient/view/managers/options/optionsdialog.py index 6da5d653..3a36d603 100644 --- a/src/mapclient/view/managers/options/optionsdialog.py +++ b/src/mapclient/view/managers/options/optionsdialog.py @@ -12,7 +12,7 @@ from mapclient.core.checks import WizardToolChecks, VCSChecks from mapclient.view.syntaxhighlighter import SyntaxHighlighter from mapclient.settings.definitions import VIRTUAL_ENVIRONMENT_STRING, \ - WIZARD_TOOL_STRING, PMR_TOOL_STRING + WIZARD_TOOL_STRING, PMR_TOOL_STRING, INTERNAL_WORKFLOW_AVAILABLE class OptionsDialog(QtWidgets.QDialog): @@ -46,6 +46,7 @@ def _make_connections(self): self._ui.checkBoxUseExternalGit.clicked.connect(self._use_external_star_clicked) self._ui.checkBoxUseExternalPySideRCC.clicked.connect(self._use_external_star_clicked) self._ui.checkBoxUseExternalPySideUIC.clicked.connect(self._use_external_star_clicked) + self._ui.pushButtonInternalWorkflowDirectory.clicked.connect(self._internal_workflow_directory_button_clicked) def _update_ui(self): self._ui.lineEditGitExecutable.setEnabled(self._ui.checkBoxUseExternalGit.isChecked()) @@ -54,6 +55,15 @@ def _update_ui(self): self._ui.pushButtonPySideRCC.setEnabled(self._ui.checkBoxUseExternalPySideRCC.isChecked()) self._ui.lineEditPySideUIC.setEnabled(self._ui.checkBoxUseExternalPySideUIC.isChecked()) self._ui.pushButtonPySideUIC.setEnabled(self._ui.checkBoxUseExternalPySideUIC.isChecked()) + if INTERNAL_WORKFLOW_AVAILABLE in self._original_options: + self._ui.groupBoxInternalWorkflowDirectory.setVisible(self._original_options[INTERNAL_WORKFLOW_AVAILABLE]) + + def _internal_workflow_directory_button_clicked(self): + directory = QtWidgets.QFileDialog.getExistingDirectory(self, caption='Select internal workflow directory', + dir=self._location) + if directory: + self._ui.lineEditInternalWorkflowDirectory.setText(directory) + self._location = directory def _pyside_rcc_button_clicked(self): rcc_program, _ = QtWidgets.QFileDialog.getOpenFileName(self, caption='Select PySide Resource Compiler', @@ -135,6 +145,7 @@ def load(self, options): pysidercc_option = self._ui.lineEditPySideRCC.objectName() pysideuic_option = self._ui.lineEditPySideUIC.objectName() vcs_option = self._ui.lineEditGitExecutable.objectName() + internal_directory_option = self._ui.lineEditInternalWorkflowDirectory.objectName() if step_name_option in options: self._ui.checkBoxShowStepNames.setChecked(options[step_name_option]) if check_tools_option in options: @@ -151,6 +162,8 @@ def load(self, options): self._ui.lineEditPySideUIC.setText(options[pysideuic_option]) if vcs_option in options: self._ui.lineEditGitExecutable.setText(options[vcs_option]) + if internal_directory_option in options: + self._ui.lineEditInternalWorkflowDirectory.setText(options[internal_directory_option]) self._update_ui() self._test_tools() @@ -163,7 +176,8 @@ def save(self): self._ui.checkBoxUseExternalPySideUIC.objectName(): self._ui.checkBoxUseExternalPySideUIC.isChecked(), self._ui.lineEditPySideRCC.objectName(): self._ui.lineEditPySideRCC.text(), self._ui.lineEditPySideUIC.objectName(): self._ui.lineEditPySideUIC.text(), - self._ui.lineEditGitExecutable.objectName(): self._ui.lineEditGitExecutable.text()} + self._ui.lineEditGitExecutable.objectName(): self._ui.lineEditGitExecutable.text(), + self._ui.lineEditInternalWorkflowDirectory.objectName(): self._ui.lineEditInternalWorkflowDirectory.text()} return options diff --git a/src/mapclient/view/managers/options/qt/optionsdialog.ui b/src/mapclient/view/managers/options/qt/optionsdialog.ui index 2f8013df..97c32bca 100644 --- a/src/mapclient/view/managers/options/qt/optionsdialog.ui +++ b/src/mapclient/view/managers/options/qt/optionsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 525 - 579 + 581 + 637 @@ -27,14 +27,65 @@ - 1 + 0 &General - - + + + + + + + + + + + Check tools on application start + + + true + + + + + + + Show step names + + + true + + + + + + + + + + Internal workflow directory + + + + + + + + + Select the internal workflow directory. + + + ... + + + + + + + Qt::Vertical @@ -47,26 +98,6 @@ - - - - Show step names - - - true - - - - - - - Check tools on application start - - - true - - - diff --git a/src/mapclient/view/managers/options/ui/ui_optionsdialog.py b/src/mapclient/view/managers/options/ui/ui_optionsdialog.py index 7419de77..bf1cfb57 100644 --- a/src/mapclient/view/managers/options/ui/ui_optionsdialog.py +++ b/src/mapclient/view/managers/options/ui/ui_optionsdialog.py @@ -17,7 +17,7 @@ class Ui_OptionsDialog(object): def setupUi(self, OptionsDialog): if not OptionsDialog.objectName(): OptionsDialog.setObjectName(u"OptionsDialog") - OptionsDialog.resize(525, 579) + OptionsDialog.resize(581, 637) self.gridLayout = QGridLayout(OptionsDialog) self.gridLayout.setObjectName(u"gridLayout") self.buttonBox = QDialogButtonBox(OptionsDialog) @@ -31,23 +31,47 @@ def setupUi(self, OptionsDialog): self.tabWidget.setObjectName(u"tabWidget") self.tabGeneral = QWidget() self.tabGeneral.setObjectName(u"tabGeneral") - self.gridLayout_3 = QGridLayout(self.tabGeneral) - self.gridLayout_3.setObjectName(u"gridLayout_3") - self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) + self.verticalLayout_4 = QVBoxLayout(self.tabGeneral) + self.verticalLayout_4.setObjectName(u"verticalLayout_4") + self.groupBox = QGroupBox(self.tabGeneral) + self.groupBox.setObjectName(u"groupBox") + self.verticalLayout_6 = QVBoxLayout(self.groupBox) + self.verticalLayout_6.setObjectName(u"verticalLayout_6") + self.checkBoxCheckToolsOnStartup = QCheckBox(self.groupBox) + self.checkBoxCheckToolsOnStartup.setObjectName(u"checkBoxCheckToolsOnStartup") + self.checkBoxCheckToolsOnStartup.setChecked(True) - self.gridLayout_3.addItem(self.verticalSpacer, 2, 1, 1, 1) + self.verticalLayout_6.addWidget(self.checkBoxCheckToolsOnStartup) - self.checkBoxShowStepNames = QCheckBox(self.tabGeneral) + self.checkBoxShowStepNames = QCheckBox(self.groupBox) self.checkBoxShowStepNames.setObjectName(u"checkBoxShowStepNames") self.checkBoxShowStepNames.setChecked(True) - self.gridLayout_3.addWidget(self.checkBoxShowStepNames, 0, 0, 1, 1) + self.verticalLayout_6.addWidget(self.checkBoxShowStepNames) - self.checkBoxCheckToolsOnStartup = QCheckBox(self.tabGeneral) - self.checkBoxCheckToolsOnStartup.setObjectName(u"checkBoxCheckToolsOnStartup") - self.checkBoxCheckToolsOnStartup.setChecked(True) - self.gridLayout_3.addWidget(self.checkBoxCheckToolsOnStartup, 1, 0, 1, 1) + self.verticalLayout_4.addWidget(self.groupBox) + + self.groupBoxInternalWorkflowDirectory = QGroupBox(self.tabGeneral) + self.groupBoxInternalWorkflowDirectory.setObjectName(u"groupBoxInternalWorkflowDirectory") + self.horizontalLayout_4 = QHBoxLayout(self.groupBoxInternalWorkflowDirectory) + self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") + self.lineEditInternalWorkflowDirectory = QLineEdit(self.groupBoxInternalWorkflowDirectory) + self.lineEditInternalWorkflowDirectory.setObjectName(u"lineEditInternalWorkflowDirectory") + + self.horizontalLayout_4.addWidget(self.lineEditInternalWorkflowDirectory) + + self.pushButtonInternalWorkflowDirectory = QPushButton(self.groupBoxInternalWorkflowDirectory) + self.pushButtonInternalWorkflowDirectory.setObjectName(u"pushButtonInternalWorkflowDirectory") + + self.horizontalLayout_4.addWidget(self.pushButtonInternalWorkflowDirectory) + + + self.verticalLayout_4.addWidget(self.groupBoxInternalWorkflowDirectory) + + self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) + + self.verticalLayout_4.addItem(self.verticalSpacer) self.tabWidget.addTab(self.tabGeneral, "") self.tabToolSettings = QWidget() @@ -192,7 +216,7 @@ def setupUi(self, OptionsDialog): self.buttonBox.accepted.connect(OptionsDialog.accept) self.buttonBox.rejected.connect(OptionsDialog.reject) - self.tabWidget.setCurrentIndex(1) + self.tabWidget.setCurrentIndex(0) QMetaObject.connectSlotsByName(OptionsDialog) @@ -200,8 +224,14 @@ def setupUi(self, OptionsDialog): def retranslateUi(self, OptionsDialog): OptionsDialog.setWindowTitle(QCoreApplication.translate("OptionsDialog", u"Options", None)) - self.checkBoxShowStepNames.setText(QCoreApplication.translate("OptionsDialog", u"Show step names", None)) + self.groupBox.setTitle("") self.checkBoxCheckToolsOnStartup.setText(QCoreApplication.translate("OptionsDialog", u"Check tools on application start", None)) + self.checkBoxShowStepNames.setText(QCoreApplication.translate("OptionsDialog", u"Show step names", None)) + self.groupBoxInternalWorkflowDirectory.setTitle(QCoreApplication.translate("OptionsDialog", u"Internal workflow directory", None)) +#if QT_CONFIG(tooltip) + self.pushButtonInternalWorkflowDirectory.setToolTip(QCoreApplication.translate("OptionsDialog", u"Select the internal workflow directory.", None)) +#endif // QT_CONFIG(tooltip) + self.pushButtonInternalWorkflowDirectory.setText(QCoreApplication.translate("OptionsDialog", u"...", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabGeneral), QCoreApplication.translate("OptionsDialog", u"&General", None)) self.groupBoxStepWizard.setTitle(QCoreApplication.translate("OptionsDialog", u"Step Wizard", None)) self.checkBoxUseExternalPySideRCC.setText(QCoreApplication.translate("OptionsDialog", u"Use external PySide resource compiler (rcc)", None)) diff --git a/src/mapclient/view/workflow/workflowgraphicsitems.py b/src/mapclient/view/workflow/workflowgraphicsitems.py index bdec7512..cf83017c 100644 --- a/src/mapclient/view/workflow/workflowgraphicsitems.py +++ b/src/mapclient/view/workflow/workflowgraphicsitems.py @@ -75,7 +75,7 @@ def paint(self, painter, option, widget): if line.length() == 0.0: return - painter.setPen(QtWidgets.QPen(QtCore.Qt.black, 1, QtCore.Qt.DashLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)) + painter.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DashLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)) painter.drawLine(line) painter.drawPixmap(midPoint.x() - 8, midPoint.y() - 8, self._pixmap) diff --git a/src/setup.plugins.py b/src/setup.plugins.py new file mode 100644 index 00000000..bd40fffa --- /dev/null +++ b/src/setup.plugins.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import codecs +import os +import re + +from setuptools import setup +from setuptools import find_packages + + +here = os.path.abspath(os.path.dirname(__file__)) + + +def read(*parts): + with codecs.open(os.path.join(here, *parts), 'r') as fp: + return fp.read() + + +def find_version(*file_paths): + version_file = read(*file_paths) + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", + version_file, re.M) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") + + +# Define the list of requirements +install_requires = [ + 'PySide2', +] + + +setup( + name='mapclientplugins.builtin', + version=find_version("mapclient", "settings", "version.py"), + description='Builtin plugins for MAP Client.', + author='MAP Client Developers', + author_email='mapclient-devs@physiomeproject.org', + url='https://github.com/MusculoskeletalAtlasProject/mapclient', + namespace_packages=['mapclientplugins', ], + zip_safe=False, + packages=find_packages(exclude=['tests', 'tests.*', 'mapclient', 'mapclient.*', 'utils', 'utils.*' ]), + install_requires=install_requires, +)