Skip to content

Instantly share code, notes, and snippets.

@willprice
Created August 5, 2020 13:47
Show Gist options
  • Select an option

  • Save willprice/311faace6fb4f514376fa405d2220615 to your computer and use it in GitHub Desktop.

Select an option

Save willprice/311faace6fb4f514376fa405d2220615 to your computer and use it in GitHub Desktop.
Create relative symlinks in python
@Sispheor
Copy link

Sispheor commented Mar 7, 2023

Works like a charm. Thank you 🙂

@milahu
Copy link

milahu commented Aug 2, 2025

see also Creating a relative symlink in python without using os.chdir()

ideally this should be possible with pathlib.Path.symlink_to like

Path(target).absolute().symlink_to(
  Path(destination).absolute(),
  target_is_directory=Path(target).isdir(),
  relative_symlink=True, # TODO add the parameter relative_symlink to pathlib
)

@tolot27
Copy link

tolot27 commented Dec 17, 2025

symlink_to does not have a parameter relative_symlink.

@milahu
Copy link

milahu commented Dec 17, 2025

yep, ideally the parameter relative_symlink should be added to pathlib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment