Skip to content

support setting symlinks on macos. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/ffmpeg_downloader/_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,22 @@ def extract(tarpaths, dst, progress=None):
return dstsub


def set_symlinks(binpaths):

user_home = path.expanduser("~")
user_bindirs = [path.join(user_home, ".local", "bin"), path.join(user_home, "bin")]
d = next(
(d for d in user_bindirs if path.isdir(d)),
None,
)
if d is None:
d = user_bindirs[0]
os.makedirs(d, exist_ok=True)
print(
"!!!Created ~/.local/bin. Must log out and back in for the setting to take effect (or update .profile or .bashrc).!!!"
def set_symlinks(binpaths, target=None):
if target:
d = target
else:
user_home = path.expanduser("~")
user_bindirs = [path.join(user_home, ".local", "bin"), path.join(user_home, "bin")]
d = next(
(d for d in user_bindirs if path.isdir(d)),
None,
)
if d is None:
d = user_bindirs[0]
os.makedirs(d, exist_ok=True)
print(
"!!!Created ~/.local/bin. Must log out and back in for the setting to take effect (or update .profile or .bashrc).!!!"
)

symlinks = {name: path.join(d, name) for name in binpaths}
for name, binpath in binpaths.items():
Expand Down
5 changes: 4 additions & 1 deletion src/ffmpeg_downloader/_macos.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from os import path
import re, os, zipfile

Expand Down Expand Up @@ -165,7 +166,9 @@ def extract(zippaths, dst, progress=None):


def set_symlinks(binpaths):
raise NotImplementedError("--set_symlinks option is not supported on Mac")
from . import _linux as linux
target = path.dirname(sys.executable)
linux.set_symlinks(binpaths, target)


def clr_symlinks(symlinks):
Expand Down