https://github.com/sciris/subenv
Run virtual environments as subprocesses
https://github.com/sciris/subenv
Last synced: 10 months ago
JSON representation
Run virtual environments as subprocesses
- Host: GitHub
- URL: https://github.com/sciris/subenv
- Owner: sciris
- License: mit
- Created: 2025-08-14T23:08:53.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-14T23:11:54.000Z (10 months ago)
- Last Synced: 2025-08-15T01:10:03.633Z (10 months ago)
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Subenv
Python package that lets you run multiple versions of code in parallel in a single interpreter session via virtual environments. Example:
```py
import subenv
# Paths to Python interpreters (e.g. different conda, uv, or venv environments)
OLD = "/old/starsim/env/bin/python"
NEW = "/new/starsim/env/bin/python"
# Create the environments
env_old = subenv.Env(OLD)
env_new = subenv.Env(NEW)
cmd1 = "import starsim as ss"
env_old.exec(cmd1)
env_new.exec(cmd1)
cmd2 = "res = ss.Sim().run().results"
env_old.exec(cmd2)
env_new.exec(cmd2)
res_old = env_old.get('res')
res_new = env_new.get('res')
print("old:", res_old)
print("new:", res_new)
env_old.close()
env_new.close()
```