Skip to content

Commit

Permalink
Fix copying of directory deps
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
lalten committed Jun 2, 2022
1 parent e134b8b commit d8bca8f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion appimage/private/tool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def make_appimage(
src = Path(file["src"]).resolve()
dst = (appdir / file["dst"]).resolve()
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy(src=src, dst=dst, follow_symlinks=True)
try:
shutil.copy(src=src, dst=dst, follow_symlinks=True)
except IsADirectoryError:
shutil.copytree(src=src, dst=dst, symlinks=True)
for link in manifest_data["symlinks"]:
linkfile = (appdir / Path(link["linkname"])).resolve()
linkfile.parent.mkdir(parents=True, exist_ok=True)
Expand Down
5 changes: 4 additions & 1 deletion tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ appimage_test(
py_binary(
name = "test_py",
srcs = ["test.py"],
data = ["data.txt"],
data = [
"data.txt",
"dir", # this is a relative directory, not a target label
],
main = "test.py",
deps = [requirement("click")],
)
Expand Down
5 changes: 5 additions & 0 deletions tests/dir/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
filegroup(
name = "dir",
srcs = ["file_in_dir.txt"],
visibility = ["//tests:__subpackages__"],
)
Empty file added tests/dir/file_in_dir.txt
Empty file.
2 changes: 2 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import click

DATA_DEP = Path("tests/data.txt")
DIR_DEP = Path("tests/dir/file_in_dir.txt")


def test_datadep() -> None:
assert DATA_DEP.is_file(), f"{DATA_DEP} does not exist"
assert (s := DATA_DEP.stat().st_size) == 591, f"{DATA_DEP} has wrong size {s}"
assert DIR_DEP.is_file(), f"{DIR_DEP} does not exist"


@click.command()
Expand Down

0 comments on commit d8bca8f

Please sign in to comment.