Creating an addon results in errors

I'm attempting to use the Docker container to set up a development environment for a theme add-on. Unfortunately, I'm running into some problems.

This is my buildout file:

[buildout]
extends = buildout.cfg
extensions = mr.developer
auto-checkout =
    collective.saml2
    mytheme

sources-dir = /plone/instance/mytheme/src

eggs =
    collective.saml2
    mytheme

[sources]
collective.saml2 = git https://github.com/collective/collective.saml2.git
mytheme = fs /plone/instance/mytheme/src

[versions]

This is the script that invokes mr.bob:

#!/bin/bash -xe


OLD_CWD=$(pwd)

gosu plone mkdir /plone/instance/mytheme
gosu plone git init .

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"


mrbob bobtemplates.plone:addon -n -O /plone/instance/mytheme -c ~/.mrbob

echo "***MR BOB INITIAL ADD ON CREATION COMPLETED***"

mrbob bobtemplates.plone:theme_barceloneta -n -c ~/.mrbob

chown -R plone /plone/instance/mytheme

The problem is that when I run buildout, I keep getting the error Directory name for existing package 'mytheme' differs. Expected '/plone/instance/mytheme/src'

I've tried different permutations of invoking buildout and mr.bob but none of them seem to get me past that error. What am I doing wrong?

I managed to get past one of the errors by changing my buildout file to add directories to the "develop" buildout item. Unfortunately, now I'm getting the error No such file or directory: /plone/addon/theme/mytheme/src/setup.py. The setup file is in /plone/addon/theme/mytheme. How do I make mr.developer look for that file in the right place?

My buildout configuration now looks like this (I moved the addon's path too):

[buildout]
extends = buildout.cfg
extensions = mr.developer
auto-checkout =
    collective.saml2
    mytheme

sources-dir = /plone/addon

eggs =
    collective.saml2
    mytheme

develop =
    /plone/addon/mytheme
    /plone/addon/mytheme/src

[sources]
collective.saml2 = git https://github.com/collective/collective.saml2.git
mytheme = fs mytheme full-path=/plone/addon/mytheme

[versions]

I would remove mytheme these from sources and remove the line in develop
that includes src.

Wouldn't that remove the addon that I'm trying to build, though? I've already confirmed that the buildout works without attempting to install the addon.

My approach of developing a customer addon is to setup a deployment plone buildout and develop my addon in the src/ folder. This then looks something like this:

[buildout]
extends =
    http://dist.plone.org/release/5.1-latest/versions.cfg

find-links =
    http://dist.plone.org/release/5.1-latest/
    http://dist.plone.org/thirdparty/

extensions =
    mr.developer

parts =
    instance

sources = sources
sources-dir = src
auto-checkout =
    my.addon

[sources]
my.addon = git git@myrepo.gitlab.com:company/my.addon

[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
http-address = localhost:8080
debug-mode = on
verbose-security = on
eggs =
    Plone
    my.addon

with this approach you can simply add other addons in the [sources] section and add them either to your setup.py install_requires or your [instance] eggs ...

1 Like

That sounds way easier than what I've been doing! Thank you!

Check out the mr.developer documentation. You can set the branch you want for working on a feature branch of the source checkout on a feature branch of the deployment (and turtles all the way down, if working on a nested policy).

When I finally gave in and put the project in git, I made it past the error. I guess I just couldn't figure out how to get addon development working with the filesystem.