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

common module causes problems #98

Open
mivade opened this issue Feb 15, 2017 · 2 comments
Open

common module causes problems #98

mivade opened this issue Feb 15, 2017 · 2 comments

Comments

@mivade
Copy link
Contributor

mivade commented Feb 15, 2017

According to the README, there is only one requirement beyond Python, namely Kivy. However, the smile.common module is imported all over the place for no good reason and just ends up polluting the namespace in a lot of the examples. Furthermore, because it imports everything, it pulls in a lot of "optional" requirements and forces them to be installed before being able to run any of the examples.

A temporary workaround is to include a requirements.txt file and make note that the user should pip install -r requirements.txt prior to installation of SMILE (I am working on this as I am starting to add some proper unit testing). A better solution is to eliminate the smile.common module altogether and only import things as needed.

@psederberg
Copy link
Contributor

I completely agree with the pollution of namespace from smile.common. This solution was adopted as a compromise between ease of use for people just starting and more experienced programmers. Note that it used to be that importing smile, itself, populated the entire namespace and we switched to smile.common specifically so that should you choose not to pollute the namespace you don't have to do so.

That said, it's still the case that simply importing the visual states brings in some features you may not need at all and it is on the docket to split out these states into more of a hierarchy so users can pick and choose what gets imported.

Our hope, too, is that we turn smile into a lightweight app that includes all of its dependencies and you simply use it to run your experiment. This will make deployment on OSX and Windows much easier and is likely a requirement for running apps on Android and iOS, which we've been working on making much easier.

With regard to the requirements.txt, that should definitely be in there, but is it really the case that importing smile.common causes an import of a library other than kivy? If so, please let us know and we'll make sure to pull the offending item out of common and/or add it to the requirements.txt.

Finally, thank you for beginning work on some unit tests. I'm happy to discuss what you are doing if you'd like, so we can coordinate our efforts, either in a different offline thread or over Skype (or other video conferencing).

@mivade
Copy link
Contributor Author

mivade commented Feb 15, 2017

Pygame is a pretty hard requirement for Kivy (for some reason pip install kivy doesn't pull in this requirement automatically). For reference, I'm trying to get this working in a fresh miniconda environment on macOS.

Trying to import from smile.mouse (by running the freekey_test.py example) gives this traceback:

Traceback (most recent call last):
   File "freekey_test.py", line 11, in <module>
     from smile.common import *
   File "/Users/depalati/src/smile/smile/common.py", line 33, in <module>
     from smile.mouse import (
   File "/Users/depalati/src/smile/smile/mouse.py", line 22, in <module>
     from smile.video import VisualState
   File "/Users/depalati/src/smile/smile/video.py", line 1658, in <module>
     exec("import %s" % modname)
   File "<string>", line 1, in <module>
   File "/Users/depalati/miniconda3/envs/smile2/lib/python3.6/site-packages/kivy/uix/codeinput.py", line 37, in <module>
     from pygments import highlight
 ModuleNotFoundError: No module named 'pygments'

After pip install pygments, smile.video wants docutils:

Traceback (most recent call last):
   File "freekey_test.py", line 11, in <module>
     from smile.common import *
   File "/Users/depalati/src/smile/smile/common.py", line 33, in <module>
     from smile.mouse import (
   File "/Users/depalati/src/smile/smile/mouse.py", line 22, in <module>
     from smile.video import VisualState
   File "/Users/depalati/src/smile/smile/video.py", line 2879, in <module>
     import kivy.uix.rst
   File "/Users/depalati/miniconda3/envs/smile2/lib/python3.6/site-packages/kivy/uix/rst.py", line 76, in <module>
     from docutils.parsers import rst
 ModuleNotFoundError: No module named 'docutils'

After pip install docutils, I get another unrelated error (at least on Python 3) that I will fix, but this seems to be the end of missing requirements.

I will follow up with you via email to discuss what we would like to do with SMILE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants