Skip to content

Commit

Permalink
Merge pull request #167 from scipion-em/devel
Browse files Browse the repository at this point in the history
releasing devel
  • Loading branch information
fonsecareyna82 authored Jun 23, 2023
2 parents 3fb59cb + a2c0665 commit 7bf0cd3
Show file tree
Hide file tree
Showing 11 changed files with 625 additions and 168 deletions.
12 changes: 12 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@

v3.1.0
users:
- Fixing an error related with the Plugin Manager when clicking the plugin treeview
- Fix workflow tutorial intro.
- New variable (flag) to define if binaries are installed by default or not --> SCIPION_DONT_INSTALL_BINARIES (any value will deactivate installation of binaries
- scipion3 config -p <relion> (or any other): shows plugin url too
- SetOfVolumes and SetOfParticles have DataViewer as the default one.

developers:
Update the methods checkLib and addPackage to improve the installation of plugins with libraries dependencies.

v3.0.12
users:
old config file is now backed up (at backup/scipion.conf.YYmmDDHHMMSS) always after any scipion config command that updates the config files.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scipion-em
outdated==0.2.1
outdated==0.2.2
2 changes: 1 addition & 1 deletion scipion/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '3.0.12'
__version__ = '3.1.0'

2 changes: 2 additions & 0 deletions scipion/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def main():
defaultViewers.append('"SetOfLandmarkModels":["imod.viewers.ImodViewer"]')
defaultViewers.append('"SetOfTomograms":["imod.viewers.ImodViewer"]')
defaultViewers.append('"SetOfSubTomograms":["pwem.viewers.DataViewer"]')
defaultViewers.append('"SetOfVolumes":["pwem.viewers.DataViewer"]')
defaultViewers.append('"SetOfParticles":["pwem.viewers.DataViewer"]')

os.environ["VIEWERS"] = '{%s}' % ','.join(defaultViewers)

Expand Down
473 changes: 455 additions & 18 deletions scipion/install/funcs.py

Large diffs are not rendered by default.

29 changes: 18 additions & 11 deletions scipion/install/install_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from scipion.constants import MODE_INSTALL_PLUGIN, MODE_UNINSTALL_PLUGIN
from scipion.install import Environment
from scipion.install.plugin_funcs import PluginRepository, PluginInfo
from scipion.install.plugin_funcs import PluginRepository, PluginInfo, installBinsDefault
from pyworkflow.utils import redStr

# ************************************************************************
Expand Down Expand Up @@ -68,6 +68,7 @@ def installPluginMethods():
# Install parser #
############################################################################


installParser = subparsers.add_parser(MODE_INSTALL_PLUGIN[1], aliases=[MODE_INSTALL_PLUGIN[0]], formatter_class=argparse.RawTextHelpFormatter,
usage="%s [-h] [--noBin] [-p pluginName [pipVersion ...]]" %
invokeCmd,
Expand Down Expand Up @@ -171,6 +172,7 @@ def installPluginMethods():
parserUsed = modeToParser[mode]
exitWithErrors = False


if parsedArgs.help or (mode in [MODE_INSTALL_BINS, MODE_UNINSTALL_BINS]
and len(parsedArgs.binName) == 0):

Expand Down Expand Up @@ -212,7 +214,7 @@ def installPluginMethods():
plugin = PluginInfo(pipName=pluginName, pluginSourceUrl=pluginSrc, remote=False)
numberProcessor = parsedArgs.j
installed = plugin.installPipModule()
if installed and not parsedArgs.noBin:
if installed and installBinsDefault() and not parsedArgs.noBin:
plugin.getPluginClass()._defineVariables()
plugin.installBin({'args': ['-j', numberProcessor]})
else:
Expand All @@ -229,22 +231,27 @@ def installPluginMethods():
plugin = pluginDict.get(pluginName, None)
if plugin:
installed = plugin.installPipModule(version=pluginVersion)
if installed and not parsedArgs.noBin:
if installed and installBinsDefault() and not parsedArgs.noBin:
plugin.getPluginClass()._defineVariables()
plugin.installBin({'args': ['-j', numberProcessor]})
else:
print("WARNING: Plugin %s does not exist." % pluginName)
exitWithErrors = True

elif parsedArgs.mode in MODE_UNINSTALL_PLUGIN:

for pluginName in parsedArgs.plugin:
plugin = PluginInfo(pluginName, pluginName, remote=False)
if plugin.isInstalled():
if not parsedArgs.noBin:
plugin.uninstallBins()
plugin.uninstallPip()
else:
print("WARNING: Plugin %s is not installed." % pluginName)
if parsedArgs.plugin:
for pluginName in parsedArgs.plugin:
plugin = PluginInfo(pluginName, pluginName, remote=False)
if plugin.isInstalled():
if installBinsDefault() and not parsedArgs.noBin:
plugin.uninstallBins()
plugin.uninstallPip()
else:
print("WARNING: Plugin %s is not installed." % pluginName)
else:
print("Incorrect usage of command 'uninstallp'. Execute 'scipion3 uninstallp --help' or "
"'scipion3 help' for more details.")

elif parsedArgs.mode == MODE_INSTALL_BINS:
binToInstallList = parsedArgs.binName
Expand Down
9 changes: 9 additions & 0 deletions scipion/install/plugin_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ def getInstallenv(self, envArgs=None):
plugin.defineBinaries(env)
except Exception as e:
print("Couldn't get binaries definition of %s plugin: %s" % (self.name, e))
import traceback
traceback.print_exc()
return env
else:
return None
Expand Down Expand Up @@ -523,3 +525,10 @@ def ansi(n):
else:
printStr = "List of available plugins in plugin repository inaccessible at this time."
return printStr


def installBinsDefault():
""" Returns the default behaviour for installing binaries
By default it is TRUE, define "SCIPION_DONT_INSTALL_BINARIES" to anything to deactivate binaries installation"""

return os.environ.get("SCIPION_DONT_INSTALL_BINARIES", True) == True
35 changes: 18 additions & 17 deletions scipion/install/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,22 +673,23 @@ def _onPluginTreeClick(self, event):
self.popup_menu.unpost()
x, y, widget = event.x, event.y, event.widget
elem = widget.identify("element", x, y)
self.tree.selectedItem = self.tree.identify_row(y)
if "image" in elem:
# a box was clicked
self._treeOperation()
else:
if self.tree.selectedItem is not None:
if self.isPlugin(self.tree.item(self.tree.selectedItem,
"values")[0]):
self.showPluginInformation(self.tree.selectedItem)
else:
parent = self.tree.parent(self.tree.selectedItem)
self.showPluginInformation(parent)
if len(self.operationList.getOperations(None)):
self.executeOpsBtn.config(state='normal')
else:
self.executeOpsBtn.config(state='disable')
if elem:
self.tree.selectedItem = self.tree.identify_row(y)
if "image" in elem:
# a box was clicked
self._treeOperation()
else:
if self.tree.selectedItem is not None:
item = self.tree.selectedItem
if not self.isPlugin(self.tree.item(item, "values")[0]):
item = self.tree.parent(item)

self.showPluginInformation(item)

if len(self.operationList.getOperations(None)):
self.executeOpsBtn.config(state='normal')
else:
self.executeOpsBtn.config(state='disable')

def _deleteSelectedOperation(self, e=None):
"""
Expand Down Expand Up @@ -887,7 +888,7 @@ def showPluginInformation(self, pluginName):
plugin.latestRelease + ' available. Right-click on the '
'plugin to update it)')
self.topPanelTree.tag_configure('pluginVersion',
foreground=Color.RED_COLOR)
foreground=Config.SCIPION_MAIN_COLOR)
else:
self.topPanelTree.tag_configure('pluginVersion', foreground='black')
self.topPanelTree.insert('', 'end', pluginVersion,
Expand Down
92 changes: 6 additions & 86 deletions scipion/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ def main(args=None):
print("%s = %s" % (k, v))
print("\nThese variables can be added/edited in '%s'"
% os.environ[SCIPION_CONFIG])
url = plugin.getUrl()

if url != "":
print("\nMore information these variables might be found at '%s'"
% url)

else:
print("No plugin found with name '%s'. Module name is expected,\n"
"i.e. 'scipion3 config -p xmipp3' shows the config variables "
Expand Down Expand Up @@ -466,92 +472,6 @@ def compareConfigVariable(section, variableName, valueInConfig, valueInTemplate)
yellow(valueInTemplate)))


# def guessJava():
# """Guess the system's Java installation, return a dict with the Java keys"""
#
# options = {}
# candidates = []
#
# # First check if the system has a favorite one.
# if 'JAVA_HOME' in os.environ:
# candidates.append(os.environ['JAVA_HOME'])
#
# # Add also all the ones related to a "javac" program.
# for d in os.environ.get('PATH', '').split(':'):
# if not os.path.isdir(d) or 'javac' not in os.listdir(d):
# continue
# javaBin = os.path.realpath(join(d, 'javac'))
# if javaBin.endswith('/bin/javac'):
# javaHome = javaBin[:-len('/bin/javac')]
# candidates.append(javaHome)
# if javaHome.endswith('/jre'):
# candidates.append(javaHome[:-len('/jre')])
#
# # Check in order if for any of our candidates, all related
# # directories and files exist. If they do, that'd be our best guess.
# for javaHome in candidates:
# allExist = True
# for path in ['include', join('bin', 'javac'), join('bin', 'jar')]:
# if not exists(join(javaHome, path)):
# allExist = False
# if allExist:
# options['JAVA_HOME'] = javaHome
# break
# # We could instead check individually for JAVA_BINDIR, JAVAC
# # and so on, as we do with MPI options, but we go for an
# # easier and consistent case instead: everything must be under
# # JAVA_HOME, which is the most common case for Java.
#
# if not options:
# print(red("Warning: could not detect a suitable JAVA_HOME."))
# if candidates:
# print(red("Our candidates were:\n %s" % '\n '.join(candidates)))
#
# return options
#
#
# def guessMPI():
# """Guess the system's MPI installation, return a dict with MPI keys"""
# # Returns MPI_LIBDIR, MPI_INCLUDE and MPI_BINDIR as a dictionary.
#
# options = {}
# candidates = []
#
# # First check if the system has a favorite one.
# for prefix in ['MPI_', 'MPI', 'OPENMPI_', 'OPENMPI']:
# if '%sHOME' % prefix in os.environ:
# candidates.append(os.environ['%sHOME' % prefix])
#
# # Add also all the ones related to a "mpicc" program.
# for d in os.environ.get('PATH', '').split(':'):
# if not os.path.isdir(d) or 'mpicc' not in os.listdir(d):
# continue
# mpiBin = os.path.realpath(join(d, 'mpicc'))
# if 'MPI_BINDIR' not in options:
# options['MPI_BINDIR'] = os.path.dirname(mpiBin)
# if mpiBin.endswith('/bin/mpicc'):
# mpiHome = mpiBin[:-len('/bin/mpicc')]
# candidates.append(mpiHome)
#
# # Add some extra directories that are commonly around.
# candidates += ['/usr/lib/openmpi', '/usr/lib64/mpi/gcc/openmpi']
#
# # Check in order if for any of our candidates, all related
# # directories and files exist. If they do, that'd be our best guess.
# for mpiHome in candidates:
# if (exists(join(mpiHome, 'include', 'mpi.h')) and
# 'MPI_INCLUDE' not in options):
# options['MPI_INCLUDE'] = join(mpiHome, 'include')
# if (exists(join(mpiHome, 'lib', 'libmpi.so')) and
# 'MPI_LIBDIR' not in options):
# options['MPI_LIBDIR'] = join(mpiHome, 'lib')
# if (exists(join(mpiHome, 'bin', 'mpicc')) and
# 'MPI_BINDIR' not in options):
# options['MPI_BINDIR'] = join(mpiHome, 'bin')
#
# return options
#

def getConfigPathFromConfigFile(scipionConfigFile, configFile):
"""
:param scipionConfigFile path to the config file to derive the folder name from
Expand Down
6 changes: 3 additions & 3 deletions scipion/scripts/kickoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def _addPair(self, text, title, r, lf, widget=ENTRY, traceCallback=None,
elif widget == CHECKBUTTON:
var.set(YES if value else NO)
widget = tk.Checkbutton(lf, text="", font=self.bigFont, variable=var,
onvalue=YES, offvalue=NO, bg="white")
onvalue=YES, offvalue=NO, bg=pw.Config.SCIPION_BG_COLOR)

widget.grid(row=r, column=1, sticky='news', padx=(5, 10), pady=pady)

Expand Down Expand Up @@ -438,9 +438,9 @@ def importTemplate(template, window):
workflow = createTemplateFile(template)
if workflow is not None:
try:
window.getViewWidget().info('Importing the workflow...')
window.getViewWidget().info('Importing workflow %s' % workflow)
window.project.loadProtocols(workflow)
window.getViewWidget().updateRunsGraph(True, reorganize=False)
window.getViewWidget().updateRunsGraph(True)
window.getViewWidget().cleanInfo()
except Exception as ex:
window.showError(str(ex), exception=ex)
Expand Down
Loading

0 comments on commit 7bf0cd3

Please sign in to comment.