Skip to content

Commit 0c09caf

Browse files
authored
Merge pull request #1 from mfzzf/main
feat: Implement the initial UCloud Sandbox Python SDK
2 parents 70c5de7 + 9a21592 commit 0c09caf

255 files changed

Lines changed: 29892 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish-pypi.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout source
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.11"
19+
20+
- name: Install build tooling
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install build
24+
25+
- name: Build distribution artifacts
26+
run: python -m build
27+
28+
- name: Publish package to PyPI
29+
uses: pypa/gh-action-pypi-publish@release/v1
30+
with:
31+
user: __token__
32+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
tests/assets/video-downloaded.webm
2+
3+
### Node template
4+
# Logs
5+
logs
6+
*.log
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
node_modules/
46+
jspm_packages/
47+
48+
# Snowpack dependency directory (https://snowpack.dev/)
49+
web_modules/
50+
51+
# TypeScript cache
52+
*.tsbuildinfo
53+
54+
# Optional npm cache directory
55+
.npm
56+
57+
# Optional eslint cache
58+
.eslintcache
59+
60+
# Optional stylelint cache
61+
.stylelintcache
62+
63+
# Microbundle cache
64+
.rpt2_cache/
65+
.rts2_cache_cjs/
66+
.rts2_cache_es/
67+
.rts2_cache_umd/
68+
69+
# Optional REPL history
70+
.node_repl_history
71+
72+
# Output of 'npm pack'
73+
*.tgz
74+
75+
# Yarn Integrity file
76+
.yarn-integrity
77+
78+
# dotenv environment variable files
79+
.env
80+
.env.development.local
81+
.env.test.local
82+
.env.production.local
83+
.env.local
84+
85+
# parcel-bundler cache (https://parceljs.org/)
86+
.cache
87+
.parcel-cache
88+
89+
# Next.js build output
90+
.next
91+
out
92+
93+
# Nuxt.js build / generate output
94+
.nuxt
95+
dist
96+
97+
# Gatsby files
98+
.cache/
99+
# Comment in the public line in if your project uses Gatsby and not Next.js
100+
# https://nextjs.org/blog/next-9-1#public-directory-support
101+
# public
102+
103+
# vuepress build output
104+
.vuepress/dist
105+
106+
# vuepress v2.x temp and cache directory
107+
.temp
108+
109+
# Docusaurus cache and generated files
110+
.docusaurus
111+
112+
# Serverless directories
113+
.serverless/
114+
115+
# FuseBox cache
116+
.fusebox/
117+
118+
# DynamoDB Local files
119+
.dynamodb/
120+
121+
# TernJS port file
122+
.tern-port
123+
124+
# Stores VSCode versions used for testing VSCode extensions
125+
.vscode-test
126+
127+
# yarn v2
128+
.yarn/cache
129+
.yarn/unplugged
130+
.yarn/build-state.yml
131+
.yarn/install-state.gz
132+
.pnp.*
133+
134+
### Python template
135+
# Byte-compiled / optimized / DLL files
136+
__pycache__/
137+
*.py[cod]
138+
*$py.class
139+
140+
# C extensions
141+
*.so
142+
143+
# Distribution / packaging
144+
.Python
145+
build/
146+
develop-eggs/
147+
dist/
148+
downloads/
149+
eggs/
150+
.eggs/
151+
lib/
152+
lib64/
153+
parts/
154+
sdist/
155+
var/
156+
wheels/
157+
share/python-wheels/
158+
*.egg-info/
159+
.installed.cfg
160+
*.egg
161+
MANIFEST
162+
163+
# PyInstaller
164+
# Usually these files are written by a python script from a template
165+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
166+
*.manifest
167+
*.spec
168+
169+
# Installer logs
170+
pip-log.txt
171+
pip-delete-this-directory.txt
172+
173+
# Unit test / coverage reports
174+
htmlcov/
175+
.tox/
176+
.nox/
177+
.coverage
178+
.coverage.*
179+
nosetests.xml
180+
coverage.xml
181+
*.cover
182+
*.py,cover
183+
.hypothesis/
184+
.pytest_cache/
185+
cover/
186+
187+
# Translations
188+
*.mo
189+
*.pot
190+
191+
# Django stuff:
192+
local_settings.py
193+
db.sqlite3
194+
db.sqlite3-journal
195+
196+
# Flask stuff:
197+
instance/
198+
.webassets-cache
199+
200+
# Scrapy stuff:
201+
.scrapy
202+
203+
# Sphinx documentation
204+
docs/_build/
205+
206+
# PyBuilder
207+
.pybuilder/
208+
target/
209+
210+
# Jupyter Notebook
211+
.ipynb_checkpoints
212+
213+
# IPython
214+
profile_default/
215+
ipython_config.py
216+
217+
# pdm
218+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
219+
# in version control.
220+
# https://pdm.fming.dev/#use-with-ide
221+
.pdm.toml
222+
223+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
224+
__pypackages__/
225+
226+
# Celery stuff
227+
celerybeat-schedule
228+
celerybeat.pid
229+
230+
# SageMath parsed files
231+
*.sage.py
232+
233+
# Environments
234+
.venv
235+
env/
236+
venv/
237+
ENV/
238+
env.bak/
239+
venv.bak/
240+
241+
# Spyder project settings
242+
.spyderproject
243+
.spyproject
244+
245+
# Rope project settings
246+
.ropeproject
247+
248+
# mkdocs documentation
249+
/site
250+
251+
# mypy
252+
.mypy_cache/
253+
.dmypy.json
254+
dmypy.json
255+
256+
# Pyre type checker
257+
.pyre/
258+
259+
# pytype static type analyzer
260+
.pytype/
261+
262+
# Cython debug symbols
263+
cython_debug/
264+
265+
.idea/
266+
267+
# Test results
268+
results.csv

