2023-10-24 10:42:49 +00:00
|
|
|
# Dev Setup
|
|
|
|
|
|
|
|
## Prerequisite
|
|
|
|
|
|
|
|
- Install [rust](https://www.rust-lang.org/tools/install)
|
|
|
|
- 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](https://github.com/PyO3/maturin) from PyO3
|
|
|
|
```
|
|
|
|
$ pip install maturin
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Build
|
|
|
|
|
2023-11-08 01:24:00 +00:00
|
|
|
- (Optional) Run cargo build
|
2023-10-24 10:42:49 +00:00
|
|
|
```
|
2023-11-08 01:24:00 +00:00
|
|
|
$ cargo build --no-default-features
|
2023-10-24 10:42:49 +00:00
|
|
|
...
|
|
|
|
Compiling pyo3-ffi v0.19.2
|
|
|
|
Compiling pyo3 v0.19.2
|
2023-11-08 01:24:00 +00:00
|
|
|
Compiling python_genshin_artifact v0.1.1 (/home/kotori/projects/python/python-genshin-artifact/python_genshin_artifact_core)
|
2023-10-24 10:42:49 +00:00
|
|
|
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
|
2023-11-08 01:24:00 +00:00
|
|
|
🛠 Installed python_genshin_artifact-0.1.1
|
2023-10-24 10:42:49 +00:00
|
|
|
```
|
2023-11-08 01:24:00 +00:00
|
|
|
- Use maturin to build the wheel
|
2023-10-24 10:42:49 +00:00
|
|
|
```
|
2023-11-08 01:24:00 +00:00
|
|
|
$ maturin build --out dist
|
|
|
|
...
|
|
|
|
Finished dev [unoptimized + debuginfo] target(s) in 3.88s
|
|
|
|
📦 Built wheel for CPython 3.11 to dist/python_genshin_artifact-0.1.4-cp311-cp311-manylinux_2_34_x86_64.whl
|
2023-10-24 10:42:49 +00:00
|
|
|
```
|
|
|
|
- Install the built wheel with pip:
|
|
|
|
```
|
2023-11-08 01:24:00 +00:00
|
|
|
$ pip install dist/python_genshin_artifact-xxx.whl
|
2023-10-24 10:42:49 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Refer to other docs (i.e [DamageAnalysis](DamageAnalysis.md)) for usage.
|