Skip to content

Transition from boostc to pure-python #37

Closed

Description

@ddemidov

I think we are now feature complete w.r.t. boostc version (pinging @ensonic). We can push this to PyPI and advertise on ev3dev.org.

Now, python-ev3dev package name on PyPI is taken by boostc version. The latest version published there was 0.2.2. I suggest we tag the pure-python bindings with something like 0.3 and just keep pushing to the same package on PyPI. This way users may still download older (boosts-based) versions. And I am going to put deprecation warning with a link to this repo in boostc version README.

Activity

  1. ddemidov commented on Oct 31, 2015

    @ddemidov
    MemberAuthor

    We also may want to wait for @EricPobot's changes before version tagging. I've seen some nice work done already in his fork.

  2. ddemidov commented on Oct 31, 2015

    @ddemidov
    MemberAuthor

    Also see #15

  3. rhempel commented on Oct 31, 2015

    @rhempel
    Member

    @ddemidov, I will follow your lead on this - the Python packaging is something you are much more familiar with.
    I think I can start making this into a Debian package.

  4. ddemidov commented on Oct 31, 2015

    @ddemidov
    MemberAuthor

    @ensonic did some work on debian package for boosc version here. Can we use it?

  5. rhempel commented on Oct 31, 2015

    @rhempel
    Member

    Yes, but now we need to add python-pil, beep, aplay, and espeak to the dependencies, fortunately we're not making changes to upstream sources so there's no patches necessary.

  6. dlech commented on Oct 31, 2015

    @dlech
    Member

    debhelper should take care of all of the python dependencies automatically. That is what ${python:Depends} is for in the debian/control file.

  7. ddemidov commented on Oct 31, 2015

    @ddemidov
    MemberAuthor

    The 0.4.0 version of the bindings is uploaded to pypi: https://pypi.python.org/pypi?:action=display&name=python-ev3dev&version=0.4.0.

    So the library may now be installed with easy_install -U python-ev3dev. We can put this into README, or we can wait until debian package is ready and use apt-get install python-ev3dev.

  8. ericpascual commented on Nov 1, 2015

    @ericpascual

    @ddemidov I'm far from home currently, and thus have no access to my machine. However as you could notice, I've pushed the latest version of my fork. Since I'm not sure to be able to isssue a pull request very soon, feel free to pick what is ok for you already.

    One of the main points of my version (demoed in the small motors.py demo) is that the user of the lib does not make an import ev3dev, but a from ev3dev import <my_platform>, which in turn includes an from ev3dev import *, thus exposing transparently the base layer in addition to the extensions or overrides specific to that platform.

    WRT autogen I've tried to backport my Python code to the templates, but have not tested if they reallly work. BTW I've also done minor fixes to some of the templates so that the code is more PEP compliant WRTcode formatting (PyCharm was underlining to much of it for code issues of this nature ;).

  9. EricPobot commented on Nov 3, 2015

    @EricPobot
    Contributor

    I'm happy my work has been retained :)
    However, I could notice that only a part of the EV3 Leds stuff has been kept, and that the feature I've added to address the LEDs by side is not here. The public version does not allow to light the left one in red and the right one in green for instance, which my version can do.
    Since this is a specificity of the EV3, it can be placed outside the autogen area.

  10. ddemidov commented on Nov 3, 2015

    @ddemidov
    MemberAuthor

    I've seen the led-grouping code in your fork, and I agree it could be useful. The reason I did not pull it yet is that I could not come up with a way to do this through spec.json/autogen. Also, I am not sure mix_all is a good name for the function; may be mix_sides would be better?

  11. ddemidov commented on Nov 3, 2015

    @ddemidov
    MemberAuthor

    I think we can introduce groups like left and right into spec.json. The idea is that each group has closely located leds, and each group has same set of colors. For example, ev3 has left and right groups of green/red leds, PiStorms has two groups of Red/Green/Blue leds. Then we could say 'set this group to this color', where color is a tuple of percentages. We could also add some predefined mixes/colors into spec.json as well. Then Leds.set(LEFT, AMBER) would work on ev3. May be can also add scale parameter to dim the color. Or maybe [c * 0.5 for c in AMBER] would be enough.

  12. EricPobot commented on Nov 3, 2015

    @EricPobot
    Contributor

    Just to be sure I have understood correctly the autogen stuff, its purpose is to generate the bindings for all the supported languages. Is this right ?

    The idea is brilliant, but your previous comment makes me wonder if it is not starting to show to limitations, by adding a layer of additional burdens caused by the tool and not by the problems it is expected to solve.

    As you could see, the involved code is pretty basic and straightforward, and IMHO writing it is simpler than finding a way to encode its logic into the autogen specs.

    In addition I find that the Python code which is produced is sometimes not really Pythonic. For instance, you could notice that I've rewritten the EV3 buttons definitions using named tuples, which is a bit more readable than embedded dictionaries (even if I agree that at the end of the day objects are dictionary in Python)

    Said differently, is the autogen strategy part of the solution, or part of the problem ?

  13. rhempel commented on Nov 3, 2015

    @rhempel
    Member

    Well, there are always going to be stylistic differences :-) autogen will shine when we do more bindings, and although each individual class for motors, or LEDs may be simple, altogether there is 1.8K of code - what happens when we add a feature or attribute and need to update 6 bindings?

    I will always suggest that we at least attempt to describe things like LED groups in the spec.json file, and if it does not work then we manually write some of the binding.

    I will also always suggest that we take a break from writing the binding and actually attempt to program a robot so that we understand the actual problems our users will face.

    As more advanced programmers, we tend to overthink the "right" solution and the result is that the binding never gets released.

    At this point, it's not autogen or spec.json that is holding us back, it's adding better button and LED and screen support and changing the API for users. We will soon be at a good release point, I am still waiting for feedback from @ensonic to approve the Python API we have now so we can issue the 0.5.0 tag.

  14. ddemidov commented on Nov 4, 2015

    @ddemidov
    MemberAuthor

    @EricPobot, I don't know why you keep saying the generated code is not pythonic. An autogen template is just a program that generates code, so if you don't like the code that is generated, you should blame the program author :). Hint: these blames usually go better with pull requests.

    I agree with @rhempel that autogen is crucial for keeping sanity of all involved in developing all the language bindings (not only python). The README of the main repo says: 'Each binding complies with our universal language binding specification, which also serves as high-level documentation for our wrappers'. Keeping that true is much easier with autogen. Before the system was introduced, when @dlech pushed new kernel with updated drivers (that means: changed attributes), each binding developer had to update his bindings manually. That usually meant that some languages did not work for several weeks after kernel release. With autogen you just need to rerun the script (usually) to bring all the bindings up to date.

  15. ericpascual commented on Nov 4, 2015

    @ericpascual

    First of all, apologizes if I've offended anybody. It was not my intent. I'm not an English speaker, and although I do my best maybe the way I wrote some messages could be misinterpreted :/

    I fully understand the motivations for using the autogen mechanism to keep all the bindings up to date with the minimum of work. But is the balance really positive when considering the extra work needed to maintain the mechanism and to code the templates ? I've no answer to this question, just wondering.

    @ddemidov The code style I was referring to is for instance the one used to declare the buttons in the EV3 specific module. This specific case does not really hurt, since it deals with private mechanisms and data, but let's take it as an example. Using dictionaries prevents IDEs (including Vim with the Python plugins) to introspect and thus provide hints to the developer. My opinion is that we should try to use as much as possible identifiers (properties,...) to provide access to data and methods.

    Ditto for the button handlers. They are currently pre-declared as None attributes. The problem with this kind of declaration is that it gives no hint about the callback signature which must be respected. They should have been declared as empty callbacks with the right signature instead.

    @rhempel WRT to examples, it happens that this is exactly the way I work, and I have a robot example which is the rewrite of a demo I use for scientific fairs, interventions in schools,... initially written with LeJOS, then ported to EV3 graphical tool, and now in ev3dev. I can of course give it to contribute to the examples folder mentioned previously (and for which a start point exists in my fork).

  16. ddemidov commented on Nov 4, 2015

    @ddemidov
    MemberAuthor

    No offence taken :). I was just saying that you can make autogen to create code however you like it. I believe the issues you are talking about are orthogonal to the tool we use to create code, be it manual labor or autogen scripts. I think this xkcd comic is a good illustration of our lines of thought:

    I want to think that autogen would let us stay on the top half :).

    re Button implementation: I am not sure what are you trying to say. The only dictionary I see is this, and you had implemented it in the same way. But feel free to propose a PR, its always easier to reason about code when its in front of ones eyes. Having empty callbacks might be a good idea.

  17. rhempel commented on Nov 4, 2015

    @rhempel
    Member

    I'm all for better introspection - and changing the internal implementation of button dicts will not change the API.

    I agree with @ddemidov - if you have an implementation that accomplishes the introspection that you like, please issue a PR.

    No offense taken at all - we're professionals :-)

  18. ericpascual commented on Nov 4, 2015

    @ericpascual

    @ddemidov You're right WRT buttons dict. I didn't change it because its content is generated by the autogen mechanism, and I'm not (yet) comfortable with it to design something else.

    However as I wrote, this was just taken as an example and there is no necessity to modify it since it's internal stuff anyway.

    I have just introduced a simpler expression of the buttons specs by using named tuples (ButtonDefinition) instead of an inner dict, but you didn't picked it (mybe I did it after you extracted my code). This was supposed to make other platforms implementors' life a bit simpler, but it is a detail.

    I'll try to find some time ASAP to install the whole tool chain and educate myself to autogen et al. in order to be able to issue PR if useful.

    PS: I knew the xkcd comic and I could see it becoming a reality so many times that I tend to be a bit chilly when it comes to code generation tools ;) I cross fingers for us to stay on the upper scenario.

  19. rhempel commented on Nov 4, 2015

    @rhempel
    Member

    Your other option to communicate changes is to update the core.py or ev3.py generated code manually - indicate why you'd like the change, and then we can update the autogen templates - just be clear that you are wanting the autogen template changed :-)

  20. EricPobot commented on Nov 4, 2015

    @EricPobot
    Contributor

    Sounds fine for me.

    Anyway, I'll invest some time to learn how the templates work and be able to modify them directly. At least for my curiosity’s sake ;)

  21. rhempel commented on Nov 6, 2015

    @rhempel
    Member

    Are we at a point where this issue can be closed?

  22. EricPobot commented on Nov 6, 2015

    @EricPobot
    Contributor

    I think we can, since it was more a discussion than an issue anyway.

    However this kind discussion has chances to exist again (I've another concern in mind, related to code generation) but issues are not appropriate for this. How could we proceed ?

  23. rhempel commented on Nov 6, 2015

    @rhempel
    Member

    OK, I will close this issue. WRT to other issues, please consider using a new public issue (unless there is a private matter you wish to discuss) so that we can have open dialog, and we have a public record of how we arrived at our decisions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions