aea.helpers.sym_
link
Sym link implementation for Linux, MacOS, and Windows.
make_
symlink
Make a symbolic link, cross platform.
Arguments:
link_name
: the link name.target
: the target.
cd
Change directory with context manager.
create_
symlink
Change directory and call the cross-platform script.
The working directory must be the parent of the symbolic link name when executing 'create_symlink_crossplatform.sh'. Hence, we need to translate target_path into the relative path from the symbolic link directory to the target directory.
So: 1) from link_path, extract the number of jumps to the parent directory in order to reach the repository root directory, and chain many "../" paths. 2) from target_path, compute the relative path to the root 3) relative_target_path is just the concatenation of the results from step (1) and (2).
For instance, given - link_path: './directory_1//symbolic_link - target_path: './directory_2/target_path
we want to compute: - link_path: 'symbolic_link' (just the last bit) - relative_target_path: '../../directory_1/target_path'
The resulting command on UNIX systems will be:
cd directory_1 && ln -s ../../directory_1/target_path symbolic_link
Arguments:
link_path
: the source pathtarget_path
: the target pathroot_path
: the root path
Returns:
exit code