diff --git a/src/mmpycorex/_version.py b/src/mmpycorex/_version.py index 8750e9a..4d32877 100644 --- a/src/mmpycorex/_version.py +++ b/src/mmpycorex/_version.py @@ -1,2 +1,2 @@ -version_info = (0, 2, 0) +version_info = (0, 3, 0) __version__ = ".".join(map(str, version_info)) diff --git a/src/mmpycorex/install.py b/src/mmpycorex/install.py index 9d24520..8058b86 100644 --- a/src/mmpycorex/install.py +++ b/src/mmpycorex/install.py @@ -77,6 +77,18 @@ def find_existing_mm_install(): else: raise ValueError(f"Unsupported OS: {platform}") +def get_default_install_location(): + """ + Get the default path where Micro-manager gets installed by the download_and_install_mm function + """ + platform = _get_platform() + if platform == 'Windows': + return r'C:\Program Files\Micro-Manager' + elif platform == 'Mac': + return str(os.path.expanduser('~')) + '/Micro-Manager' + else: + raise ValueError(f"Unsupported OS: {platform}") + def download_and_install_mm(destination='auto', mm_install_log_path=None, ci_build=False): """ Download and install the latest nightly build of Micro-Manager @@ -109,9 +121,10 @@ def bar(curr, total, width): print('Downloading: ', latest_version) wget.download(latest_version, out=installer, bar=bar) + if destination == 'auto': + destination = get_default_install_location() + if windows: - if destination == 'auto': - destination = r'C:\Program Files\Micro-Manager' cmd = f"{installer} /SP /VERYSILENT /SUPRESSMSGBOXES /CURRENTUSER /DIR=\"{destination}\"" if mm_install_log_path: @@ -120,8 +133,6 @@ def bar(curr, total, width): return destination else: - if destination == 'auto': - destination = str(os.path.expanduser('~')) + '/Micro-Manager' try: # unmount if already mounted subprocess.run(['hdiutil', 'detach', '/Volumes/Micro-Manager']) diff --git a/src/mmpycorex/launcher.py b/src/mmpycorex/launcher.py index fb50067..910710c 100644 --- a/src/mmpycorex/launcher.py +++ b/src/mmpycorex/launcher.py @@ -6,10 +6,12 @@ import types import os +from mmpycorex.install import get_default_install_location from pymmcore import CMMCore import pymmcore from pyjavaz import DEFAULT_BRIDGE_PORT, server_terminated + import re logger = logging.getLogger(__name__) @@ -120,7 +122,7 @@ def terminate_core_instances(debug=False): atexit.register(terminate_core_instances) def create_core_instance( - mm_app_path: str, config_file: str=None, java_loc: str=None, + mm_app_path: str = get_default_install_location(), config_file: str='MMConfig_demo.cfg', java_loc: str=None, python_backend=False, core_log_path: str='', buffer_size_mb: int=1024, max_memory_mb: int=2000, port: int=DEFAULT_BRIDGE_PORT, debug=False):