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 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
- # Python convenience wrappers
52
- "SimpleBox",
53
- "CodeBox",
54
- "ExecResult",
55
- # Error types
56
- "BoxliteError",
57
- "ExecError",
58
- "TimeoutError",
59
- "ParseError",
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, StreamType
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__(self, options: Optional[BrowserBoxOptions] = None,
64
- runtime: Optional['Boxlite'] = None):
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
- self,
29
- image: str = "python:slim",
30
- memory_mib: Optional[int] = None,
31
- cpus: Optional[int] = None,
32
- runtime: Optional['Boxlite'] = None,
33
- **kwargs
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, 'r') as f:
83
+ with open(script_path, "r") as f:
84
84
  code = f.read()
85
85
  return await self.run(code)
86
86