Commit 6f6fccd7 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'bf/assets' into 'master'

RF: Move assets into fsleyes package dir

See merge request fsl/fsleyes/fsleyes!244
parents 112982c4 36f522d3
......@@ -9,6 +9,20 @@ This document contains the ``fsleyes`` release history in reverse
chronological order.
1.0.3 (Friday 23rd April 2021)
------------------------------
Fixed
^^^^^
* Fixed an issue with the management of built-in asset files (e.g. icons,
colour maps, etc). Asset files are now located inside the ``fsleyes``
package directory.
1.0.2 (Thursday 22nd April 2021)
--------------------------------
......
......@@ -5,21 +5,17 @@ include requirements.txt
include requirements-dev.txt
include requirements-extra.txt
include requirements-notebook.txt
recursive-exclude fsleyes/tests *
recursive-include userdoc *
recursive-include apidoc *
recursive-exclude userdoc/html *
recursive-exclude apidoc/html *
recursive-include assets *
recursive-exclude assets/icons/splash/sources *
recursive-exclude assets/icons/sources *
recursive-exclude assets/icons/app_icon *
recursive-include fsleyes/assets *
# these directories are temporarily
# created for built distributions
recursive-include fsleyes/userdoc *
recursive-include fsleyes/assets *
# Source (e.g. .xcf) files for some image files
recursive-exclude fsleyes/assets/icons/splash/sources *
recursive-exclude fsleyes/assets/icons/sources *
recursive-exclude fsleyes/assets/icons/app_icon *
# Tests and docs are too big for pypi
recursive-exclude fsleyes/tests *
recursive-exclude userdoc *
recursive-exclude apidoc *
global-exclude *.py[cod]
global-exclude __pycache__
global-exclude *.xcf
......@@ -223,9 +223,9 @@ module).
"""
assetDir = op.join(op.dirname(__file__), '..')
"""Base directory which contains all *FSLeyes* assets/resources (e.g. icon
files). This is set in the :func:`initialise` function.
assetDir = op.abspath(op.join(op.dirname(__file__), 'assets'))
"""Directory which contains all *FSLeyes* assets/resources (e.g. icon
files).
"""
......@@ -233,23 +233,13 @@ def canWriteToAssetDir():
"""Returns ``True`` if the user can write to the FSLeyes asset directory,
``False`` otherwise.
"""
return os.access(op.join(assetDir, 'assets'), os.W_OK | os.X_OK)
return os.access(assetDir, os.W_OK | os.X_OK)
def initialise():
"""Called when `FSLeyes`` is started as a standalone application. This
function *must* be called before most other things in *FSLeyes* are used.
Does a few initialisation steps::
- Initialises the :mod:`fsl.utils.settings` module, for persistent
storage of application settings.
- Sets the :data:`assetDir` attribute.
"""
global assetDir
import fsleyes.plugins as plugins
# implement various hacks and workarounds
......@@ -269,25 +259,6 @@ def initialise():
import fsleyes.frame # noqa
import fsleyes.actions.frameactions # noqa
fsleyesDir = op.dirname(__file__)
assetDir = None
options = []
# The assets directory is either inside, or
# alongside, the FSLeyes package directory,
# depending on whether we are running from
# a code install, or from a source distribution.
options = [op.join(fsleyesDir, '..'), fsleyesDir]
for opt in options:
if op.exists(op.join(opt, 'assets')):
assetDir = op.abspath(opt)
break
if assetDir is None:
raise RuntimeError('Could not find FSLeyes asset directory! '
'Searched: {}'.format(options))
def _hacksAndWorkarounds():
"""Called by :func:`initialise`. Implements hacks and workarounds for
......
......@@ -131,16 +131,9 @@ def toggleOverlayVisibility(self, *args, **kwargs):
def openHelp(self, *args, **kwargs):
"""Opens FSLeyes help in a web browser. """
url = op.join(fsleyes.assetDir, 'userdoc', 'index.html')
import fsleyes_widgets.utils.webpage as webpage
# Show locally stored help files
if op.exists(url):
webpage.openFile(url)
else:
url = 'https://open.win.ox.ac.uk/pages/fsl/fsleyes/fsleyes/userdoc/'
webpage.openPage(url)
url = 'https://open.win.ox.ac.uk/pages/fsl/fsleyes/fsleyes/userdoc/'
webpage.openPage(url)
def setFSLDIR(self, *args, **kwargs):
......
......@@ -579,7 +579,7 @@ class NotebookServer(threading.Thread):
# directory to a temporary location that
# will be deleted on exit.
cfgdir = op.join(tempfile.mkdtemp(prefix='fsleyes-jupyter'), 'config')
shutil.copytree(op.join(fsleyes.assetDir, 'assets', 'jupyter'), cfgdir)
shutil.copytree(op.join(fsleyes.assetDir, 'jupyter'), cfgdir)
log.debug('Copied notebook configuration to %s', cfgdir)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment