ivaldi 0.3.2__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ivaldi-0.3.2 → ivaldi-0.3.3}/PKG-INFO +1 -1
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/commands/install.py +12 -7
- ivaldi-0.3.3/ivaldi/shared/admin.py +77 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/shared/settings.py +3 -2
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/types/settings.py +0 -1
- {ivaldi-0.3.2 → ivaldi-0.3.3}/pyproject.toml +1 -1
- ivaldi-0.3.2/ivaldi/shared/admin.py +0 -21
- {ivaldi-0.3.2 → ivaldi-0.3.3}/LICENSE +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/README.md +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/THIRD_PARTY_NOTICES.md +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/__init__.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/__main__.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/commands/build.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/commands/run.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/shared/alias.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/shared/build.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/shared/collect.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/shared/extract.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/shared/project.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/shared/python.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/shared/uv.py +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/stage/.gitkeep +0 -0
- {ivaldi-0.3.2 → ivaldi-0.3.3}/ivaldi/types/enums.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import platform
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
|
|
4
|
+
from ivaldi.shared.admin import restore_sudo_ownership
|
|
4
5
|
from ivaldi.shared.alias import install_alias
|
|
5
6
|
from ivaldi.shared.project import install_project, mark_installed
|
|
6
7
|
from ivaldi.shared.python import install_python
|
|
@@ -12,13 +13,17 @@ system = platform.system()
|
|
|
12
13
|
|
|
13
14
|
def install(location, executable: Path | None = None):
|
|
14
15
|
settings = load_settings(location=location, build=False)
|
|
15
|
-
settings = load_install_directories(settings)
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
try:
|
|
18
|
+
settings = load_install_directories(settings)
|
|
19
|
+
install_uv(settings)
|
|
20
|
+
install_python(settings)
|
|
21
|
+
install_project(settings)
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
alias = install_alias(settings, executable)
|
|
24
|
+
if not settings.platform.add_to_path or alias is not None:
|
|
25
|
+
mark_installed(settings)
|
|
26
|
+
finally:
|
|
27
|
+
if settings.dirs.app is not None:
|
|
28
|
+
restore_sudo_ownership(settings.dirs.app)
|
|
24
29
|
return settings
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(frozen=True)
|
|
7
|
+
class User:
|
|
8
|
+
uid: int
|
|
9
|
+
gid: int
|
|
10
|
+
home: Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def sudo_user() -> User | None:
|
|
14
|
+
"""Return the user who invoked sudo, when running elevated on POSIX."""
|
|
15
|
+
if os.name == "nt" or os.geteuid() != 0:
|
|
16
|
+
return None
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
uid = int(os.environ["SUDO_UID"])
|
|
20
|
+
gid = int(os.environ["SUDO_GID"])
|
|
21
|
+
except KeyError:
|
|
22
|
+
return None
|
|
23
|
+
except ValueError:
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
if uid <= 0 or gid < 0:
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
import pwd
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
home = Path(pwd.getpwuid(uid).pw_dir)
|
|
33
|
+
except KeyError:
|
|
34
|
+
return None
|
|
35
|
+
return User(uid=uid, gid=gid, home=home)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def user_home() -> Path:
|
|
39
|
+
"""Return the invoking user's home, rather than root's home under sudo."""
|
|
40
|
+
user = sudo_user()
|
|
41
|
+
return user.home if user is not None else Path.home()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def restore_sudo_ownership(path: Path) -> None:
|
|
45
|
+
"""Return an elevated install tree to the user who invoked sudo.
|
|
46
|
+
|
|
47
|
+
Windows elevation retains the user's SID and files created below AppData
|
|
48
|
+
inherit that user's ACL, so no ownership repair is necessary there.
|
|
49
|
+
"""
|
|
50
|
+
user = sudo_user()
|
|
51
|
+
if user is None or not path.exists():
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
for directory, directories, files in os.walk(path, topdown=False, followlinks=False):
|
|
55
|
+
for name in (*directories, *files):
|
|
56
|
+
os.chown(Path(directory) / name, user.uid, user.gid, follow_symlinks=False)
|
|
57
|
+
os.chown(directory, user.uid, user.gid, follow_symlinks=False)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def needs_admin(admin: bool | str, phase: str) -> bool:
|
|
61
|
+
"""Return whether a configured phase requires administrator privileges."""
|
|
62
|
+
return admin is True or admin == phase
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def is_admin() -> bool:
|
|
66
|
+
if os.name == "nt":
|
|
67
|
+
import ctypes
|
|
68
|
+
|
|
69
|
+
return bool(ctypes.windll.shell32.IsUserAnAdmin())
|
|
70
|
+
return os.geteuid() == 0
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def run_elevated(*_args, **_kwargs):
|
|
74
|
+
"""Stop and ask the user to restart the launcher with elevated privileges."""
|
|
75
|
+
if os.name == "nt":
|
|
76
|
+
raise SystemExit("Administrator privileges are required; rerun this command as Administrator")
|
|
77
|
+
raise SystemExit("Administrator privileges are required; rerun this command with sudo")
|
|
@@ -6,6 +6,7 @@ import shutil
|
|
|
6
6
|
import tomllib
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
|
+
from ivaldi.shared.admin import user_home
|
|
9
10
|
from ivaldi.types.enums import IVALDI
|
|
10
11
|
from ivaldi.types.settings import UV, UVX, App, Directories, Nuitka, Platform, Python, Settings
|
|
11
12
|
|
|
@@ -18,7 +19,7 @@ GENERATED_CONFIG_HEADER = "# Generated from [tool.ivaldi] in pyproject.toml"
|
|
|
18
19
|
def set_platform_home(settings):
|
|
19
20
|
|
|
20
21
|
if system == "Darwin":
|
|
21
|
-
home =
|
|
22
|
+
home = user_home()
|
|
22
23
|
settings.dirs.exec = (home / "bin").resolve()
|
|
23
24
|
settings.dirs.app = home / "Library" / "Application Support" / settings.platform.location
|
|
24
25
|
elif system == "Windows":
|
|
@@ -26,7 +27,7 @@ def set_platform_home(settings):
|
|
|
26
27
|
settings.dirs.exec = (Path(os.environ["LOCALAPPDATA"]) / "Microsoft" / "WindowsApps").resolve()
|
|
27
28
|
|
|
28
29
|
elif system == "Linux":
|
|
29
|
-
home =
|
|
30
|
+
home = user_home()
|
|
30
31
|
settings.dirs.exec = home / ".local" / "bin"
|
|
31
32
|
settings.dirs.app = Path(os.environ.get("XDG_DATA_HOME", home / ".local" / "share")) / settings.platform.location
|
|
32
33
|
else:
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def needs_admin(admin: bool | str, phase: str) -> bool:
|
|
5
|
-
"""Return whether a configured phase requires administrator privileges."""
|
|
6
|
-
return admin is True or admin == phase
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def is_admin() -> bool:
|
|
10
|
-
if os.name == "nt":
|
|
11
|
-
import ctypes
|
|
12
|
-
|
|
13
|
-
return bool(ctypes.windll.shell32.IsUserAnAdmin())
|
|
14
|
-
return os.geteuid() == 0
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def run_elevated(*_args, **_kwargs):
|
|
18
|
-
"""Stop and ask the user to restart the launcher with elevated privileges."""
|
|
19
|
-
if os.name == "nt":
|
|
20
|
-
raise SystemExit("Administrator privileges are required; rerun this command as Administrator")
|
|
21
|
-
raise SystemExit("Administrator privileges are required; rerun this command with sudo")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|