Skip to content

Commit

Permalink
build.hooks: Ignore bytecode collisions
Browse files Browse the repository at this point in the history
Bytecode files contain fully resolved file names, meaning that the byte code will always collide even if the original sources are identical.
We can safely ignore collisions for bytecode because we check the original sources for equality.
  • Loading branch information
adisbladis committed Nov 24, 2024
1 parent d31c5e0 commit e66b856
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion build/hooks/make-venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,14 @@ def write_site_packages(src: Path, dst: Path) -> None:
try:
os.symlink(src, dst)
except FileExistsError as exc:
# Bytecode files contain fully resolved file names, meaning that the byte code will always collide
# even if the original sources are identical.
# We can safely ignore collisions for bytecode because we check the original sources for equality.
if "__pycache__" in dst.parts and dst.suffix == ".pyc":
return

if not filecmp.cmp(src, dst):
raise ValueError(f"""Two packages are trying to provide the same file with differnt contents.
raise ValueError(f"""Two packages are trying to provide the same file with different contents.
Target: {dst}
File 1: {src}
File 2: {Path(dst).resolve()}.
Expand Down

0 comments on commit e66b856

Please sign in to comment.