Page MenuHome

bam pack with -m FILE fails on copying deeper hierachies because of missing destination folders
Closed, ResolvedPublic


I just right now installed blender-bam through pip3, so the following should apply to the latest published version:

Given the following file structure:
(...)/textures/HDRI/Outdoor/Rocky Ridge-4k.hdr

Inside (...)/ I run:

bam pack -o foo/scene.blend -m FILE scene.blend

Which produces (BAM!):

scanning deps: b'/home/user/project/scene.blend'...
  blend:       b'/home/user/project/scene.blend'

archiving: 2 files
  copying: b'/home/user/project/textures/HDRI/Outdoor/Rocky Ridge-4k.hdr' -> b'/home/user/project/foo/textures/HDRI/Outdoor/Rocky Ridge-4k.hdr'
Traceback (most recent call last):
  File "/usr/local/bin/bam", line 11, in <module>
  File "/usr/local/lib/python3.5/dist-packages/bam/", line 8, in main
  File "/usr/local/lib/python3.5/dist-packages/bam/", line 2003, in main
  File "/usr/local/lib/python3.5/dist-packages/bam/", line 1797, in <lambda>
  File "/usr/local/lib/python3.5/dist-packages/bam/", line 1386, in pack
  File "/usr/local/lib/python3.5/dist-packages/bam/blend/", line 502, in pack
    shutil.copy(src, dst)
  File "/usr/lib/python3.5/", line 235, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.5/", line 115, in copyfile
    with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: b'/home/user/project/foo/textures/HDRI/Outdoor/Rocky Ridge-4k.hdr'

This is the affected line ( "/usr/local/lib/python3.5/dist-packages/bam/blend/", line 502) and surrounding block:

        for src, dst in path_copy_files:
            assert(b'.blend' not in dst)

            # in rare cases a filepath could point to a directory
            if (not os.path.exists(src)) or os.path.isdir(src):
                yield report("  %s: %r\n" % (colorize("source missing", color='red'), src))
                yield report("  %s: %r -> %r\n" % (colorize("copying", color='blue'), src, dst))
--------------> shutil.copy(src, dst)

To me this looks like the target folder structure foo/textures/HDRI/Outdoor/ into which Rocky Ridge-4k.hdr should go is non-existent, while shutil.copy requires it to exist (it doesn't create it automatically).

Possible solution: os.path.exists and os.makedirs to the rescue?

I'll supply a localized patch myself if you wish so, but in case this issue lies dormant all over the place also elsewhere in bam, this probably should be adressed by you as the masterminds behind it. :)

Thanks! Looking forward to smooth bam operation after this fix :)

Event Timeline

Super cool, already tested a few scenarios - works! Merci Bastien!

Any outlook when the pip package gets updated? (for the moment i just applied the patch locally)