Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix external plugins import #3150

Closed
Nodd opened this issue May 3, 2016 · 10 comments · Fixed by #3210
Closed

Fix external plugins import #3150

Nodd opened this issue May 3, 2016 · 10 comments · Fixed by #3210

Comments

@Nodd
Copy link
Contributor

Nodd commented May 3, 2016

Description

I had to change the package name for autopep8, because there was a name clash with the autopep8 package that's used in autopep8 plugin.
In theory spyder plugins should be loaded as spyplugins.ui.pluginame, but it seems that somehow pluginame is added to sys.modules too.

Version and main components

  • Spyder Version: 3.0.0dev
  • Python Version: 3.5.1
  • Qt Versions: 5.5.1, PyQt5 5.5.1 on Linux

Dependencies

pyflakes >=0.6.0:  1.1.0 (OK)
pep8 >=0.6      :  1.7.0 (OK)
pygments >=1.6  :  2.1.3 (OK)
qtconsole >=4.0 :  4.2.1 (OK)
nbconvert >=4.0 :  4.2.0 (OK)
pandas >=0.13.1 :  0.18.0 (OK)
numpy >=1.7     :  1.11.0 (OK)
sphinx >=0.6.6  :  1.4.1 (OK)
rope >=0.9.4    :  0.9.4-1 (OK)
jedi >=0.8.1    :  0.9.0 (OK)
psutil >=0.3    :  4.1.0 (OK)
matplotlib >=1.0:  1.5.1 (OK)
sympy >=0.7.3   :  None (NOK)
pylint >=0.25   :  1.5.5 (OK)

@goanpeca
Copy link
Member

goanpeca commented May 3, 2016

@Nodd can we consider moving away from namespace packages?, I know it was something we agreed on before but it seems they are falling out of favour in the python community and other libraries have moved away from them.

Like flask, i.e. http://flask.pocoo.org/docs/0.10/extensions/

@Nodd
Copy link
Contributor Author

Nodd commented May 3, 2016

Well, it's better to do it now rather than after 3.0 is out. What is the problem with namespace packages exactly?

If I understand correctly, extensions would work by searching in sys.path (and ~/.spyder/userplugins/) for every module starting with spyderplugin_ (or similar) and import it ?
Edit: I don't remember where we initially discussed about namespace plugins. Do you have a link?

@goanpeca
Copy link
Member

goanpeca commented May 3, 2016

Apparently they created more problems than they solve, conda does not necessarily play well, and some of the conda devs say that we should stay away from them.

If I understand correctly, extensions would work by searching in sys.path (and ~/.spyder/userplugins/) for every module starting with spyderplugin_ (or similar) and import it ?

Yes, that would be the easy fix and avoid name collisions once and for all

I dont remember about the link either

@goanpeca
Copy link
Member

goanpeca commented May 3, 2016

Well the names could be

spyder-profiler, spyder-line-profiler, spyder-memory-profiler, spyder-conda-manager, spyder-git, etc

and the imports would be

spyder_profiler

@ccordoba12
Copy link
Member

I don't think namespace packages are much of a problem in our case, unless we make one package depend on another. That's were problems could arise.

@goanpeca, what do you propose as an alternative?

@ccordoba12
Copy link
Member

I see, so we can follow the Flask model. Changes to do it don't seem too hard to implement for me :-)

@goanpeca
Copy link
Member

@ccordoba12, yes we should follow the flask model. No, the changes are not so big.

@ccordoba12
Copy link
Member

@goanpeca, could you open a PR with those changes?

I'd do it myself but I'm really swamped with the move to Qt 5.6 (now I'm in charge of the Windows conda packages too :-).

@goanpeca
Copy link
Member

👍

@Nodd
Copy link
Contributor Author

Nodd commented Jun 7, 2016

How do we differentiate between UI and IO plugins ? Using a subdirectory is not very practical without a namespace package (both for the plugin developer and the implementation in spyder).
There are different options:

  1. .ini file
  2. spyder_ui_ and spyder_io_ as prefix instead of spyder_
  3. Different parent classes, but you need to import the plugins to know their type, the implementation would be ugly

Option 1 can be interesting for building a plugin manager because there could be other information here. They could also be stored as attributes in the modules (similar to __version__).

@ccordoba12 ccordoba12 modified the milestones: v3.0rc1, v3.0beta4 Jun 9, 2016
@ccordoba12 ccordoba12 changed the title External plugin import Fix external plugins import Jun 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants