bytecodealliance / bytecodealliance/componentize-py
Allow dynamic imports in sandbox example
- Lingua principale
- Rust
- Stelle
- 277
- Fork
- 51
- Merge medio
- 12h 10m
- PR unite (30g)
- 10
Descrizione
I'd like to execute code using the sandbox example, but am running into an issue. I want to allow exec'd code to import packages, but if I don't import packages in the host script, the guest code won't run.
```python
# Guest code
import json
print(json.dumps({"message": "Hello"}))
```
```python
# Works
import sys
import json
from command import exports
class Run(exports.Run):
def run(self):
with open(sys.argv[1]) as f:
code = f.read()
exec(code)
```
```python
# Fails
import sys
from command import exports
class Run(exports.Run):
def run(self):
with open(sys.argv[1]) as f:
code = f.read()
exec(code)
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.