爱意满满的作品展示区。
Honwhy

使用 Rust 编写 Python 模块

  •  
  •   Honwhy ·
    honwhy · May 27, 2023 · 3191 views
    This topic created in 1269 days ago, the information mentioned may be changed or developed.

    使用 Rust 编写 python 模块

    img

    首先创建一个目录,新建 python 虚拟环境,使用 maturin 脚手架新建一个 Rust 项目。

    cd urlsafe-base64-py
    python -m venv .env
    source .env/bin/activate
    pip install maturin
    

    本地安装和测试验证

    
    maturin develop
    python
    >>> import urlsafe_base64_py as ubp
    >>> ubp.encode("helloworld")
    'aGVsbG93b3JsZA'
    >>> ubp.decode("aGVsbG93b3JsZA")
    'helloworld'
    >>>
    

    发布到 pypi

    maturin publish
    

    结果 img2

    3 replies  •  2023-05-28 10:20:01 +08:00
    NoOneNoBody
    NoOneNoBody
    May 27, 2023
    1
    这算滥发么?
    pypi 应该建个测试沙箱
    centralpark
    centralpark
    May 27, 2023
    2
    @NoOneNoBody #1 有沙盒的,test.pypi.org
    fooyao183
    fooyao183
    May 28, 2023
    3
    有点 6 ,有没有可能自动转换现有 rust 库到 python 库
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2438 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 11:50 · PVG 19:50 · LAX 03:50 · JFK 06:50
    ♥ Do have faith in what you're doing.