ivaldi 0.1.7__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.1.7/PKG-INFO +16 -0
- ivaldi-0.1.7/README.md +1 -0
- ivaldi-0.1.7/ivaldi/__init__.py +45 -0
- ivaldi-0.1.7/ivaldi/enums.py +72 -0
- ivaldi-0.1.7/ivaldi/linux/installer.py +0 -0
- ivaldi-0.1.7/ivaldi/mac/installer.py +10 -0
- ivaldi-0.1.7/ivaldi/settings.py +92 -0
- ivaldi-0.1.7/ivaldi/shared/collect.py +56 -0
- ivaldi-0.1.7/ivaldi/shared/extract.py +28 -0
- ivaldi-0.1.7/ivaldi/shared/load_settings.py +60 -0
- ivaldi-0.1.7/ivaldi/shared/python.py +27 -0
- ivaldi-0.1.7/ivaldi/shared/uv.py +69 -0
- ivaldi-0.1.7/ivaldi/win/installer.py +0 -0
- ivaldi-0.1.7/pyproject.toml +64 -0
ivaldi-0.1.7/PKG-INFO
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ivaldi
|
|
3
|
+
Version: 0.1.7
|
|
4
|
+
Summary: Create a portable version of your Python Project
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Author: Fionn Tolster
|
|
7
|
+
Requires-Python: >3.13,<3.15
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Requires-Dist: nuitka[all] (>=4.1.3,<5.0.0)
|
|
11
|
+
Requires-Dist: poetry[all] (>=2.4.1,<3.0.0)
|
|
12
|
+
Requires-Dist: requests (>=2.34.2,<3.0.0)
|
|
13
|
+
Requires-Dist: zstandard (>=0.25.0,<0.26.0)
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
Alpha project
|
ivaldi-0.1.7/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Alpha project
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from ivaldi.shared.load_settings import load_directories, load_settings
|
|
7
|
+
|
|
8
|
+
logging.basicConfig(
|
|
9
|
+
force=True,
|
|
10
|
+
level=logging.INFO,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def build():
|
|
15
|
+
|
|
16
|
+
if sys.platform == "win32":
|
|
17
|
+
from ivaldi.win.installer import Install
|
|
18
|
+
|
|
19
|
+
settings = load_settings("win")
|
|
20
|
+
|
|
21
|
+
app_data = Path(os.environ["APPDATA"]) / settings.platform.location
|
|
22
|
+
exec_dir = (Path(os.environ["LOCALAPPDATA"]) / "Microsoft" / "WindowsApps").resolve()
|
|
23
|
+
settings = load_directories(settings, app_data, exec_dir)
|
|
24
|
+
elif sys.platform == "darwin":
|
|
25
|
+
from ivaldi.mac.installer import Install
|
|
26
|
+
|
|
27
|
+
settings = load_settings("mac")
|
|
28
|
+
|
|
29
|
+
app_data = Path.home() / "Library" / "Application Support" / settings.platform.location
|
|
30
|
+
exec_dir = (Path.home() / "bin").resolve()
|
|
31
|
+
settings = load_directories(settings, app_data, exec_dir)
|
|
32
|
+
elif sys.platform == "linux":
|
|
33
|
+
from ivaldi.linux.installer import Install
|
|
34
|
+
|
|
35
|
+
settings = load_settings("linux")
|
|
36
|
+
|
|
37
|
+
app_data = Path(os.environ.get("XDG_DATA_HOME", Path.home() / ".local" / "share")) / settings.platform.location
|
|
38
|
+
exec_dir = Path(os.environ.get("XDG_DATA_HOME", Path.home() / ".local" / "bin"))
|
|
39
|
+
settings = load_directories(settings, app_data, exec_dir)
|
|
40
|
+
|
|
41
|
+
Install(settings)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def run():
|
|
45
|
+
pass
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class UV_ARTIFACTS(StrEnum):
|
|
5
|
+
MACOS = "uv-aarch64-apple-darwin.tar.gz"
|
|
6
|
+
MACOS_INTEL = "uv-x86_64-apple-darwin.tar.gz"
|
|
7
|
+
WINDOWS_ARM = "uv-aarch64-pc-windows-msvc.zip"
|
|
8
|
+
WINDOWS_X86 = "uv-i686-pc-windows-msvc.zip"
|
|
9
|
+
WINDOWS_X64 = "uv-x86_64-pc-windows-msvc.zip"
|
|
10
|
+
LINUX_ARM64 = "uv-aarch64-unknown-linux-gnu.tar.gz"
|
|
11
|
+
LINUX_X86 = "uv-i686-unknown-linux-gnu.tar.gz"
|
|
12
|
+
LINUX_PPC64LE = "uv-powerpc64le-unknown-linux-gnu.tar.gz"
|
|
13
|
+
LINUX_RISCV = "uv-riscv64gc-unknown-linux-gnu.tar.gz"
|
|
14
|
+
LINUX_S390X = "uv-s390x-unknown-linux-gnu.tar.gz"
|
|
15
|
+
LINUX_X64 = "uv-x86_64-unknown-linux-gnu.tar.gz"
|
|
16
|
+
LINUX_ARMV7 = "uv-armv7-unknown-linux-gnueabihf.tar.gz"
|
|
17
|
+
LINUX_MUSL_ARM64 = "uv-aarch64-unknown-linux-musl.tar.gz"
|
|
18
|
+
LINUX_MUSL_X86 = "uv-i686-unknown-linux-musl.tar.gz"
|
|
19
|
+
LINUX_RISCV_MUSL = "uv-riscv64gc-unknown-linux-musl.tar.gz"
|
|
20
|
+
LINUX_MUSL_X64 = "uv-x86_64-unknown-linux-musl.tar.gz"
|
|
21
|
+
LINUX_MUSL_ARMV6 = "uv-arm-unknown-linux-musleabihf.tar.gz"
|
|
22
|
+
LINUX_MUSL_ARMV7 = "uv-armv7-unknown-linux-musleabihf.tar.gz"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class UV_MACOS_ARTIFACTS(StrEnum):
|
|
26
|
+
ARM64 = UV_ARTIFACTS.MACOS
|
|
27
|
+
AARCH64 = UV_ARTIFACTS.MACOS
|
|
28
|
+
X86_64 = UV_ARTIFACTS.MACOS_INTEL
|
|
29
|
+
AMD64 = UV_ARTIFACTS.MACOS_INTEL
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class UV_WINDOWS_ARTIFACTS(StrEnum):
|
|
33
|
+
ARM64 = UV_ARTIFACTS.WINDOWS_ARM
|
|
34
|
+
AARCH64 = UV_ARTIFACTS.WINDOWS_ARM
|
|
35
|
+
X86 = UV_ARTIFACTS.WINDOWS_X86
|
|
36
|
+
I386 = UV_ARTIFACTS.WINDOWS_X86
|
|
37
|
+
I686 = UV_ARTIFACTS.WINDOWS_X86
|
|
38
|
+
AMD64 = UV_ARTIFACTS.WINDOWS_X64
|
|
39
|
+
X86_64 = UV_ARTIFACTS.WINDOWS_X64
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class UV_LINUX_ARTIFACTS(StrEnum):
|
|
43
|
+
ARM64 = UV_ARTIFACTS.LINUX_ARM64
|
|
44
|
+
AARCH64 = UV_ARTIFACTS.LINUX_ARM64
|
|
45
|
+
X86 = UV_ARTIFACTS.LINUX_X86
|
|
46
|
+
I386 = UV_ARTIFACTS.LINUX_X86
|
|
47
|
+
I686 = UV_ARTIFACTS.LINUX_X86
|
|
48
|
+
PPC64LE = UV_ARTIFACTS.LINUX_PPC64LE
|
|
49
|
+
POWERPC64LE = UV_ARTIFACTS.LINUX_PPC64LE
|
|
50
|
+
RISCV64 = UV_ARTIFACTS.LINUX_RISCV
|
|
51
|
+
RISCV64GC = UV_ARTIFACTS.LINUX_RISCV
|
|
52
|
+
S390X = UV_ARTIFACTS.LINUX_S390X
|
|
53
|
+
AMD64 = UV_ARTIFACTS.LINUX_X64
|
|
54
|
+
X86_64 = UV_ARTIFACTS.LINUX_X64
|
|
55
|
+
ARMV7 = UV_ARTIFACTS.LINUX_ARMV7
|
|
56
|
+
ARMV7L = UV_ARTIFACTS.LINUX_ARMV7
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class UV_LINUX_MUSL_ARTIFACTS(StrEnum):
|
|
60
|
+
ARM64 = UV_ARTIFACTS.LINUX_MUSL_ARM64
|
|
61
|
+
AARCH64 = UV_ARTIFACTS.LINUX_MUSL_ARM64
|
|
62
|
+
X86 = UV_ARTIFACTS.LINUX_MUSL_X86
|
|
63
|
+
I386 = UV_ARTIFACTS.LINUX_MUSL_X86
|
|
64
|
+
I686 = UV_ARTIFACTS.LINUX_MUSL_X86
|
|
65
|
+
RISCV64 = UV_ARTIFACTS.LINUX_RISCV_MUSL
|
|
66
|
+
RISCV64GC = UV_ARTIFACTS.LINUX_RISCV_MUSL
|
|
67
|
+
AMD64 = UV_ARTIFACTS.LINUX_MUSL_X64
|
|
68
|
+
X86_64 = UV_ARTIFACTS.LINUX_MUSL_X64
|
|
69
|
+
ARMV6 = UV_ARTIFACTS.LINUX_MUSL_ARMV6
|
|
70
|
+
ARMV6L = UV_ARTIFACTS.LINUX_MUSL_ARMV6
|
|
71
|
+
ARMV7 = UV_ARTIFACTS.LINUX_MUSL_ARMV7
|
|
72
|
+
ARMV7L = UV_ARTIFACTS.LINUX_MUSL_ARMV7
|
|
File without changes
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import ClassVar
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class App:
|
|
8
|
+
def __init__(self, *args: tuple[str], **kwargs: dict[str, str]):
|
|
9
|
+
self.exclude = kwargs.pop("exclude")
|
|
10
|
+
self.include = kwargs.pop("include")
|
|
11
|
+
|
|
12
|
+
super().__init__()
|
|
13
|
+
|
|
14
|
+
entrypoint: str = None
|
|
15
|
+
include: ClassVar[list[str]] = []
|
|
16
|
+
exclude: ClassVar[list[str]] = [
|
|
17
|
+
"**/__pycache__/**", # Python cache
|
|
18
|
+
".venv/**/*", # Virtual environment
|
|
19
|
+
".git/**/*", # Git directory
|
|
20
|
+
"**/tests/**", # Test files
|
|
21
|
+
"**/*.pyc", # Compiled Python files
|
|
22
|
+
"**/*.pyo",
|
|
23
|
+
"**/*.pyd",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass
|
|
28
|
+
class UV:
|
|
29
|
+
def __post_init__(self):
|
|
30
|
+
self.version = self.version.replace("/", "")
|
|
31
|
+
self.repo = self.repo.removesuffix("/")
|
|
32
|
+
|
|
33
|
+
location: str = None
|
|
34
|
+
entrypoint: str = None
|
|
35
|
+
version: str = "0.12.3"
|
|
36
|
+
repo: str = "https://releases.astral.sh/github/uv/releases/download/"
|
|
37
|
+
extra_args: list[str] = None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class UVX:
|
|
42
|
+
extra_args: list[str] = None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class Python:
|
|
47
|
+
version: str = None
|
|
48
|
+
gil: bool = True
|
|
49
|
+
install_flags: list[str] = None
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@dataclass
|
|
53
|
+
class Poetry:
|
|
54
|
+
version: str = None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass
|
|
58
|
+
class Platform:
|
|
59
|
+
name: str = None
|
|
60
|
+
location: str = None
|
|
61
|
+
alias: str = None
|
|
62
|
+
add_to_path: bool = True
|
|
63
|
+
admin: bool = False
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass
|
|
67
|
+
class Directories:
|
|
68
|
+
uv: Path = None
|
|
69
|
+
bin: Path = None
|
|
70
|
+
app: Path = None
|
|
71
|
+
exec: Path = None
|
|
72
|
+
project: Path = None
|
|
73
|
+
build: Path = None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclass
|
|
77
|
+
class Executables:
|
|
78
|
+
uv: Path = None
|
|
79
|
+
uvx: Path = None
|
|
80
|
+
python: Path = None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass
|
|
84
|
+
class Settings:
|
|
85
|
+
app: App = field(default_factory=App)
|
|
86
|
+
bin: Executables = field(default_factory=Executables)
|
|
87
|
+
dirs: Directories = field(default_factory=Platform)
|
|
88
|
+
platform: Platform = field(default_factory=Platform)
|
|
89
|
+
poetry: Poetry = field(default_factory=Poetry)
|
|
90
|
+
python: Python = field(default_factory=Python)
|
|
91
|
+
uv: UV = field(default_factory=UV)
|
|
92
|
+
uvx: UVX = field(default_factory=UVX)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import shutil
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
logger = logging.getLogger(__name__)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def collect(settings):
|
|
9
|
+
project = settings.dirs.project
|
|
10
|
+
exclusion_rules = set()
|
|
11
|
+
for rule in settings.app.exclude:
|
|
12
|
+
rule = rule.rstrip("/")
|
|
13
|
+
exclusion_rules.add(rule)
|
|
14
|
+
if rule.endswith("/**/*"):
|
|
15
|
+
exclusion_rules.add(rule[:-5])
|
|
16
|
+
elif rule.endswith("/**"):
|
|
17
|
+
exclusion_rules.add(rule[:-3])
|
|
18
|
+
|
|
19
|
+
included = set()
|
|
20
|
+
for rule in settings.app.include:
|
|
21
|
+
included.update(project.glob(rule))
|
|
22
|
+
|
|
23
|
+
included = sorted(included)
|
|
24
|
+
excluded = []
|
|
25
|
+
collected = []
|
|
26
|
+
|
|
27
|
+
for item in included:
|
|
28
|
+
relative_path = item.relative_to(project)
|
|
29
|
+
relative_or_parent_excluded = any(
|
|
30
|
+
path.full_match(rule)
|
|
31
|
+
for path in (relative_path, *relative_path.parents)
|
|
32
|
+
if path != Path(".")
|
|
33
|
+
for rule in exclusion_rules
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
if relative_or_parent_excluded:
|
|
37
|
+
excluded.append(item)
|
|
38
|
+
else:
|
|
39
|
+
collected.append(item)
|
|
40
|
+
|
|
41
|
+
logger.info("Collecting %d project items", len(collected))
|
|
42
|
+
if excluded:
|
|
43
|
+
logger.info("Dropping %d project items due to exclusion rules", len(excluded))
|
|
44
|
+
|
|
45
|
+
for item in collected:
|
|
46
|
+
relative_path = item.relative_to(project)
|
|
47
|
+
build_path = settings.dirs.build / relative_path
|
|
48
|
+
|
|
49
|
+
if item.is_dir():
|
|
50
|
+
build_path.mkdir(parents=True, exist_ok=True)
|
|
51
|
+
continue
|
|
52
|
+
|
|
53
|
+
build_path.parent.mkdir(parents=True, exist_ok=True)
|
|
54
|
+
shutil.copy2(item, build_path, follow_symlinks=False)
|
|
55
|
+
|
|
56
|
+
return collected
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
import tarfile
|
|
3
|
+
import zipfile
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def extract(location, destination):
|
|
8
|
+
location = Path(location)
|
|
9
|
+
destination = Path(destination)
|
|
10
|
+
|
|
11
|
+
destination.mkdir(exist_ok=True, parents=True)
|
|
12
|
+
|
|
13
|
+
if ".tar" in location.suffixes:
|
|
14
|
+
with tarfile.open(location) as archive:
|
|
15
|
+
archive.extractall(path=str(location.parent), filter="data")
|
|
16
|
+
elif ".zip" in location.suffixes:
|
|
17
|
+
with zipfile.ZipFile(location) as archive:
|
|
18
|
+
archive.extractall(path=str(location.parent))
|
|
19
|
+
else:
|
|
20
|
+
raise ValueError(f"Unsupported archive format: {location}")
|
|
21
|
+
|
|
22
|
+
location.unlink()
|
|
23
|
+
for f in location.parent.iterdir():
|
|
24
|
+
if f.is_dir() and f.name in location.name:
|
|
25
|
+
for subf in f.iterdir():
|
|
26
|
+
if subf.is_file():
|
|
27
|
+
subf.move(destination / subf.name)
|
|
28
|
+
shutil.rmtree(f)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import tomllib
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from ivaldi.settings import UV, UVX, App, Directories, Platform, Poetry, Python, Settings
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def find_build_file(start: Path | None = None) -> Path:
|
|
8
|
+
directory = start or Path.cwd()
|
|
9
|
+
candidate = directory / "ivaldi.toml"
|
|
10
|
+
|
|
11
|
+
if candidate.is_file():
|
|
12
|
+
return candidate, candidate.parent
|
|
13
|
+
|
|
14
|
+
for parent in directory.parents:
|
|
15
|
+
candidate = parent / "ivaldi.toml"
|
|
16
|
+
if candidate.is_file():
|
|
17
|
+
return candidate, candidate.parent
|
|
18
|
+
|
|
19
|
+
raise FileNotFoundError(f"Could not find ivaldi.toml in {directory} or any parent directory")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def load_settings(platform):
|
|
23
|
+
file, project_folder = find_build_file()
|
|
24
|
+
|
|
25
|
+
with open(file, "rb") as f:
|
|
26
|
+
config = tomllib.load(f)
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
uv = UV(**config.get("uv", {}))
|
|
30
|
+
uvx = UVX(**config.get("uvx", {}))
|
|
31
|
+
poetry = Poetry(**config.get("poetry", {}))
|
|
32
|
+
python = Python(**config.get("python", {}))
|
|
33
|
+
app = App(**config.get("app", {}))
|
|
34
|
+
platform = Platform(**config.get(platform, {}))
|
|
35
|
+
dirs = Directories(project=project_folder)
|
|
36
|
+
except TypeError as err:
|
|
37
|
+
f = str(err).replace(".__init__()", "")
|
|
38
|
+
raise KeyError(f)
|
|
39
|
+
|
|
40
|
+
settings = Settings(app=app, python=python, poetry=poetry, uv=uv, uvx=uvx, dirs=dirs, platform=platform)
|
|
41
|
+
|
|
42
|
+
return settings
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def load_directories(settings: Settings, app_data: Path, exec_dir: Path):
|
|
46
|
+
bin = app_data / "bin"
|
|
47
|
+
uv_cache = app_data / "cache"
|
|
48
|
+
build = app_data / "build"
|
|
49
|
+
|
|
50
|
+
app_data.mkdir(exist_ok=True, parents=True)
|
|
51
|
+
bin.mkdir(exist_ok=True, parents=True)
|
|
52
|
+
uv_cache.mkdir(exist_ok=True, parents=True)
|
|
53
|
+
exec_dir.mkdir(exist_ok=True, parents=True)
|
|
54
|
+
|
|
55
|
+
settings.dirs.bin = bin
|
|
56
|
+
settings.dirs.uv = uv_cache
|
|
57
|
+
settings.dirs.app = app_data
|
|
58
|
+
settings.dirs.build = build
|
|
59
|
+
settings.exec = exec
|
|
60
|
+
return settings
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import subprocess
|
|
3
|
+
|
|
4
|
+
logger = logging.getLogger(__name__)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def install(settings):
|
|
8
|
+
|
|
9
|
+
uv = f"{settings.bin.uv.resolve()!s}"
|
|
10
|
+
dir = f"{settings.dirs.app.resolve()!s}"
|
|
11
|
+
bin = f"{settings.dirs.bin.resolve()!s}"
|
|
12
|
+
uv_cache = f"{settings.dirs.uv.resolve()!s}"
|
|
13
|
+
|
|
14
|
+
extra_flags = settings.python.install_flags or []
|
|
15
|
+
|
|
16
|
+
flags = ["-q", "--no-config", "--cache-dir", uv_cache, "--no-registry", "--no-bin", "-i", bin] + extra_flags
|
|
17
|
+
|
|
18
|
+
command = [uv, "python", "install", settings.python.version, *flags, "--directory", dir]
|
|
19
|
+
install = subprocess.run(
|
|
20
|
+
command,
|
|
21
|
+
shell=False,
|
|
22
|
+
check=True,
|
|
23
|
+
)
|
|
24
|
+
if install.returncode != 0:
|
|
25
|
+
raise RuntimeError(f"Python install failed - exited with code {install.returncode} - {install}")
|
|
26
|
+
|
|
27
|
+
logger.info(f"Installed Python {settings.python.version} sucessfully")
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import platform
|
|
3
|
+
import tempfile
|
|
4
|
+
from os import stat
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import requests
|
|
8
|
+
|
|
9
|
+
from ivaldi.settings import Settings
|
|
10
|
+
from ivaldi.shared.extract import extract
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def resolve_release():
|
|
16
|
+
from ivaldi.enums import UV_ARTIFACTS, UV_LINUX_ARTIFACTS, UV_LINUX_MUSL_ARTIFACTS, UV_MACOS_ARTIFACTS, UV_WINDOWS_ARTIFACTS
|
|
17
|
+
|
|
18
|
+
system = platform.system()
|
|
19
|
+
machine = platform.machine().upper()
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
if system == "Darwin":
|
|
23
|
+
artifact = UV_MACOS_ARTIFACTS[machine]
|
|
24
|
+
elif system == "Windows":
|
|
25
|
+
artifact = UV_WINDOWS_ARTIFACTS[machine]
|
|
26
|
+
elif system == "Linux":
|
|
27
|
+
if platform.libc_ver()[0].lower() == "musl" or Path("/etc/alpine-release").exists():
|
|
28
|
+
artifact = UV_LINUX_MUSL_ARTIFACTS[machine]
|
|
29
|
+
else:
|
|
30
|
+
artifact = UV_LINUX_ARTIFACTS[machine]
|
|
31
|
+
else:
|
|
32
|
+
raise KeyError
|
|
33
|
+
except KeyError:
|
|
34
|
+
raise RuntimeError(f"UV does not provide an artifact for {system} on {machine}")
|
|
35
|
+
|
|
36
|
+
return UV_ARTIFACTS(artifact)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def install(settings: Settings):
|
|
40
|
+
|
|
41
|
+
repo = settings.uv.repo
|
|
42
|
+
version = settings.uv.version
|
|
43
|
+
release = resolve_release()
|
|
44
|
+
destination = settings.dirs.app / release
|
|
45
|
+
|
|
46
|
+
url = repo + "/" + version + "/" + release
|
|
47
|
+
|
|
48
|
+
with requests.get(url, stream=True) as response:
|
|
49
|
+
response.raise_for_status()
|
|
50
|
+
total_length = response.headers.get("content-length")
|
|
51
|
+
if total_length is None: # no content length header
|
|
52
|
+
raise ValueError(f"Received empty content-length header back from {url}. Please check the URL passed.")
|
|
53
|
+
else:
|
|
54
|
+
try:
|
|
55
|
+
blksize = stat.st_blksize if stat else 4096
|
|
56
|
+
except AttributeError:
|
|
57
|
+
blksize = 4096
|
|
58
|
+
|
|
59
|
+
with tempfile.NamedTemporaryFile() as f:
|
|
60
|
+
for data in response.iter_content(chunk_size=blksize):
|
|
61
|
+
f.write(data)
|
|
62
|
+
Path(f.name).replace(destination)
|
|
63
|
+
|
|
64
|
+
extract(location=destination, destination=settings.dirs.bin)
|
|
65
|
+
|
|
66
|
+
logger.info(f"Installed UV {version} sucessfully")
|
|
67
|
+
|
|
68
|
+
settings.bin.uv = settings.dirs.bin / "uv"
|
|
69
|
+
settings.bin.uvx = settings.dirs.bin / "uvx"
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ivaldi"
|
|
3
|
+
version = "0.1.7"
|
|
4
|
+
description = "Create a portable version of your Python Project"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "Fionn Tolster"}
|
|
7
|
+
]
|
|
8
|
+
license = "MIT"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">3.13,<3.15"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"requests (>=2.34.2,<3.0.0)",
|
|
13
|
+
"poetry[all] (>=2.4.1,<3.0.0)",
|
|
14
|
+
"nuitka[all] (>=4.1.3,<5.0.0)",
|
|
15
|
+
"zstandard (>=0.25.0,<0.26.0)",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
build = "ivaldi:build"
|
|
20
|
+
run = "ivaldi:run"
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
24
|
+
build-backend = "poetry.core.masonry.api"
|
|
25
|
+
|
|
26
|
+
[tool.poetry]
|
|
27
|
+
packages = [{ include = "ivaldi", from="." }, ]
|
|
28
|
+
include = []
|
|
29
|
+
|
|
30
|
+
[tool.nuitka]
|
|
31
|
+
project = true
|
|
32
|
+
# Build flags
|
|
33
|
+
mode = "onefile"
|
|
34
|
+
no-prefer-source-code = true
|
|
35
|
+
assume-yes-for-downloads = true
|
|
36
|
+
output-dir = "dist/nuitka"
|
|
37
|
+
remove-output = true
|
|
38
|
+
static-libpython = "no"
|
|
39
|
+
onefile-no-compression = true
|
|
40
|
+
|
|
41
|
+
nofollow-import-to = ["*.tests", "tests", "*.benchmarks", "_decimal"]
|
|
42
|
+
enable-plugin = []
|
|
43
|
+
include-package = []
|
|
44
|
+
|
|
45
|
+
# OS compatability
|
|
46
|
+
include-windows-runtime-dlls = "yes"
|
|
47
|
+
company-name = "Neo4j"
|
|
48
|
+
product-name = "Ivaldi Installer"
|
|
49
|
+
file-description = "Creates a portable executable version of your project"
|
|
50
|
+
|
|
51
|
+
# # Runtime optimisations
|
|
52
|
+
# onefile-tempdir-spec = "{CACHE_DIR}/Neo4j/neoterm-installer"
|
|
53
|
+
# onefile-cache-mode = "cached"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
[tool.coverage.run]
|
|
57
|
+
relative_files = true
|
|
58
|
+
|
|
59
|
+
[dependency-groups]
|
|
60
|
+
dev = [
|
|
61
|
+
"ruff (>=0.16.0,<0.17.0)",
|
|
62
|
+
"pytest (>=9.0.2,<10.0.0)",
|
|
63
|
+
]
|
|
64
|
+
|