V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
gosky
V2EX  ›  Python

有没有 Python sandbox 或者 container,比 docker 更轻量级

  •  
  •   gosky · 225 天前 · 1243 次点击
    这是一个创建于 225 天前的主题,其中的信息可能已经有所发展或是发生改变。
    目前服务都是 go 写的,go 服务跑在 docker 上
    一些工作需要 python 执行
    优先考虑到 go 里面跑一个 python 解释器,但一来没发现很好的解析器,二来依赖也是个问题
    所以想到,有没有类似 sandbox 或者 container 的技术,可以把 python 代码和依赖,都打包起来。每次 go 需要执行 python 任何了,就执行这个 sandbox 或者 container
    这样,还可以附带解决不同 python 任务的依赖
    7 条回复    2023-09-18 09:59:28 +08:00
    dayeye2006199
        1
    dayeye2006199  
       225 天前
    python 打包成 webassembly 然后 go 里面弄个 runtime 去调用? https://github.com/wasmerio/wasmer-go

    但这个肯定有些依赖支持的不好,特别是那类科学运算的
    ryanking8215
        2
    ryanking8215  
       225 天前
    做成胖容器,golang 的容器安装 python ,基础容器一般是 alpine 或者 debian ,都支持
    Lychee0
        3
    Lychee0  
       225 天前
    如果不涉及 dl 这种依赖 torch 容器镜像的工作,直接 pyinstaller 打包一下就好,然后在最终 alpine 镜像里面补下依赖咯
    打包困难就参考楼上的方案,python 官方不推荐 alpine ,可以试试看 python:3.xx-slim-bookworm
    6167
        4
    6167  
       225 天前
    用 go 发布 celery 异步任务?
    neoblackcap
        5
    neoblackcap  
       225 天前
    建议简单写一个 python web 服务,直接通过网络接口来调用 python 服务。
    julyclyde
        6
    julyclyde  
       224 天前
    这其实是两件事啊
    一般所谓容器包含文件系统发行、运行环境 cgroups+namespace 两个东西
    而你想要的是其实是个 python venv
    gosky
        7
    gosky  
    OP
       222 天前
    @julyclyde 也不知道该叫啥 哈哈
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1121 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:06 · PVG 02:06 · LAX 11:06 · JFK 14:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.