Search code examples
pythonbuildout

Symlink multiple targets in buildout recipe


I have a buildout recipe that creates a symlink to a file. The relevant section looks like this and works perfectly:

[symlinks]
recipe = cns.recipe.symlink
symlink = targetname1 = linkname1

Now I want to link to another file -- that is, a different source pointing at a different target. I thought this would work, but it doesn't:

[symlinks]
recipe = cns.recipe.symlink
symlink = targetname1 = linkname1
symlink = targetname2 = linkname2

Now neither of the two symlinks gets created.

I can solve the problem by doing this, but it's very clunky, especially when I want to make more than 2 symlinks:

[symlinks1]
recipe = cns.recipe.symlink
symlink = targetname1 = linkname1

[symlinks2]
recipe = cns.recipe.symlink
symlink = targetname2 = linkname2

How do I put multiple symlinks in a single section in the buildout recipe?


Solution

  • The solution is to write the different links on different lines. Like this:

    [symlinks]
    recipe = cns.recipe.symlink
    symlink =
        targetname1 = linkname1
        targetname2 = linkname2
    

    You can add as many links as you like by putting each one on a new line.

    You can read more about it in the source code for the recipe here. The documentation on that page above is unfortunately rather poor though.