kennethreitz/bob-builder — pull request #12 by dzuelke (2014-04-07 20:18:13+00:00)
Title: Fix tarball creation, for real :)

The recent change caused empty folders to be discarded.

I looked into the issue again. The old `os.path.basename` call returned an empty string only if `dir` had a trailing slash. Otherwise, it would return the dir name. So this was a bit brittle, because depending on whether or not someone had a trailing slash in the "Build Dir" comment at the top of their file, they'd get different results.

Passing an empty string as `arcname` always causes the empty entry in the tarball. This seems to be related to how `arcname` is passed through a `realpath` call.

The fix, then, is to simply iterate over the top level of the given directory, and add those entries individually (can be files or dirs). Much simpler code, too :)