Platon-Daytona SDK for Python
A Python SDK for interacting with the Daytona API, providing a simple interface for Daytona Sandbox management, Git operations, file system operations, and language server protocol support.
This is a fork of the original Daytona SDK, enhanced and maintained by Platon.AI.
Key Features
- Sandbox Management: Create, manage and remove sandboxes
- Git Operations: Clone repositories, manage branches, and more
- File System Operations: Upload, download, search and manipulate files
- Language Server Protocol: Interact with language servers for code intelligence
- Process Management: Execute code and commands in sandboxes
- Async Support: Full async/await support for modern Python applications
Installation
You can install the package using pip:
pip install platon-daytona
Quick Start
Here's a simple example of using the SDK:
from daytona import Daytona
# Initialize using environment variables
daytona = Daytona()
# Create a sandbox
sandbox = daytona.create()
# Run code in the sandbox
response = sandbox.process.code_run('print("Hello World!")')
print(response.result)
# Clean up when done
daytona.delete(sandbox)
Configuration
The SDK can be configured using environment variables or by passing a configuration object:
from daytona import Daytona, DaytonaConfig
# Initialize with configuration
config = DaytonaConfig(
api_key="your-api-key",
api_url="your-api-url",
target="us"
)
daytona = Daytona(config)
Or using environment variables:
DAYTONA_API_KEY: Your Daytona API keyDAYTONA_API_URL: The Daytona API URLDAYTONA_TARGET: Your target environment
You can also customize sandbox creation:
sandbox = daytona.create(CreateSandboxFromSnapshotParams(
language="python",
env_vars={"PYTHON_ENV": "development"},
auto_stop_interval=60, # Auto-stop after 1 hour of inactivity
auto_archive_interval=60 # Auto-archive after a Sandbox has been stopped for 1 hour
))
Examples
Execute Commands
# Execute a shell command
response = sandbox.process.exec('echo "Hello, World!"')
print(response.result)
# Run Python code
response = sandbox.process.code_run('''
x = 10
y = 20
print(f"Sum: {x + y}")
''')
print(response.result)
File Operations
# Upload a file
sandbox.fs.upload_file(b'Hello, World!', 'path/to/file.txt')
# Download a file
content = sandbox.fs.download_file('path/to/file.txt')
# Search for files
matches = sandbox.fs.find_files(root_dir, 'search_pattern')
Git Operations
# Clone a repository
sandbox.git.clone('https://github.com/example/repo', 'path/to/clone')
# List branches
branches = sandbox.git.branches('path/to/repo')
# Add files
sandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])
Language Server Protocol
# Create and start a language server
lsp = sandbox.create_lsp_server('typescript', 'path/to/project')
lsp.start()
# Notify the lsp for the file
lsp.did_open('path/to/file.ts')
# Get document symbols
symbols = lsp.document_symbols('path/to/file.ts')
# Get completions
completions = lsp.completions('path/to/file.ts', {"line": 10, "character": 15})
Async Support
import asyncio
from daytona import AsyncDaytona
async def main():
daytona = AsyncDaytona()
sandbox = await daytona.create()
response = await sandbox.process.code_run('print("Async Hello!")')
print(response.result)
await daytona.delete(sandbox)
asyncio.run(main())
What's Different in This Fork
This fork includes several enhancements over the original Daytona SDK:
- Enhanced error handling and debugging capabilities
- Additional utility functions for common operations
- Improved documentation and examples
- Better type hints and IDE support
- Regular updates and maintenance by Platon.AI team
API Compatibility
This package maintains 100% API compatibility with the original Daytona SDK. You can use it as a drop-in replacement:
# Import works exactly the same as original
from daytona import Daytona, DaytonaConfig, AsyncDaytona
Requirements
- Python 3.8 or higher
- Valid Daytona API credentials
Contributing
We welcome contributions! This project is based on the original Daytona SDK and follows the same contribution guidelines.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Support
- Issues: GitHub Issues
- Documentation: Project Documentation
- Email: ivincent.zhang@gmail.com
Acknowledgments
This project is based on the excellent work by Daytona Platforms Inc. We thank the original team for creating such a powerful SDK.
Note: This is an independent fork maintained by Platon.AI. For the original Daytona SDK, please visit the official Daytona repository.
Metadata
Release files for platon-daytona 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| platon_daytona-0.1.5.tar.gz | 84.9 kB | Without provenance | Details for platon_daytona-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| platon_daytona-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for platon_daytona-0.1.5-py3-none-any.whl |
Total release size: 191.8 kB
Release files / platon_daytona-0.1.5.tar.gz
| Download URL | platon_daytona-0.1.5.tar.gz |
|---|---|
| Size | 84.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a7cc8991fa4813c4e64894392870ae0cc4d09fcddd4cda8bfe615bc70c80b9e
|
|
BLAKE2b-256 checksum How to use checksums |
04dd61ae28840592222c3520ace4a59352a81086baf4f75b2e1b7c279d3fde44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2
|
Release files / platon_daytona-0.1.5-py3-none-any.whl
| Download URL | platon_daytona-0.1.5-py3-none-any.whl |
|---|---|
| Size | 106.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d11be632793e28d04a1823dd6d6f33a95d4bacbd5ec9f0b256acc4d34c5db56f
|
|
BLAKE2b-256 checksum How to use checksums |
a8545ebbb1cd964ad2d6e3d4894f1064e50d14809db8305f0f4d798f15e37d53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2
|
Security for platon-daytona 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.