You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One thing I don't like is how the module is organized. When I write
fromev3devimport*
I expect to be able to write d = Device(). But now, since ev3dev module (the top folder) has the ev3dev submodule (the ev3dev.py file) I have to do d = ev3dev.Device(). Normally if I wanted that, I would just import ev3dev instead.
So I think we should keep just the ev3dev.py at the top level and get rid of the ev3dev folder with __init__.py.
I'm not so sure about that - we run into namespace pollution risks - besides, once the ev3dev.Device or ev3dev.Motor is instantiated, the prefix is no longer an issue
Ah, now I understand - so just pull ev3dev.py and __init__.py up from the ev3dev folder. Does this affect things if we submit to any other repositories ? Sorry for my ignorance on this topic
I am not sure what you mean by other repositories. Something like PyPI to make the bindings installable through easy_install or pip? I think that would be fine.
When we install it, it resides somewhere in dist-packages folder (as single ev3dev.py file). I've added a setup.py in #11, you can try to install the package system-wide with sudo python setup.py install.
Re module organization and pypi: the document you referenced describes rather complex project with many files in it. Since our bindings reside in single file, I think nothing prevents us from having flat structure.
I can work with that, but I thought @rhempel wanted to have separate files for convenience classes that are not generated. Like e.g. motors.py or sensors.py that contain non-lego sensors, advanced PID control algorythms etc... Then it's nice to have them in a folder.
You can also symlink a subdirectory of the repo into your mindstorms project btw. easier than symlinking.
There's a point at which PID control and other helpers need to be managed and customized by users. For now, we have all the helper functions (except higher level motor) auto-generated and I'm basically happy with the library. @ddemidov made a good point about having the main ev3dev.py not being in a subdirectory. For now, let's move forward with what we've got, and see what shakes out.
BTW the out of the directory move broke setup.py process, which is still looking for an ev3dev package (and thus a directory). The "packages" directive should be replaced by "py_modules". But I guess that we are in a transitional state for the moment, and that such adjustments will have to be done when the situation will be stabilized.
Activity
rhempel commentedon Oct 17, 2015
I'm not so sure about that - we run into namespace pollution risks - besides, once the
ev3dev.Deviceorev3dev.Motoris instantiated, the prefix is no longer an issueddemidov commentedon Oct 17, 2015
When I care about namespace pollution, I do
And when I just want convenience, I do
I think this is standard practice for python.
rhempel commentedon Oct 17, 2015
Ah, now I understand - so just pull
ev3dev.pyand__init__.pyup from the ev3dev folder. Does this affect things if we submit to any other repositories ? Sorry for my ignorance on this topicddemidov commentedon Oct 17, 2015
I am not sure what you mean by other repositories. Something like PyPI to make the bindings installable through
easy_installorpip? I think that would be fine.rhempel commentedon Oct 17, 2015
Yes, that kind of repo - when we install from there, what does the directory structure look like?
ddemidov commentedon Oct 17, 2015
When we install it, it resides somewhere in dist-packages folder (as single
ev3dev.pyfile). I've added asetup.pyin #11, you can try to install the package system-wide withsudo python setup.py install.antonvh commentedon Oct 18, 2015
This document explains how the module should be structured (it was ok, now it isn't anymore). http://peterdowns.com/posts/first-time-with-pypi.html
If you want to use it in another project without updating pypi, you can use subtree . Then test, change, and cherry pick back into master.
git filter-branch --prune-empty --subdirectory-filter ev3dev libonlyantonvh commentedon Oct 18, 2015
The new structure also breaks autogen for me. - I pulled the latest ev3dev-lang repo in the pure-python branch.
ddemidov commentedon Oct 18, 2015
autogen should be fixed with ev3dev/ev3dev-lang@07c14ef.
Re module organization and pypi: the document you referenced describes rather complex project with many files in it. Since our bindings reside in single file, I think nothing prevents us from having flat structure.
ddemidov commentedon Oct 18, 2015
Here is some discussion on module-vs-single-file: http://programmers.stackexchange.com/questions/243044/single-python-file-distribution-module-or-package
antonvh commentedon Oct 18, 2015
I can work with that, but I thought @rhempel wanted to have separate files for convenience classes that are not generated. Like e.g. motors.py or sensors.py that contain non-lego sensors, advanced PID control algorythms etc... Then it's nice to have them in a folder.
You can also symlink a subdirectory of the repo into your mindstorms project btw. easier than symlinking.
rhempel commentedon Oct 18, 2015
There's a point at which PID control and other helpers need to be managed and customized by users. For now, we have all the helper functions (except higher level motor) auto-generated and I'm basically happy with the library. @ddemidov made a good point about having the main
ev3dev.pynot being in a subdirectory. For now, let's move forward with what we've got, and see what shakes out.ddemidov commentedon Oct 18, 2015
resolved by #11
antonvh commentedon Oct 20, 2015
Can we please move back to the directory? It is more future-proof. @ericpascual also made a compelling namespace argument.
ddemidov commentedon Oct 20, 2015
We can always do this if we outgrow single file.
ericpascual commentedon Oct 20, 2015
BTW the out of the directory move broke setup.py process, which is still looking for an ev3dev package (and thus a directory). The "packages" directive should be replaced by "py_modules". But I guess that we are in a transitional state for the moment, and that such adjustments will have to be done when the situation will be stabilized.
ddemidov commentedon Oct 20, 2015
Thanks, I'll make a PR with the fix. Strange, but
setup.py installworkedfor me as is.