Skip to content

Commit

Permalink
Fix for plugins (#1282)
Browse files Browse the repository at this point in the history
* update for importlib

* correct spec function

* give full path for importlib

* fix dependencies

* update docs
  • Loading branch information
zm711 authored Jun 5, 2024
1 parent 514c629 commit a1a8776
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Phy provides two GUIs:


## What's new

* [5 June 2024] phy 2.0 beta 6, bug fixes, install work, fixing some deprecations
* [7 Sep 2021] Release of phy 2.0 beta 5, with some install and bug fixes
* [7 Feb 2020] Release of phy 2.0 beta 1, with many new views, new features, various improvements and bug fixes...

Expand All @@ -44,7 +44,7 @@ Run the following commands in a terminal:
1. Create a new conda environment with the conda dependencies:

```
conda create -n phy2 -y cython dask h5py joblib matplotlib numpy pillow pip pyopengl pyqt pyqtwebengine pytest python qtconsole requests responses scikit-learn scipy traitlets
conda create -n phy2 -y python=3.11 cython dask h5py joblib matplotlib numpy pillow pip pyopengl pyqt pyqtwebengine pytest python qtconsole requests responses scikit-learn scipy traitlets
```
2. Activate the new conda environment with `conda activate phy2`
Expand All @@ -60,6 +60,9 @@ cd path/to/my/spikesorting/output
phy template-gui params.py
```

6. If there are problems with this method we also have an `environment.yml` file which allows for
automatic install of the necessary packages. Give that a try.


### Dealing with the error `ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidget`

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
- defaults
dependencies:
- python
- python=3.11
- pip
- git
- numpy
Expand Down
2 changes: 1 addition & 1 deletion phy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

__author__ = 'Cyrille Rossant'
__email__ = 'cyrille.rossant at gmail.com'
__version__ = '2.0b5'
__version__ = '2.0b6'
__version_git__ = __version__ + _git_version()


Expand Down
13 changes: 7 additions & 6 deletions phy/utils/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import importlib
import logging
import os
import sys
from pathlib import Path

from phylib.utils._misc import _fullname
Expand Down Expand Up @@ -97,20 +98,20 @@ def discover_plugins(dirs):
"""
# Scan all subdirectories recursively.
for path in _iter_plugin_files(dirs):
subdir = path.parent
modname = path.stem
if modname in ('phy_config', 'phycontrib_loader'):
continue
file, path, descr = importlib.util.find_spec(modname, [subdir])
if file:
spec = importlib.util.spec_from_file_location(modname, path)
if spec is not None:
# Loading the module registers the plugin in
# IPluginRegistry.
try:
mod = importlib.load_module(modname, file, path, descr) # noqa
mod = importlib.util.module_from_spec(spec) # noqa
sys.modules[modname] = mod
spec.loader.exec_module(mod)
except Exception as e: # pragma: no cover
logger.exception(e)
finally:
file.close()

return IPluginRegistry.plugins


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dask
cython
pillow
colorcet
pyopengl
pyopengl==3.1.6
requests
qtconsole
tqdm
Expand Down

0 comments on commit a1a8776

Please sign in to comment.