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
edis0n0
V2EX  ›  Python

Python 使用 c 语言写的这些 lib 的 py binding 的最佳实践是什么,好像没办法在 venv 的环境里直接用

  •  
  •   edis0n0 · 2022-11-02 15:57:40 +08:00 · 1925 次点击
    这是一个创建于 513 天前的主题,其中的信息可能已经有所发展或是发生改变。
    5 条回复    2022-11-03 16:26:51 +08:00
    YsHaNg
        1
    YsHaNg  
       2022-11-02 19:28:19 +08:00 via iPhone
    ctypes ?
    cclin
        2
    cclin  
       2022-11-02 19:31:43 +08:00 via Android
    编译好的吗?放在 pythonpath 目录下就行
    需要注意 python 版本要一致
    Huelse
        3
    Huelse  
       2022-11-02 19:57:25 +08:00
    pybind11 编译动态库后直接在当前目录可以用的
    clemente0620
        4
    clemente0620  
       2022-11-02 21:01:38 +08:00
    pybind11
    julyclyde
        5
    julyclyde  
       2022-11-03 16:26:51 +08:00
    ctypes 或者 cffi 吧
    运行时加载比较方便

    比编译一个 binding 要好一些。因为 binding 库编译的时候会 link 到具体的 python 版本,换 python 的时候还得再编译一次
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2754 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 12:04 · PVG 20:04 · LAX 05:04 · JFK 08:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.