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

使用 Rust 编写 Python 模块

  •  
  •   Honwhy ·
    honwhy · May 27, 2023 · 2862 views
    This topic created in 1122 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
        1
    NoOneNoBody  
       May 27, 2023
    这算滥发么?
    pypi 应该建个测试沙箱
    centralpark
        2
    centralpark  
       May 27, 2023
    @NoOneNoBody #1 有沙盒的,test.pypi.org
    fooyao183
        3
    fooyao183  
       May 28, 2023
    有点 6 ,有没有可能自动转换现有 rust 库到 python 库
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3533 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 10:42 · PVG 18:42 · LAX 03:42 · JFK 06:42
    ♥ Do have faith in what you're doing.