def init_pasta(pasta_home=None): """ Sets the _DEFAULT_TOOLS_PATH. """ global _DEFAULT_TOOLS_PATH bin_dir = pasta.pasta_tools_deploy_dir(default_to_dev_dir=True) if _DEFAULT_TOOLS_PATH is None: _DEFAULT_TOOLS_PATH = {} for i in get_external_tool_classes(): tool_name = i.section_name.split()[0] _DEFAULT_TOOLS_PATH[tool_name] = os.path.join(bin_dir, tool_name) if platform.system() == 'Windows' and tool_name != 'opal': _DEFAULT_TOOLS_PATH[tool_name] += '.exe' _DEFAULT_TOOLS_PATH['opal'] += '.jar'
if sys.argv[1] == 'py2exe': sys.stderr.write( "\nMoving 'mafft.exe' into bundled binary directory ... \n") src_path = os.path.join(PY2EXE_DIST_DIR, "mafft.exe") dest_path = os.path.join(PY2EXE_DIST_DIR, bin_win_dest, "mafft.exe") if os.path.exists(dest_path): os.remove(dest_path) os.rename(src_path, dest_path) sys.stderr.write("OK\n") # On Linux and OS X systems, sym-link all tool scripts # to `bin` subdirectory, so PASTA can be run from the command-line # I know this is ugly. Trust me, I hate it as much as you do. if platform.system() != "Windows": DEST_DIR_ROOT = pasta.pasta_tools_deploy_dir(default_to_dev_dir=False) def create_symlink(src_path, subdir=None): if subdir: dest_dir = os.path.join(DEST_DIR_ROOT, subdir) else: dest_dir = DEST_DIR_ROOT dest_path = os.path.join(dest_dir, os.path.basename(src_path)) sys.stderr.write("\nCreating link: '%s' => '%s'\n" % (src_path, dest_path)) if os.path.exists(dest_path) and os.path.islink(dest_path): real_dest = os.path.abspath(os.path.realpath(dest_path)) if real_dest != os.path.abspath(os.path.realpath(src_path)): msg = "ERROR: Symbolic link '%s' already exists, but points to different source: '%s'\n[Aborting]\nIf the old file was part of older PASTA versions, remove the old path manually and rerun." % ( src_path, real_dest) sys.exit(msg)
sys.stderr.write("\nMoving 'mafft.exe' into bundled binary directory ... \n") src_path = os.path.join(PY2EXE_DIST_DIR, "mafft.exe") dest_path = os.path.join(PY2EXE_DIST_DIR, bin_win_dest, "mafft.exe") if os.path.exists(dest_path): os.remove(dest_path) os.rename(src_path, dest_path) sys.stderr.write("OK\n") # On Linux and OS X systems, sym-link all tool scripts # to `bin` subdirectory, so PASTA can be run from the command-line # I know this is ugly. Trust me, I hate it as much as you do. if platform.system() != "Windows": DEST_DIR_ROOT = pasta.pasta_tools_deploy_dir(default_to_dev_dir=False) def create_symlink(src_path, subdir=None): if subdir: dest_dir = os.path.join(DEST_DIR_ROOT, subdir) else: dest_dir = DEST_DIR_ROOT dest_path = os.path.join(dest_dir, os.path.basename(src_path)) sys.stderr.write("\nCreating link: '%s' => '%s'\n" % (src_path, dest_path)) if os.path.exists(dest_path) and os.path.islink(dest_path): real_dest = os.path.abspath(os.path.realpath(dest_path)) if real_dest != os.path.abspath(os.path.realpath(src_path)): msg = "ERROR: Symbolic link '%s' already exists, but points to different source: '%s'\n[Aborting]\nIf the old file was part of older PASTA versions, remove the old path manually and rerun." % (src_path, real_dest) sys.exit(msg) else: sys.stderr.write("Path already exists and is linked correctly.\n") elif os.path.exists(dest_path):