boxlite 0.2.0.dev0__cp310-cp310-macosx_14_0_arm64.whl → 0.5.6__cp310-cp310-macosx_14_0_arm64.whl
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.
- boxlite/__init__.py +54 -23
- boxlite/boxlite.cpython-310-darwin.so +0 -0
- boxlite/browserbox.py +10 -3
- boxlite/codebox.py +7 -7
- boxlite/computerbox.py +129 -336
- boxlite/constants.py +25 -0
- boxlite/errors.py +8 -2
- boxlite/exec.py +2 -1
- boxlite/interactivebox.py +50 -56
- boxlite/runtime/boxlite-guest +0 -0
- boxlite/runtime/boxlite-shim +0 -0
- boxlite/runtime/debugfs +0 -0
- boxlite/runtime/libgvproxy.dylib +0 -0
- boxlite/runtime/libkrun.1.16.0.dylib +0 -0
- boxlite/runtime/{libkrunfw.4.dylib → libkrunfw.5.dylib} +0 -0
- boxlite/runtime/mke2fs +0 -0
- boxlite/simplebox.py +81 -34
- boxlite/sync_api/__init__.py +65 -0
- boxlite/sync_api/_box.py +133 -0
- boxlite/sync_api/_boxlite.py +377 -0
- boxlite/sync_api/_codebox.py +145 -0
- boxlite/sync_api/_execution.py +203 -0
- boxlite/sync_api/_simplebox.py +180 -0
- boxlite/sync_api/_sync_base.py +137 -0
- boxlite-0.5.6.dist-info/METADATA +845 -0
- boxlite-0.5.6.dist-info/RECORD +27 -0
- {boxlite-0.2.0.dev0.dist-info → boxlite-0.5.6.dist-info}/WHEEL +1 -1
- boxlite-0.2.0.dev0.dist-info/METADATA +0 -9
- boxlite-0.2.0.dev0.dist-info/RECORD +0 -17
boxlite/__init__.py
CHANGED
|
@@ -4,9 +4,7 @@ BoxLite - Lightweight, secure containerization for any environment.
|
|
|
4
4
|
Following SQLite philosophy: "BoxLite" for branding, "boxlite" for code APIs.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
import os
|
|
8
7
|
import warnings
|
|
9
|
-
from pathlib import Path
|
|
10
8
|
|
|
11
9
|
# Import core Rust API
|
|
12
10
|
try:
|
|
@@ -19,6 +17,7 @@ try:
|
|
|
19
17
|
ExecStdout,
|
|
20
18
|
ExecStderr,
|
|
21
19
|
BoxInfo,
|
|
20
|
+
BoxStateInfo,
|
|
22
21
|
RuntimeMetrics,
|
|
23
22
|
BoxMetrics,
|
|
24
23
|
)
|
|
@@ -33,6 +32,7 @@ try:
|
|
|
33
32
|
"ExecStdout",
|
|
34
33
|
"ExecStderr",
|
|
35
34
|
"BoxInfo",
|
|
35
|
+
"BoxStateInfo",
|
|
36
36
|
"RuntimeMetrics",
|
|
37
37
|
"BoxMetrics",
|
|
38
38
|
]
|
|
@@ -40,52 +40,83 @@ except ImportError as e:
|
|
|
40
40
|
warnings.warn(f"BoxLite native extension not available: {e}", ImportWarning)
|
|
41
41
|
__all__ = []
|
|
42
42
|
|
|
43
|
-
# Import Python convenience wrappers
|
|
43
|
+
# Import Python convenience wrappers (re-exported via __all__)
|
|
44
44
|
try:
|
|
45
|
-
from .simplebox import SimpleBox
|
|
46
|
-
from .exec import ExecResult
|
|
47
|
-
from .codebox import CodeBox
|
|
48
|
-
from .errors import BoxliteError, ExecError, TimeoutError, ParseError
|
|
49
|
-
|
|
50
|
-
__all__.extend(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
45
|
+
from .simplebox import SimpleBox # noqa: F401
|
|
46
|
+
from .exec import ExecResult # noqa: F401
|
|
47
|
+
from .codebox import CodeBox # noqa: F401
|
|
48
|
+
from .errors import BoxliteError, ExecError, TimeoutError, ParseError # noqa: F401
|
|
49
|
+
|
|
50
|
+
__all__.extend(
|
|
51
|
+
[
|
|
52
|
+
# Python convenience wrappers
|
|
53
|
+
"SimpleBox",
|
|
54
|
+
"CodeBox",
|
|
55
|
+
"ExecResult",
|
|
56
|
+
# Error types
|
|
57
|
+
"BoxliteError",
|
|
58
|
+
"ExecError",
|
|
59
|
+
"TimeoutError",
|
|
60
|
+
"ParseError",
|
|
61
|
+
]
|
|
62
|
+
)
|
|
61
63
|
except ImportError:
|
|
62
64
|
pass
|
|
63
65
|
|
|
64
|
-
# Specialized containers
|
|
66
|
+
# Specialized containers (re-exported via __all__)
|
|
65
67
|
try:
|
|
66
|
-
from .browserbox import BrowserBox, BrowserBoxOptions
|
|
68
|
+
from .browserbox import BrowserBox, BrowserBoxOptions # noqa: F401
|
|
67
69
|
|
|
68
70
|
__all__.extend(["BrowserBox", "BrowserBoxOptions"])
|
|
69
71
|
except ImportError:
|
|
70
72
|
pass
|
|
71
73
|
|
|
72
74
|
try:
|
|
73
|
-
from .computerbox import ComputerBox
|
|
75
|
+
from .computerbox import ComputerBox # noqa: F401
|
|
74
76
|
|
|
75
77
|
__all__.extend(["ComputerBox"])
|
|
76
78
|
except ImportError:
|
|
77
79
|
pass
|
|
78
80
|
|
|
79
81
|
try:
|
|
80
|
-
from .interactivebox import InteractiveBox
|
|
82
|
+
from .interactivebox import InteractiveBox # noqa: F401
|
|
81
83
|
|
|
82
84
|
__all__.extend(["InteractiveBox"])
|
|
83
85
|
except ImportError:
|
|
84
86
|
pass
|
|
85
87
|
|
|
88
|
+
# Sync API (greenlet-based synchronous wrappers, re-exported via __all__)
|
|
89
|
+
# Requires greenlet: pip install boxlite[sync]
|
|
90
|
+
try:
|
|
91
|
+
from .sync_api import ( # noqa: F401
|
|
92
|
+
SyncBoxlite,
|
|
93
|
+
SyncBox,
|
|
94
|
+
SyncExecution,
|
|
95
|
+
SyncExecStdout,
|
|
96
|
+
SyncExecStderr,
|
|
97
|
+
SyncSimpleBox,
|
|
98
|
+
SyncCodeBox,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
__all__.extend(
|
|
102
|
+
[
|
|
103
|
+
"SyncBoxlite",
|
|
104
|
+
"SyncBox",
|
|
105
|
+
"SyncExecution",
|
|
106
|
+
"SyncExecStdout",
|
|
107
|
+
"SyncExecStderr",
|
|
108
|
+
"SyncSimpleBox",
|
|
109
|
+
"SyncCodeBox",
|
|
110
|
+
]
|
|
111
|
+
)
|
|
112
|
+
except ImportError:
|
|
113
|
+
# greenlet not installed - sync API not available
|
|
114
|
+
pass
|
|
115
|
+
|
|
86
116
|
# Get version from package metadata
|
|
87
117
|
try:
|
|
88
118
|
from importlib.metadata import version, PackageNotFoundError
|
|
119
|
+
|
|
89
120
|
__version__ = version("boxlite")
|
|
90
121
|
except PackageNotFoundError:
|
|
91
122
|
# Package not installed (e.g., development mode)
|
|
Binary file
|
boxlite/browserbox.py
CHANGED
|
@@ -8,7 +8,7 @@ controlled from outside using standard tools like Puppeteer or Playwright.
|
|
|
8
8
|
from dataclasses import dataclass
|
|
9
9
|
from typing import Optional, TYPE_CHECKING
|
|
10
10
|
|
|
11
|
-
from .simplebox import SimpleBox
|
|
11
|
+
from .simplebox import SimpleBox
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
14
|
from .boxlite import Boxlite
|
|
@@ -30,6 +30,7 @@ class BrowserBoxOptions:
|
|
|
30
30
|
>>> async with BrowserBox(opts) as browser:
|
|
31
31
|
... print(browser.endpoint())
|
|
32
32
|
"""
|
|
33
|
+
|
|
33
34
|
browser: str = "chromium" # chromium, firefox, or webkit
|
|
34
35
|
memory: int = 2048 # Memory in MiB
|
|
35
36
|
cpu: int = 2 # Number of CPU cores
|
|
@@ -60,14 +61,19 @@ class BrowserBox(SimpleBox):
|
|
|
60
61
|
# CDP port for each browser type
|
|
61
62
|
_PORTS = {"chromium": 9222, "firefox": 9223, "webkit": 9224}
|
|
62
63
|
|
|
63
|
-
def __init__(
|
|
64
|
-
|
|
64
|
+
def __init__(
|
|
65
|
+
self,
|
|
66
|
+
options: Optional[BrowserBoxOptions] = None,
|
|
67
|
+
runtime: Optional["Boxlite"] = None,
|
|
68
|
+
**kwargs,
|
|
69
|
+
):
|
|
65
70
|
"""
|
|
66
71
|
Create and auto-start a browser.
|
|
67
72
|
|
|
68
73
|
Args:
|
|
69
74
|
options: Browser configuration (uses defaults if None)
|
|
70
75
|
runtime: Optional runtime instance (uses global default if None)
|
|
76
|
+
**kwargs: Additional configuration options (volumes, env, etc.)
|
|
71
77
|
"""
|
|
72
78
|
opts = options or BrowserBoxOptions()
|
|
73
79
|
|
|
@@ -80,6 +86,7 @@ class BrowserBox(SimpleBox):
|
|
|
80
86
|
memory_mib=opts.memory,
|
|
81
87
|
cpus=opts.cpu,
|
|
82
88
|
runtime=runtime,
|
|
89
|
+
**kwargs,
|
|
83
90
|
)
|
|
84
91
|
|
|
85
92
|
async def __aenter__(self):
|
boxlite/codebox.py
CHANGED
|
@@ -25,12 +25,12 @@ class CodeBox(SimpleBox):
|
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
def __init__(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
self,
|
|
29
|
+
image: str = "python:slim",
|
|
30
|
+
memory_mib: Optional[int] = None,
|
|
31
|
+
cpus: Optional[int] = None,
|
|
32
|
+
runtime: Optional["Boxlite"] = None,
|
|
33
|
+
**kwargs,
|
|
34
34
|
):
|
|
35
35
|
"""
|
|
36
36
|
Create a new CodeBox.
|
|
@@ -80,7 +80,7 @@ class CodeBox(SimpleBox):
|
|
|
80
80
|
Returns:
|
|
81
81
|
Execution output as a string
|
|
82
82
|
"""
|
|
83
|
-
with open(script_path,
|
|
83
|
+
with open(script_path, "r") as f:
|
|
84
84
|
code = f.read()
|
|
85
85
|
return await self.run(code)
|
|
86
86
|
|