vercel-sandbox-bundle 0.2.0__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.
- vercel_sandbox_bundle-0.2.0/LICENSE +21 -0
- vercel_sandbox_bundle-0.2.0/PKG-INFO +49 -0
- vercel_sandbox_bundle-0.2.0/README.md +36 -0
- vercel_sandbox_bundle-0.2.0/_vercel_hatch_build.py +116 -0
- vercel_sandbox_bundle-0.2.0/hatch_build.py +29 -0
- vercel_sandbox_bundle-0.2.0/pyproject.toml +91 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/__init__.py +378 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/__main__.py +47 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/__init__.py +1 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/api_client.py +1469 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/async_filesystem_handle.py +243 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/async_runtime.py +1445 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/errors.py +179 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/filesystem_handle_common.py +196 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/filesystem_handle_core.py +341 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/filesystem_write.py +182 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/log_stream.py +29 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/models.py +741 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/options.py +76 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/pagination.py +119 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/process_output.py +105 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/runtime_common.py +533 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/service.py +994 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/state.py +127 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/streaming_archive.py +177 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/sync_filesystem_handle.py +227 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/sync_runtime.py +1362 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_internal/text_reader.py +377 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/_vendor/__init__.py +1 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/py.typed +1 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/sync.py +371 -0
- vercel_sandbox_bundle-0.2.0/vercel/sandbox/version.py +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vercel, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vercel-sandbox-bundle
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python SDK for Vercel Sandbox
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: pydantic<3,>=2.7.0
|
|
9
|
+
Requires-Dist: vercel-internal-core-bundle<0.2.0,>=0.1.0
|
|
10
|
+
Requires-Dist: vercel-internal-shared-vendored-deps>=0.1.0
|
|
11
|
+
Requires-Dist: vercel-oidc-bundle>=0.7.1
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# vercel-sandbox-bundle
|
|
15
|
+
|
|
16
|
+
This is a version of `vercel-sandbox` with third-party dependencies bundled. For normal use, install the unbundled `vercel-sandbox` package instead: https://pypi.org/project/vercel-sandbox/
|
|
17
|
+
|
|
18
|
+
# Vercel Sandbox Python SDK
|
|
19
|
+
|
|
20
|
+
Create and manage Vercel Sandboxes with synchronous and asynchronous APIs.
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from vercel import sandbox
|
|
24
|
+
from vercel.api import session
|
|
25
|
+
|
|
26
|
+
async with session():
|
|
27
|
+
async with sandbox.create_sandbox() as instance:
|
|
28
|
+
process = await instance.run_process("echo", ["hello"], capture_output=True)
|
|
29
|
+
print(process.stdout)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The package can be installed independently with `pip install vercel-sandbox`.
|
|
33
|
+
|
|
34
|
+
The same promoted API is available synchronously:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from vercel.api import session
|
|
38
|
+
from vercel.sandbox import sync as sandbox
|
|
39
|
+
|
|
40
|
+
with session():
|
|
41
|
+
with sandbox.create_sandbox() as instance:
|
|
42
|
+
process = instance.run_process("echo", ["hello"], capture_output=True)
|
|
43
|
+
print(process.stdout)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Installing this package also provides the `vercel-sandbox` and `sandbox`
|
|
47
|
+
console commands. Both are aliases that delegate all arguments to `npx sandbox`;
|
|
48
|
+
they require Node.js with npm and `npx` installed. Node.js is not required when
|
|
49
|
+
using the Python API directly.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# vercel-sandbox-bundle
|
|
2
|
+
|
|
3
|
+
This is a version of `vercel-sandbox` with third-party dependencies bundled. For normal use, install the unbundled `vercel-sandbox` package instead: https://pypi.org/project/vercel-sandbox/
|
|
4
|
+
|
|
5
|
+
# Vercel Sandbox Python SDK
|
|
6
|
+
|
|
7
|
+
Create and manage Vercel Sandboxes with synchronous and asynchronous APIs.
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from vercel import sandbox
|
|
11
|
+
from vercel.api import session
|
|
12
|
+
|
|
13
|
+
async with session():
|
|
14
|
+
async with sandbox.create_sandbox() as instance:
|
|
15
|
+
process = await instance.run_process("echo", ["hello"], capture_output=True)
|
|
16
|
+
print(process.stdout)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The package can be installed independently with `pip install vercel-sandbox`.
|
|
20
|
+
|
|
21
|
+
The same promoted API is available synchronously:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from vercel.api import session
|
|
25
|
+
from vercel.sandbox import sync as sandbox
|
|
26
|
+
|
|
27
|
+
with session():
|
|
28
|
+
with sandbox.create_sandbox() as instance:
|
|
29
|
+
process = instance.run_process("echo", ["hello"], capture_output=True)
|
|
30
|
+
print(process.stdout)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Installing this package also provides the `vercel-sandbox` and `sandbox`
|
|
34
|
+
console commands. Both are aliases that delegate all arguments to `npx sandbox`;
|
|
35
|
+
they require Node.js with npm and `npx` installed. Node.js is not required when
|
|
36
|
+
using the Python API directly.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""Hatch metadata hook for publish-time workspace dependency bounds."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import ast
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from hatchling.metadata.plugin.interface import MetadataHookInterface
|
|
10
|
+
from packaging.requirements import Requirement
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
import tomllib
|
|
14
|
+
except ModuleNotFoundError: # pragma: no cover - Python < 3.11
|
|
15
|
+
import tomli as tomllib # type: ignore[no-redef]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class WorkspaceDependenciesMetadataHook(MetadataHookInterface):
|
|
19
|
+
"""Generate package dependencies from the repo-owned dependency table."""
|
|
20
|
+
|
|
21
|
+
def update(self, metadata: dict[str, Any]) -> None:
|
|
22
|
+
"""Populate dynamic dependencies for Hatchling metadata generation."""
|
|
23
|
+
pyproject = _load_pyproject(Path(self.root))
|
|
24
|
+
release = pyproject.get("tool", {}).get("vercel", {}).get("release", {})
|
|
25
|
+
dependency_table = release.get("dependencies", {})
|
|
26
|
+
workspace_sources = pyproject.get("tool", {}).get("uv", {}).get("sources", {})
|
|
27
|
+
workspace_names = {
|
|
28
|
+
name for name, source in workspace_sources.items() if source.get("workspace") is True
|
|
29
|
+
}
|
|
30
|
+
workspace_root = _find_workspace_root(Path(self.root))
|
|
31
|
+
|
|
32
|
+
metadata["dependencies"] = [
|
|
33
|
+
_rewrite_dependency(requirement, workspace_names, workspace_root)
|
|
34
|
+
for requirement in dependency_table.get("dependencies", [])
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _load_pyproject(path: Path) -> dict[str, Any]:
|
|
39
|
+
with (path / "pyproject.toml").open("rb") as fp:
|
|
40
|
+
return tomllib.load(fp)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _find_workspace_root(start: Path) -> Path | None:
|
|
44
|
+
for path in [start, *start.parents]:
|
|
45
|
+
pyproject = path / "pyproject.toml"
|
|
46
|
+
if not pyproject.exists():
|
|
47
|
+
continue
|
|
48
|
+
data = _load_pyproject(path)
|
|
49
|
+
if "workspace" in data.get("tool", {}).get("uv", {}):
|
|
50
|
+
return path
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _rewrite_dependency(
|
|
55
|
+
requirement: str,
|
|
56
|
+
workspace_names: set[str],
|
|
57
|
+
workspace_root: Path | None,
|
|
58
|
+
) -> str:
|
|
59
|
+
parsed = Requirement(requirement)
|
|
60
|
+
normalized = parsed.name.lower().replace("_", "-")
|
|
61
|
+
if normalized not in workspace_names or workspace_root is None:
|
|
62
|
+
return requirement
|
|
63
|
+
return _with_lower_bound(parsed, _read_workspace_version(workspace_root, normalized))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _with_lower_bound(requirement: Requirement, version: str) -> str:
|
|
67
|
+
extras = f"[{','.join(sorted(requirement.extras))}]" if requirement.extras else ""
|
|
68
|
+
specifiers = [
|
|
69
|
+
str(specifier) for specifier in requirement.specifier if specifier.operator != ">="
|
|
70
|
+
]
|
|
71
|
+
specifier_text = ",".join([f">={version}", *specifiers])
|
|
72
|
+
marker = f" ; {requirement.marker}" if requirement.marker else ""
|
|
73
|
+
return f"{requirement.name}{extras}{specifier_text}{marker}"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _read_workspace_version(workspace_root: Path, package_name: str) -> str:
|
|
77
|
+
for pattern in ("src/*/pyproject.toml", "integrations/*/pyproject.toml"):
|
|
78
|
+
for pyproject_path in workspace_root.glob(pattern):
|
|
79
|
+
version = _version_from_pyproject(pyproject_path, package_name)
|
|
80
|
+
if version is not None:
|
|
81
|
+
return version
|
|
82
|
+
raise RuntimeError(f"unknown workspace dependency {package_name!r}")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _version_from_pyproject(pyproject_path: Path, package_name: str) -> str | None:
|
|
86
|
+
data = _load_pyproject(pyproject_path.parent)
|
|
87
|
+
if data.get("project", {}).get("name") != package_name:
|
|
88
|
+
return None
|
|
89
|
+
version_path = pyproject_path.parent / data["tool"]["hatch"]["version"]["path"]
|
|
90
|
+
module = ast.parse(version_path.read_text(encoding="utf-8"), filename=str(version_path))
|
|
91
|
+
for node in module.body:
|
|
92
|
+
value = _version_value(node)
|
|
93
|
+
if value is None:
|
|
94
|
+
continue
|
|
95
|
+
if isinstance(value, ast.Constant) and isinstance(value.value, str):
|
|
96
|
+
return value.value
|
|
97
|
+
raise RuntimeError(f"could not find __version__ in {version_path}")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _version_value(node: ast.stmt) -> ast.expr | None:
|
|
101
|
+
if isinstance(node, ast.Assign) and any(
|
|
102
|
+
isinstance(target, ast.Name) and target.id == "__version__" for target in node.targets
|
|
103
|
+
):
|
|
104
|
+
return node.value
|
|
105
|
+
if (
|
|
106
|
+
isinstance(node, ast.AnnAssign)
|
|
107
|
+
and isinstance(node.target, ast.Name)
|
|
108
|
+
and node.target.id == "__version__"
|
|
109
|
+
):
|
|
110
|
+
return node.value
|
|
111
|
+
return None
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def get_metadata_hook() -> type[MetadataHookInterface]:
|
|
115
|
+
"""Return the hook class used by Hatchling's custom hook loader."""
|
|
116
|
+
return WorkspaceDependenciesMetadataHook
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Load the shared Vercel Hatch metadata hook."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib.util import module_from_spec, spec_from_file_location
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from types import ModuleType
|
|
8
|
+
|
|
9
|
+
from hatchling.metadata.plugin.interface import MetadataHookInterface
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_metadata_hook() -> type[MetadataHookInterface]:
|
|
13
|
+
"""Return the shared workspace dependency metadata hook."""
|
|
14
|
+
return _load_shared_hook().get_metadata_hook()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _load_shared_hook() -> ModuleType:
|
|
18
|
+
root = Path(__file__).resolve().parent
|
|
19
|
+
candidates = [root / "../../scripts/hatch_build.py", root / "_vercel_hatch_build.py"]
|
|
20
|
+
for candidate in candidates:
|
|
21
|
+
path = candidate.resolve()
|
|
22
|
+
if path.exists():
|
|
23
|
+
spec = spec_from_file_location("_vercel_hatch_build", path)
|
|
24
|
+
if spec is None or spec.loader is None:
|
|
25
|
+
raise RuntimeError(f"could not load Hatch hook from {path}")
|
|
26
|
+
module = module_from_spec(spec)
|
|
27
|
+
spec.loader.exec_module(module)
|
|
28
|
+
return module
|
|
29
|
+
raise RuntimeError("could not find shared Vercel Hatch metadata hook")
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27.0,<2"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vercel-sandbox-bundle"
|
|
7
|
+
dynamic = ["version", "dependencies"]
|
|
8
|
+
description = "Python SDK for Vercel Sandbox"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = [
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"LICENSE.*",
|
|
15
|
+
"vercel/sandbox/_vendor/LICEN[CS]E*",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
vercel-sandbox = "vercel.sandbox.__main__:main"
|
|
20
|
+
sandbox = "vercel.sandbox.__main__:main"
|
|
21
|
+
|
|
22
|
+
[tool.hatch.metadata.hooks.custom]
|
|
23
|
+
path = "hatch_build.py"
|
|
24
|
+
|
|
25
|
+
[tool.vercel.release.dependencies]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"vercel-internal-core-bundle>=0.1.0,<0.2.0",
|
|
28
|
+
"vercel-oidc-bundle>=0.7.1",
|
|
29
|
+
"pydantic>=2.7.0,<3",
|
|
30
|
+
"vercel-internal-shared-vendored-deps>=0.1.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[tool.uv.sources]
|
|
34
|
+
vercel-internal-core = { workspace = true }
|
|
35
|
+
vercel-oidc = { workspace = true }
|
|
36
|
+
|
|
37
|
+
[tool.hatch.version]
|
|
38
|
+
path = "vercel/sandbox/version.py"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.sdist]
|
|
41
|
+
force-include = { "_vercel_hatch_build.py" = "/_vercel_hatch_build.py" }
|
|
42
|
+
include = [
|
|
43
|
+
"/vercel/sandbox/**/*.py",
|
|
44
|
+
"/vercel/sandbox/py.typed",
|
|
45
|
+
"/README.md",
|
|
46
|
+
"/pyproject.toml",
|
|
47
|
+
"/hatch_build.py",
|
|
48
|
+
"/LICENSE",
|
|
49
|
+
"/vercel/sandbox/_vendor/LICEN[CS]E*",
|
|
50
|
+
]
|
|
51
|
+
exclude = ["/**/__pycache__"]
|
|
52
|
+
|
|
53
|
+
[tool.hatch.build.targets.wheel]
|
|
54
|
+
dev-mode-dirs = ["."]
|
|
55
|
+
only-include = ["/vercel/sandbox"]
|
|
56
|
+
exclude = ["/**/__pycache__"]
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
testpaths = ["tests"]
|
|
60
|
+
pythonpath = ["."]
|
|
61
|
+
addopts = "--no-header --capture=tee-sys -m 'not live'"
|
|
62
|
+
asyncio_mode = "auto"
|
|
63
|
+
markers = ["live: requires live Sandbox API credentials"]
|
|
64
|
+
|
|
65
|
+
[tool.poe]
|
|
66
|
+
include = "../../scripts/poe/poe.toml"
|
|
67
|
+
verbosity = -1
|
|
68
|
+
|
|
69
|
+
[tool.mypy]
|
|
70
|
+
cache_dir = "../../.mypy_cache/vercel-sandbox"
|
|
71
|
+
explicit_package_bases = true
|
|
72
|
+
packages = ["vercel.sandbox"]
|
|
73
|
+
|
|
74
|
+
[tool.poe.tasks.typecheck]
|
|
75
|
+
cmd = "$MYPY"
|
|
76
|
+
|
|
77
|
+
[tool.vendoring]
|
|
78
|
+
destination = "vercel/sandbox/_vendor/"
|
|
79
|
+
requirements = "vercel/sandbox/_vendor/vendor.txt"
|
|
80
|
+
namespace = "vercel.sandbox._vendor"
|
|
81
|
+
protected-files = [
|
|
82
|
+
"__init__.py",
|
|
83
|
+
"vendor.txt",
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
[tool.vendoring.transformations]
|
|
87
|
+
drop = [
|
|
88
|
+
"*.so",
|
|
89
|
+
"*/tests/",
|
|
90
|
+
"*/__pycache__/",
|
|
91
|
+
]
|