LICENSE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
MIT License
2+
3+
Copyright (c) 2025 UCloud Technology Co., Ltd.
4+
5+
This project is based on E2B (https://github.com/e2b-dev/e2b), originally developed by FoundryLabs, Inc.
6+
Original E2B License: MIT License, Copyright (c) 2025 FOUNDRYLABS, INC.
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11+
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
ROOT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/../..)
2+
3+
generate-api:
4+
python $(ROOT_DIR)/spec/remove_extra_tags.py sandboxes templates
5+
openapi-python-client generate --output-path $(ROOT_DIR)/packages/python-sdk/e2b/api/api --overwrite --path $(ROOT_DIR)/spec/openapi_generated.yml
6+
rm -rf e2b/api/client
7+
mv e2b/api/api/e2b_api_client e2b/api/client
8+
rm -rf e2b/api/api
9+
ruff format .
10+
11+
generate-envd:
12+
if [ ! -f "/go/bin/protoc-gen-connect-python" ]; then \
13+
$(MAKE) -C $(ROOT_DIR)/packages/connect-python build; \
14+
fi
15+
16+
cd $(ROOT_DIR)/spec/envd && pwd && buf generate --template buf-python.gen.yaml
17+
./scripts/fix-python-pb.sh
18+
19+
ruff format .
20+
21+
generate: generate-api generate-envd generate-mcp
22+
23+
init:
24+
pip install openapi-python-client datamodel-code-generator
25+
26+
lint:
27+
ruff check .
28+
29+
format:
30+
ruff format .
31+
32+
generate-mcp:
33+
datamodel-codegen \
34+
--input ../../spec/mcp-server.json \
35+
--input-file-type jsonschema \
36+
--output e2b/sandbox/mcp.py \
37+
--output-model-type typing.TypedDict \
38+
--target-python-version 3.9 \
39+
--class-name McpServer \
40+
--use-field-description \
41+
--disable-timestamp \
42+
--extra-fields forbid
43+
44+
.PHONY: setup
45+
setup:
46+
poetry install
47+
48+
.PHONY: test
49+
test: setup
50+
poetry run pytest --verbose --numprocesses=4

0 commit comments

Comments
 (0)