[Distutils] symlinks in sources

Wichert Akkerman wichert at wiggy.net
Tue Apr 26 11:27:52 CEST 2011


I am trying to figure out the intended behaviour of dealing with 
symlinks in package sources. My use case is that I have a number of 
package implementation web things, and they tend to have an interactive 
(static) prototype parts of which are reused directly in the 
application. The filesystem structure for those packages is one of two 
options:

1. Prototype is at the toplevel of the source. For example:

    Prototype/index.html
    Prototyle/style/main.css
    setup.py
    MANIFEST.in
    src/namespace/__init__.py
    src/namespace/templates/index.html
    src/namespace/templates/style -> ../../../Prototype/style

2. Prototype is at outside the source. For example:

    Prototype/index.html
    Prototyle/style/main.css
    buildout/bootstrap.py
    buildout/buildout.cfg
    buildout/src/mypackage/setup.py
    buildout/src/mypackage/MANIFEST.in
    buildout/src/mypackage/src/namespace/__init__.py
    buildout/src/mypackage/src/namespace/templates/index.html
    buildout/src/mypackage/src/namespace/templates/style -> 
../../../../../../Prototype/style

My goal is to be able to create an sdist for my package and upload that 
to pypi, and when people install that namespace/templates/style/main.css 
must exist. Currently this does not appear to be possible. The problems 
I see are:

a) symlinks are skipped by distutils
b) if you use a file finder plugin which traverses the symlink and
    reports the files they end up twice in the sdist: once for the
    Prototype and once inside the package. They second one is stored
    as a link inside the sdist, but that link is not unpacked when
    installing from the sdist and the files go missing.

Trying to analyse things a bit I see a number of possible scenarios for 
symlinks:

i) symlink pointing to file inside the packgage
ii) symlink pointing to directory inside the packgage
iii) symlink pointing to file outside the packgage, but in SCM
iv) symlink pointing to directory outside the packgage, but in SCM
v) symlink pointing to something outside package and not managed by SCM

My expectation is that i and ii work out of the box, iii and iv should 
work if you have a file finder plugin for setuptools that traverses the 
symlink, and v to not work. Is that expectation reasonable?


Wichert.



More information about the Distutils-SIG mailing list