Skip to content

Commit 84bef04

Browse files
Fix package symlinks towards store
1 parent 88a7ae4 commit 84bef04

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/deploy/commands/build.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,16 @@ def _build_envs(self) -> None:
251251

252252
def _build_env_for_package(self, base: Path, finalpkg: Package) -> None:
253253
for pkg in chain([finalpkg], finalpkg.depends):
254-
for srcdir, subdirs, files in os.walk(pkg.out):
255-
dstdir = base / srcdir[len(str(pkg.out)) + 1 :]
254+
out = pkg.out.resolve()
255+
for srcdir, subdirs, files in os.walk(out):
256+
dstdir = base / srcdir[len(str(out)) + 1 :]
256257
dstdir.mkdir(parents=True, exist_ok=True)
257258
for f in files:
258259
with suppress(FileExistsError):
259-
os.symlink(os.path.join(srcdir, f), os.path.join(dstdir, f))
260+
target = os.path.relpath(
261+
os.path.join(srcdir, f), dstdir.resolve()
262+
)
263+
os.symlink(target, os.path.join(dstdir, f))
260264

261265
# Write a manifest file
262266
(base / "manifest").write_text(finalpkg.manifest)

tests/test_build.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,20 +344,22 @@ def test_not_overwrite_user_set_version_alias_with_default(tmp_path, base_config
344344
assert str((tmp_path / "1").readlink()) == "1.1"
345345

346346

347-
def test_hello_world_example(tmp_path):
347+
def test_hello_world_example(tmp_path, monkeypatch):
348348
import shutil
349349

350350
example_dir = Path(__file__).parent.parent / "examples" / "hello_world"
351351
work_dir = tmp_path / "hello_world"
352352
shutil.copytree(example_dir, work_dir, ignore=shutil.ignore_patterns("output"))
353353

354-
prefix = tmp_path / "prefix"
355-
config = load_config(work_dir / "config.yaml")
356-
builder = Build(work_dir, config, prefix=prefix)
354+
monkeypatch.chdir(work_dir)
355+
356+
prefix = Path("output/prefix")
357+
config = load_config(Path("config.yaml"))
358+
builder = Build(Path("."), config, prefix=prefix)
357359
builder.build()
358360

359361
wrapper = prefix / "bin" / "run"
360362
assert wrapper.exists()
361-
result = subprocess.run([wrapper], capture_output=True, text=True)
363+
result = subprocess.run([str(wrapper)], capture_output=True, text=True)
362364
assert result.returncode == 0
363365
assert "running with args:" in result.stdout

0 commit comments

Comments
 (0)