Merge lp://qastaging/~ted/snapcraft/ros-catkin-plugin into lp://qastaging/~snappy-dev/snapcraft/core

Proposed by Sergio Schvezov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 208
Merged at revision: 243
Proposed branch: lp://qastaging/~ted/snapcraft/ros-catkin-plugin
Merge into: lp://qastaging/~snappy-dev/snapcraft/core
Diff against target: 845 lines (+726/-0)
16 files modified
debian/control (+2/-0)
examples/ros/icon.svg (+1/-0)
examples/ros/snapcraft.yaml (+27/-0)
examples/ros/src/CMakeLists.txt (+47/-0)
examples/ros/src/beginner_tutorials/CMakeLists.txt (+39/-0)
examples/ros/src/beginner_tutorials/msg/Num.msg (+1/-0)
examples/ros/src/beginner_tutorials/package.xml (+42/-0)
examples/ros/src/beginner_tutorials/src/add_two_ints_client.cpp (+30/-0)
examples/ros/src/beginner_tutorials/src/add_two_ints_server.cpp (+23/-0)
examples/ros/src/beginner_tutorials/src/listener.cpp (+60/-0)
examples/ros/src/beginner_tutorials/src/talker.cpp (+87/-0)
examples/ros/src/beginner_tutorials/srv/AddTwoInts.srv (+4/-0)
snapcraft/meta.py (+3/-0)
snapcraft/plugins/catkin.py (+270/-0)
snapcraft/plugins/roscore.py (+83/-0)
snapcraft/yaml.py (+7/-0)
To merge this branch: bzr merge lp://qastaging/~ted/snapcraft/ros-catkin-plugin
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
John Lenton (community) Needs Fixing
Review via email: mp+273048@code.qastaging.launchpad.net

Commit message

Adding a catkin plugin

To post a comment you must log in.
184. By Ted Gould

Look elsewhere for deps

Revision history for this message
John Lenton (chipaca) wrote :

inline

review: Needs Fixing
Revision history for this message
John Lenton (chipaca) :
185. By Ted Gould

Switching to isolated under recommentation from the Erle folks

186. By Ted Gould

Build our own dependency system to ensure the packages can build correctly.

Revision history for this message
Leo Arias (elopio) wrote :

It's probably not a good idea to use config={} in the arguments of the methods because {} is mutable and it can cause some unexpected behaviors. See more info here: http://effbot.org/zone/default-values.htm
As the article suggest, it's better to use config=None, and then if config is None: config = {}.

Also, your python files are not passing the mccabe test:

./snapcraft/plugins/catkin.py:73:1: C901 'CatkinPlugin.find_package_deps' is too complex (10)
./snapcraft/plugins/catkin.py:128:1: C901 'CatkinPlugin.build' is too complex (13)

You should extract methods for the loops. The more the merrier.

187. By Ted Gould

Should use the default rosversion

188. By Sergio Schvezov

Handle not having stage-packages key

189. By Ted Gould

Fix the binary location to match make_isolated

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Hey good work on getting everything to this point. Seems like a really useful plugin. I do have some comments though.

I've been giving this a bit more of a look and I don't think we want config={} at all, parts should not have knowledge of config, it is what keeps them independent. We also don't want to have it write a services entry, that should be in the users control.

Last but not least, as elopio mentions, the code needs to be split out a bit.

review: Needs Fixing
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Also merge lp:~sergiusens/snapcraft/catkin which adds the roscore binaries

Revision history for this message
Ted Gould (ted) wrote :

On Fri, 2015-10-02 at 22:39 +0000, Sergio Schvezov wrote:

> I've been giving this a bit more of a look and I don't think we want
> config={} at all, parts should not have knowledge of config, it is
> what keeps them independent. We also don't want to have it write a
> services entry, that should be in the users control.

So, I actually think the opposite, we need it more or an actual step for
it.

I think that we do want the plugins to provide smarter generation of the
packages.yaml file, we can argue whether they should do services, but I
think we definitely want them to do frameworks and add capabilities on
individual binaries/services/etc. The case I'd mention is the QML
plugin. For QML to be useful it needs the Mir Framework and every binary
needs to have the mir_client capability. I don't think that we should
require the developer to understand those, just understand that he/she
needs to pull in QML. The QML plugin should add those onto the packages
file where it can.

