bytecodealliance / bytecodealliance/componentize-py

Allow dynamic imports in sandbox example

Open
#91 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
277
Forks
51
Avg merge
12h 10m
Merged PRs (30d)
10

Description

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)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.