python-genshin-artifact/docs/build.md
luoshuijs 5f7033d331
📝 Add Documentation
Co-authored-by: Nahida <CHxCOOH@googlemail.com>
Co-authored-by: kotoriのねこ <minamiktr@outlook.com>
2023-10-24 18:42:49 +08:00

1.6 KiB

Dev Setup

Prerequisite

  • Install rust
  • Confirm installation
    $ rustup --version
    rustup 1.26.0 (5af9b9484 2023-04-05)
    info: This is the version for the rustup toolchain manager, not the rustc compiler.
    info: The currently active `rustc` version is `rustc 1.75.0-nightly (1c05d50c8 2023-10-21)`
    $ cargo --version
    cargo 1.73.0 (9c4383fb5 2023-08-26)
    
  • Install maturin from PyO3
    $ pip install maturin
    

Build

  • Navigate to core -> run cargo build
    $ cd python_genshin_artifact_core
    $ cargo build
       ...
       Compiling pyo3-ffi v0.19.2
       Compiling pyo3 v0.19.2
       Compiling genshin_artifact_core v0.1.1 (/home/kotori/projects/python/python-genshin-artifact/python_genshin_artifact_core)
        Finished dev [unoptimized + debuginfo] target(s) in 3.12s
    
  • Use maturin to install the rust library into a python library
    $ maturin develop
    ...
    📦 Built wheel for CPython 3.11 to /tmp/.tmpicGM3M/genshin_artifact_core-0.1.1-cp311-cp311-linux_x86_64.whl
    🛠 Installed genshin_artifact_core-0.1.1
    
  • Navigate back to project root and build with poetry:
    $ poetry build
    Building Python-Genshin-Artifact (0.1.1)
      - Building sdist
      - Built python_genshin_artifact-0.1.1.tar.gz
      - Building wheel
      - Built python_genshin_artifact-0.1.1-py3-none-any.whl
    
  • Install the built wheel with pip:
    $ pip install dist/python_genshin_artifact-0.1.1-py3-none-any.whl
    

Usage

Refer to other docs (i.e DamageAnalysis) for usage.