[Breaking] Naming convention #19

Merged
Dandaedre merged 2 commits from dan into develop 2023-02-25 21:34:45 +01:00
27 changed files with 64 additions and 86 deletions

4
Cargo.lock generated
View File

@ -552,8 +552,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
[[package]]
name = "xiv_craft_solver"
version = "0.1.4"
name = "xiv_csolver"
version = "0.1.5"
dependencies = [
"clap",
"lazy_static",

View File

@ -1,12 +1,12 @@
[package]
name = "xiv_craft_solver"
name = "xiv_csolver"
version = "0.1.5"
edition = "2021"
authors = ["谭俊健","Dandaedre","Vkyfox"]
description = "Small XIV solver library in rust, with python and rust bindings"
homepage = "https://proxy.dandaedre.com/gitea/Dandaedre/rcraft_solver"
documentation = "https://proxy.dandaedre.com/gitea/Dandaedre/rcraft_solver"
repository = "https://proxy.dandaedre.com/gitea/Dandaedre/rcraft_solver.git"
homepage = "https://proxy.dandaedre.com/gitea/Dandaedre/xiv_csolver"
documentation = "https://proxy.dandaedre.com/gitea/Dandaedre/xiv_csolver"
repository = "https://proxy.dandaedre.com/gitea/Dandaedre/xiv_csolver.git"
license = "MIT OR Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -39,13 +39,13 @@ no_python = [] # Removes the python bindings
fast = [] # Remove some under optimisations that try to find other routes
[lib]
name = "xiv_craft_solver" # Pending rename ffcraft_solver_lib
name = "xiv_csolver_lib" # Pending rename xiv_csolver_lib
path = "src/lib.rs"
crate-type = ["cdylib","rlib"]
[[bin]]
name = "ffcraft_solver_cli"
path = "src/bin/ffcraft.rs"
name = "xiv_csolver_cli"
path = "src/bin/xiv_csolver.rs"
[tool.maturin]
python-source = "python"

View File

@ -14,8 +14,8 @@ dependencies = [
script_runner="@shell"
ignore_errors = true
script = [
"twine upload releases/ffcraft_solver*.whl --repository gitea",
"twine upload releases/xiv_craft_solver*.whl --repository gitea",
"twine upload releases/xiv_csolver*.whl --repository gitea",
"twine upload releases/xiv_csolver_lib*.whl --repository gitea",
]
[tasks.format]
@ -46,8 +46,8 @@ script_runner = "@shell"
script = '''
mkdir -p releases # Add version as an arg and things
cp target/wheels/*.whl releases/
zip releases/ffcraft_solver_cli.zip -j target/release/ffcraft_solver_cli craft.toml -j target/release/libxiv_craft_solver.so
cd python/dist/ && zip ../../releases/ffcraft_solver_gui.zip -r ffcraft_solver_gui_linux/
zip releases/xiv_csolver_cli_linux.zip -j target/release/xiv_csolver_cli craft.toml -j target/release/libxiv_craft_solver.so
cd python/dist/ && zip ../../releases/xiv_csolver_gui_linux.zip -r xiv_csolver_gui_linux/
'''
[tasks.zip_win]
@ -55,8 +55,8 @@ script_runner = "@shell"
script = '''
mkdir -p releases # Add version as an arg and things
cp target/wheels/*.whl releases/
tar acvf releases/ff_craft_solver_cli_win.zip .\craft.toml -C .\target\release\ ffcraft_solver_cli.exe libxiv_craft_solver.d
tar acvf releases/ff_craft_solver_gui_win.zip -C .\python\dist\ .\ffcraft_solver_gui_win\*
tar acvf releases/xiv_csolver_cli_win.zip .\craft.toml -C .\target\release\ xiv_csolver_cli.exe libxiv_craft_solver.d
tar acvf releases/xiv_csolver_gui_win.zip -C .\python\dist\ .\xiv_csolver_gui_win\*
'''
[tasks.pip]
@ -78,13 +78,14 @@ linux_alias = "linux_pyinstaller"
script_runner = "@shell"
script = '''
cd python
pyinstaller src/ffcraft_solver/__main__.py -i "src/ffcraft_solver/ressources/ffcraft_solver.ico" --add-data "src/ffcraft_solver/configs/:ffcraft_solver/configs" --add-data "src/ffcraft_solver/ressources/:ffcraft_solver/ressources" --name ffcraft_solver_gui_linux -y
pyinstaller src/xiv_csolver/__main__.py -i "src/xiv_csolver/ressources/xiv_csolver.ico" --add-data "src/xiv_csolver/configs/:xiv_csolver/configs" --add-data "src/xiv_csolver/ressources/:xiv_csolver/ressources" --name xiv_csolver_gui_linux -y
'''
[tasks.windows_pyinstaller]
script_runner = "@shell"
script = '''
cd python && pyinstaller src\ffcraft_solver\__main__.py --add-data "src\ffcraft_solver\configs\;ffcraft_solver\configs" --add-data "src\ffcraft_solver\ressources\;ffcraft_solver\ressources" --name ffcraft_solver_gui_win -y
cd python
pyinstaller src\xiv_csolver\__main__.py -i "src/xiv_csolver/ressources/xiv_csolver.ico" --add-data "src\xiv_csolver\configs\;xiv_csolver\configs" --add-data "src\xiv_csolver\ressources\;xiv_csolver\ressources" --name xiv_csolver_gui_win -y
'''
[tasks.build]
@ -100,6 +101,8 @@ args = ["develop", "--release"]
command = "maturin"
args = ["build", "--release"]
[tasks.rebuild]
dependencies = ["clean","build","maturin","pip"]
[tasks.rust]
dependencies = ["build","maturin"]

View File

@ -1,4 +1,4 @@
# xiv_craft_solver
# xiv_csolver
A rust program for solving FFXIV craft recipe.
Originaly written by [RikaKagurasaka](https://github.com/RikaKagurasaka/xiv_craft_solver),
@ -19,7 +19,7 @@ When building the CLI invocation is done with the following parameters
```
Small XIV solver library in rust, with python and rust bindings
Usage: ffcraft [OPTIONS]
Usage: xiv_csolver_cli [OPTIONS]
Options:
-r, --recipe-name <RECIPE_NAME>
@ -44,6 +44,11 @@ Options:
Print version
```
## Developpement
Please remember to set and use a venv before building
While not mandatory, using ``cargo-make`` will provide you with the commands:
- cargo make rebuild (rebuilding both the rust and pip bindings)
- cargo make release (rebuilding and bundling the executables (for your os)) in a releases folder
### Rust
Everything is located in the root & src.
You can build the program (CLI) with cargo build the following features are available
@ -51,8 +56,9 @@ You can build the program (CLI) with cargo build the following features are avai
- The ``no_python`` will not build the lib (WIP, not fully implemented)
- The ``fast`` feature will not allow some under-optimisation to run (saving global run-time)
- The ``verbose`` feature will allow even more debug messages (They might not be shown depending on the verbosity level hoever)
#### Maturin
To build the python module, run ``maturin develop`` or ``maturin build`` then ``maturin install``
To build the python module, run either ``maturin develop`` or ``maturin build`` then ``maturin install``
### Python
#### Developping the GUI
@ -60,10 +66,9 @@ To build the python module, run ``maturin develop`` or ``maturin build`` then ``
1. Go to the ``python`` directory
2. Install the dev dependencies ``pip install -r requirements_dev.txt``
3. Install the project (in editable mode) ``pip install -e .``
4. Invoke the project (from anywhere) ``python -m ffcraft_solver``
4. Invoke the project (from anywhere) ``python -m xiv_csolver``
5. Edit the project and re-invoke it (no need to install / compile again)
#### Rust CLI Example
Note: The recipe data can be retrieved from a [FFXIV Crafting Optimizer](https://yyyy.games/crafter/#/simulator)
with checking of **Custom Recipe** after selecting the recipe.

View File

@ -7,10 +7,11 @@
🟩 (GUI) Update on the Quality %
🟩 (GUI) Ability to save
✅ (GUI) Make the logging work
🟩 (PKG) Rename libs, bin, python, exe
✅ (PKG) Rename libs, bin, python, exe
### Important
✅ (PKG) Have cargo-make setup for release/cleanup/build
✅ (PKG) Merge latest pre-release for the GUI
✅ (PKG) Have a rebuild function
### Features
🟩 (GUI) Refactor code

View File

@ -3,7 +3,7 @@ requires = ["maturin>=0.14,<0.15"]
build-backend = "maturin"
[project] # The rust bindings
name = "xiv_craft_solver"
name = "xiv_csolver_lib"
requires-python = ">=3.7"
version = "0.1.5"
classifiers = [

View File

@ -8,8 +8,8 @@ classifiers =
[options]
packages =
ffcraft_solver
ffcraft_solver.modules
xiv_csolver
xiv_csolver.modules
install_requires =
pyyaml>=6.0
python_requires = >=3.9
@ -21,7 +21,7 @@ zip_safe = no
[options.packages.find]
where =
= src
= src/ffcraft_solver
= src/xiv_csolver
[options.extras_require]
testing =

View File

@ -3,7 +3,7 @@ requires = ["setuptools>=42.0", "wheel"]
build-backend = "setuptools.build_meta"
[project] # The Python GUI
name = "ffcraft_solver"
name = "xiv_csolver"
authors = [
{name="Vkyfox"},
{name="Dandaedre"},
@ -18,7 +18,7 @@ classifiers = [
]
[tool.pytest.ini_options]
addopts = "--cov=ffcraft_solver"
addopts = "--cov=xiv_csolver"
testpaths = [
"tests",
]

View File

@ -1,4 +1,4 @@
"""
A rust program for solving FFXIV craft recipe.
- ffcraft_solver
- xiv_csolver
"""

View File

@ -1,7 +1,7 @@
import time
import dearpygui.dearpygui as dpg
from ffcraft_solver.modules import loader, log, solver
from xiv_csolver.modules import loader, log, solver
import rich

View File

@ -1,10 +1,10 @@
import xiv_craft_solver
import xiv_csolver_lib
import rich
rich.inspect(xiv_craft_solver)
rich.inspect(xiv_craft_solver.test_result)
rich.inspect(xiv_craft_solver.test_result())
rich.inspect(xiv_craft_solver.test_result())
rich.inspect(xiv_csolver_lib)
rich.inspect(xiv_csolver_lib.test_result)
rich.inspect(xiv_csolver_lib.test_result())
rich.inspect(xiv_csolver_lib.test_result())
class FeedMeDaddy:
@ -28,5 +28,5 @@ class FeedMeDaddy:
el_daddy = FeedMeDaddy()
rich.inspect(xiv_craft_solver.solve_from_python(el_daddy))
rich.inspect(xiv_csolver_lib.solve_from_python(el_daddy))

View File

@ -1,6 +1,6 @@
import yaml
import os
from ffcraft_solver.modules import log
from xiv_csolver.modules import log
class DefaultConfig:

View File

@ -1,7 +1,7 @@
import rich
import xiv_craft_solver as xcs
from ffcraft_solver.__main__ import User, Recipe
from ffcraft_solver.modules import log, translator
import xiv_csolver_lib as xcs
from xiv_csolver.__main__ import User, Recipe
from xiv_csolver.modules import log, translator
class Result:

View File

@ -1,4 +1,4 @@
from ffcraft_solver.modules import log
from xiv_csolver.modules import log
loggers = log.Loggers

View File

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 248 KiB

View File

Before

Width:  |  Height:  |  Size: 352 KiB

After

Width:  |  Height:  |  Size: 352 KiB

View File

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 248 KiB

View File

Before

Width:  |  Height:  |  Size: 352 KiB

After

Width:  |  Height:  |  Size: 352 KiB

View File

@ -1,29 +0,0 @@
[tox]
minversion = 3.8.0
envlist = py37, py38, py39, flake8, mypy
isolated_build = true
[gh-actions]
python =
3.7: py36, mypy, flake8
3.8: py38
3.9: py39
[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps =
-r{toxinidir}/requirements_dev.txt
commands =
pytest --basetemp={envtmpdir}
[testenv:flake8]
basepython = python3.10
deps = flake8
commands = flake8 src tests
[testenv:mypy]
basepython = python3.10
deps =
-r{toxinidir}/requirements_dev.txt
commands = mypy src

View File

@ -1,26 +1,24 @@
// #![warn(missing_docs,unsafe_code,unstable_features,)]
use clap::Parser;
use std::time::Instant;
use xiv_craft_solver;
use xiv_csolver_lib;
#[derive(Debug)]
struct CustomError(String);
fn main() {
let args = xiv_craft_solver::io::Args::parse();
let params = xiv_craft_solver::io::Parameters::from_args(&args);
let args = xiv_csolver_lib::io::Args::parse();
let params = xiv_csolver_lib::io::Parameters::from_args(&args);
// Start timer
let now = Instant::now();
println!("Solving...");
// Solve from config
let (recipe, stats) = xiv_craft_solver::load_from_config(
&args.recipe_name,
&args.file_name,
&args.character_name,
);
let results = xiv_craft_solver::solve_craft(recipe, stats, params);
let (recipe, stats) =
xiv_csolver_lib::load_from_config(&args.recipe_name, &args.file_name, &args.character_name);
let results = xiv_csolver_lib::solve_craft(recipe, stats, params);
// Stop timer
let t_final = now.elapsed().as_millis();
@ -40,21 +38,21 @@ fn main() {
println!("[Final] {} results were found:", res.len());
#[cfg(feature = "verbose")]
if args.verbose > 1 {
xiv_craft_solver::print_routes(&results);
xiv_csolver_lib::print_routes(&results);
}
}
}
}
println!("\n > SOLUTION [Least steps] <");
xiv_craft_solver::find_fast_route(&results)
xiv_csolver_lib::find_fast_route(&results)
.unwrap()
.pretty_print();
println!("\n > SOLUTION [Most durability] <");
xiv_craft_solver::find_safe_route(&results)
xiv_csolver_lib::find_safe_route(&results)
.unwrap()
.pretty_print();
println!("\n > SOLUTION [Most quality] < ");
xiv_craft_solver::find_quality_route(&results)
xiv_csolver_lib::find_quality_route(&results)
.unwrap()
.pretty_print();

View File

@ -2,7 +2,7 @@ use crate::Craft;
use clap::Parser;
use core::fmt::Display;
#[cfg(not(feature = "no_python"))]
// #[cfg(not(feature = "no_python"))]
use pyo3::prelude::*;
#[derive(Debug, Clone, Copy)]
@ -187,7 +187,7 @@ impl Parameters {
/// A Python module implemented in Rust.
#[cfg(not(feature = "no_python"))]
#[pymodule]
fn xiv_craft_solver(_py: Python, m: &PyModule) -> PyResult<()> {
fn xiv_csolver_lib(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(test_result, m)?)?;
m.add_function(wrap_pyfunction!(solve_from_python, m)?)?;
Ok(())