Perhaps a solution for the services would be to provide a way to insert
a commented block into the packages.yaml file. So the plugin could see
if there was a ROS Master and if not throw some comments in saying "hey,
you might want these keys."

While for ROS I think this isn't as important, but as we start adding
things to the wiki you'd want to add postgres to your snap, not
configure postgres as a server in your snap. It seems that there needs
to be some way to have the service come along with the plugin.

190. By Ted Gould

Lint fixes

191. By Ted Gould

Restructuring code to pull XML parsing out of the file handling

192. By Ted Gould

Pulling the dependency resolution into its own function and using set logic to simplify

193. By Ted Gould

Making more sets instead of lists

194. By Ted Gould

Updates from Sergio

Revision history for this message
Ted Gould (ted) wrote :

So I think the complexity is taken care off and the other little comments.

I'm going to leave the *attr() ones because they match the other code, if we're going to change those I'm happy with that, but it should be one branch to change them all.

Wait for Sergio's comment/discussion on the config variable and how we want to handle that.

Revision history for this message
Ted Gould (ted) wrote :

Oh, also note, this push breaks the Erle Spider codebase as the switch to sets exposes some more dependency declaration that is needed in their codebase.

195. By Ted Gould

Change formatting of string to make it easier to read.

196. By Ted Gould

Update to trunk and roscore updates

197. By Ted Gould

Grab changes from roscore branch

198. By Ted Gould

Get schemas and other changes needed by the new plugins system

199. By Ted Gould

Drop 'config' parameters

200. By Ted Gould

Revert plugin.py changes

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

I've done a first pass, the code looks really good, just a couple nits here and there.

One thing we haven't been doing and I started addressing was that all our methods our public and I'd make them private (prefix the method with _), this becomes more important now that we inherit from plugins instead of 'requiring' them.

Revision history for this message
Ted Gould (ted) wrote :

On Thu, 2015-10-15 at 23:44 +0000, Sergio Schvezov wrote:

> One thing we haven't been doing and I started addressing was that all our methods our public and I'd make them private (prefix the method with _), this becomes more important now that we inherit from plugins instead of 'requiring' them.

Fixed.

> > +binaries:
> > + listener:
> > + exec: opt/ros/indigo/beginner_tutorials/listener
> > + talker:
> > + exec: opt/ros/indigo/beginner_tutorials/talker
> > +
> > +parts:
> > + roscore:
> > + plugin: roscore
> > + catkin-tutorials:
> > + plugin: catkin
> > + source: .
> > + catkin-packages:
> > + - beginner_tutorials
> > +
> > +services:
>
> just a minor thing, but maybe put this upstairs (above) together with binaries

Fixed

> > + rosmaster:
> > + start: bin/roscore-rosmaster-service
> > + description: ROS Master Service
> > + ports:
>
> this can be dropped, I think it is being killed and nothing uses it so it can just go away to not confuse people (ports and everything under it)

Fixed, we should probably mark it deprecated in the schema then, no?

> > + def __init__(self, name, options):
> > + super().__init__(name, options)
> > + self.rosversion = options.rosversion
>
> the base class already saves options as self.options from way back and I guess we never noticed that, but maybe all these 'options' attribs don't need specific assigns.

Fixed.

> > + except lxml.etree.ParseError:
> > + logger.warning("Unable to read packages.xml file for '" + pkg + "'")
>
> use .format instead of + or maybe ('string %r' % pkg)

Fixed.

> > + return
>
> what are the consequences of this, even if handled internally maybe raising a RuntimeError is good here and logging from whoever calls this.

My thoughts here is that we can let the developer decide, if they care
that we can't parse it they can fix the file. If they don't care and
they just want to add the dependencies via stage-packages manually we
should allow that too. I kinda see packages.xml as nicety instead of a
requirement for a build.

> > +
> > + for deptype in ['buildtool_depend', 'build_depend', 'run_depend']:
>
> use () instead of [] here.

Fixed. But I don't understand why that would be better, it seems like a
list would always be less memory?

201. By Ted Gould

Making private functions private

202. By Ted Gould

Make directories us os.path.join()

203. By Ted Gould

Move services and drop port info

204. By Ted Gould

Don't cache the rosversion

205. By Ted Gould

Change string formatting

206. By Ted Gould

Set instead of a list

207. By Ted Gould

PEP8 is lame

Revision history for this message
Sergio Schvezov (sergiusens) :
208. By Ted Gould

Merge in trunk

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Great work! Great contribution!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: