Can I ignore symlinks in setuptools MANIFEST.in?
Asked Answered
H

1

11

When creating a source distribution using python's setuptools (python setup.py sdist), I am using a MANIFEST.in file containing the line:

recursive-include mypackage

because I want to include some non-module files inside the mypackage directory. However, there are also symbolic links under the mypackage directory whose targets I do not want included in my source distribution. Is there a way to specify "ignore symlinks" inside the MANIFEST.in ?

I know... I probably shouldn't have those symlinks there.

Humidifier answered 18/10, 2013 at 22:3 Comment(3)
Maybe you can exclude them by running a function turning a MANIFEST_template.in into MANIFEST.in at the start of your setup.py? Scanning for symlinks with the info from this post. Would be nice if there's such an option, though.Parliamentarian
To the best of my knowledge, using recursive-include mypackage to include everything in your package should be avoided. This can pick up lots of things you really don't want included in your distributions. You should list specific files if they are few and special, or otherwise include them by extension or other file name pattern, e.g. recursive-include mypackage *.mydataformat.Sixfold
If you know the symlinks you can explicitly add excludes after recursive-include in MANIFEST.in – directives are evaluated in order.Unreasoning
F
3

Distutils does not offer any special handling of symlinks. You can look through the distutils code and see that the processing of the MANIFEST.in file is doing simple pattern matching, using os.listdir recursively, without any special handling for symlinks.

Flamingo answered 29/4, 2015 at 16:4 Comment(1)
You might want to edit this answer to make it clear that this means "no" to my original question -- distutils can't be told to ignore symlinks because under the hood it's not aware of them.Humidifier

© 2022 - 2024 — McMap. All rights reserved.