Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase committed Feb 22, 2024
1 parent 407fb97 commit 5740178
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions python/py_venv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import argparse
import filecmp
import warnings
from pathlib import Path

SKIP_SET = {Path("requirements.txt")}
Expand All @@ -22,7 +24,17 @@
relative_directory = directory_path.relative_to(target_directory, walk_up=True)

for file_name in file_names:
if in_package_directory / file_name not in SKIP_SET:
symlink_path = target_directory / file_name
target_path = relative_directory / file_name
symlink_path.symlink_to(target_path)
if in_package_directory / file_name in SKIP_SET:
continue

symlink_path = target_directory / file_name
target_path = relative_directory / file_name
if symlink_path.exists():
if not filecmp.cmp(symlink_path, directory_path / file_name, shallow=False):
warnings.warn(
f"{symlink_path} already exists and points to {symlink_path.readlink()}\n"
+ f"Skip {target_path} which seems to have different contents"
)
continue

symlink_path.symlink_to(target_path)

0 comments on commit 5740178

Please sign in to comment.