From e14dbf66dc97633b7bca710df2e8cd05eaf4589c Mon Sep 17 00:00:00 2001 From: Wiktor Mazur Date: Sun, 20 Oct 2019 14:59:45 +0200 Subject: [PATCH] Repository cleanup --- .gitignore | 11 ++- README.md | 55 ++++++------ appveyor.yml | 26 +++--- Cargo.lock => backend/Cargo.lock | 88 +++++++++++++------ Cargo.toml => backend/Cargo.toml | 4 +- backend/aostats/__init__.py | 1 + .../lib}/packet-sniffer/Cargo.toml | 0 .../lib}/packet-sniffer/src/lib.rs | 0 .../lib}/photon-protocol/Cargo.lock | 0 .../lib}/photon-protocol/Cargo.toml | 0 .../lib}/photon-protocol/src/lib.rs | 0 .../lib}/photon-protocol/src/types.rs | 0 backend/setup.py | 30 +++++++ {src => backend/src}/core.rs | 0 {src => backend/src}/game_protocol/message.rs | 0 {src => backend/src}/game_protocol/mod.rs | 0 {src => backend/src}/game_protocol/packet.rs | 0 .../src}/game_protocol/protocol.rs | 0 {src => backend/src}/lib.rs | 3 +- {src => backend/src}/meter/mod.rs | 0 {src => backend/src}/meter/player.rs | 0 {src => backend/src}/meter/traits.rs | 0 {src => backend/src}/meter/types.rs | 0 frontend/aostats.py | 3 + {gui => frontend}/requirements.txt | 3 +- frontend/src/__init__.py | 2 + {gui => frontend}/src/about.py | 0 gui/src/meter.py => frontend/src/app.py | 21 +++-- {gui => frontend}/src/config.py | 0 {gui => frontend}/src/engine.py | 21 ++--- {gui => frontend}/src/main.py | 6 +- {gui => frontend}/src/styling.py | 2 +- {gui => frontend}/src/table.py | 0 {gui => frontend}/src/version.py | 0 gui/albion-stats | 3 - requirements.txt | 3 - 36 files changed, 180 insertions(+), 102 deletions(-) rename Cargo.lock => backend/Cargo.lock (94%) rename Cargo.toml => backend/Cargo.toml (93%) create mode 100644 backend/aostats/__init__.py rename {lib => backend/lib}/packet-sniffer/Cargo.toml (100%) rename {lib => backend/lib}/packet-sniffer/src/lib.rs (100%) rename {lib => backend/lib}/photon-protocol/Cargo.lock (100%) rename {lib => backend/lib}/photon-protocol/Cargo.toml (100%) rename {lib => backend/lib}/photon-protocol/src/lib.rs (100%) rename {lib => backend/lib}/photon-protocol/src/types.rs (100%) create mode 100644 backend/setup.py rename {src => backend/src}/core.rs (100%) rename {src => backend/src}/game_protocol/message.rs (100%) rename {src => backend/src}/game_protocol/mod.rs (100%) rename {src => backend/src}/game_protocol/packet.rs (100%) rename {src => backend/src}/game_protocol/protocol.rs (100%) rename {src => backend/src}/lib.rs (98%) rename {src => backend/src}/meter/mod.rs (100%) rename {src => backend/src}/meter/player.rs (100%) rename {src => backend/src}/meter/traits.rs (100%) rename {src => backend/src}/meter/types.rs (100%) create mode 100644 frontend/aostats.py rename {gui => frontend}/requirements.txt (66%) create mode 100644 frontend/src/__init__.py rename {gui => frontend}/src/about.py (100%) rename gui/src/meter.py => frontend/src/app.py (73%) rename {gui => frontend}/src/config.py (100%) rename {gui => frontend}/src/engine.py (87%) rename {gui => frontend}/src/main.py (98%) rename {gui => frontend}/src/styling.py (89%) rename {gui => frontend}/src/table.py (100%) rename {gui => frontend}/src/version.py (100%) delete mode 100755 gui/albion-stats delete mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index fff75c5..bf35d73 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,14 @@ lib/**/target damage-meter.log *.so .vscode + + +# Python +*.spec +env +**/build +**/dist +**/*.egg-info +*.egg __pycache__ -albion-online-stats.cfg \ No newline at end of file +albion-online-stats.cfg diff --git a/README.md b/README.md index b4a2d19..3331371 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@

+Project Badge Albion Online Stats =================== @@ -21,6 +22,8 @@ Albion online stats is an extension to MMORPG game - Albion Online. It tracks ne # Usage of built release +> **Note** this section does not require any coding knowledge. Those simple two steps are required to use this software :) + ## Installation 1. On windows make sure that WinPcap is installed in your system. [Npcap 0.9983 installer for Windows Vista/2008, 7/2008R2, 8/2012, 8.1/2012R2, 10/2016 (x86 and x64)](https://nmap.org/npcap/dist/npcap-0.9983.exe) @@ -39,45 +42,39 @@ After first execution the app is going to create default configuration file name - Python installed - *Windows only prerequisites* https://github.com/libpnet/libpnet#windows + ## All platforms 1. Clone repository: ```shell git clone https://github.com/mazurwiktor/albion-online-stats.git ``` -2. Build rust library +2. [optional] Create and activate python virtualenv ```shell - cargo build --release + python -m venv env + [linux/mac] . env/bin/activate + [windows] .\env\Scripts\activate.ps1 + ``` + +3. Install requirements (backend will be compiled during requirements installation) + + ```shell + pip install -v -r frontend/requirements.txt + ``` + +4. Run the application + ```shell + [sudo on linux] python frontend/aostats.py + ``` + +## GUI testing +- Seting TESTING variable runs frontend without backend dependency + + ```shell + TESTING=true python frontend/aostats.py ``` -3. Copy library to GUI directory - - 3.1 on Linux - - ```shell - cp target/release/libmeter.so gui/ - ``` - - 3.1 on Windows - - ```shell - cp target/release/meter.dll gui/libmeter.pyd - ``` - -4. Run GUI - - 3.1 on Linux - - ```shell - sudo python gui/meter.py - ``` - - 3.1 on Windows - - ```shell - python gui/meter.py - ``` # License diff --git a/appveyor.yml b/appveyor.yml index 575203c..5093085 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,15 +6,18 @@ environment: RUST_CHANNEL: beta WPD_LIB_PATH: "C:/dl/wpdpack/WpdPack/Lib/x64/Packet.lib" PYTHON: "C:\\Python36-x64" + PYTHON_LIB: "C:\\Python36-x64\\libs\\python36.lib" PYTHON_ARCH: "64" VCVARS: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\vcvars64.bat" install: + - ps: ls C:\\Python36-x64 - SET PATH=%PYTHON%;%path% - ps: mkdir C:/dl - curl -o "C:/dl/wpd.zip" "https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip" - ps: Add-Type -AssemblyName system.io.compression.filesystem - ps: "[io.compression.zipfile]::ExtractToDirectory(\"C:/dl/wpd.zip\", \"C:/dl/wpdpack\")" - ps: cp ${env:WPD_LIB_PATH} "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" + - ps: cp ${env:PYTHON_LIB} "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:RUST_CHANNEL}-${env:TARGET}.exe" - rust-%RUST_CHANNEL%-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - CALL "%VCVARS%" @@ -22,21 +25,20 @@ install: - choco install winpcap - rustc -V - cargo -V -test: false +test: true +test_script: + - ps: cd backend + - cargo test + - ps: cd .. build_script: - - cargo build --release --verbose + - python -m venv env + - ps: .\env\Scripts\activate.ps1 + - pip install -v -r frontend\requirements.txt + - pyinstaller -F -w -i assets\albion-stats-icon.ico frontend\aostats.py + - ps: deactivate after_build: -- ps: cd ${env:APPVEYOR_BUILD_FOLDER}/gui -- python -m venv env -- ps: .\env\Scripts\activate.ps1 -- pip install -r requirements.txt -- ps: cd src -- ps: cp ${env:APPVEYOR_BUILD_FOLDER}\target\release\meter.dll libmeter.pyd -- pyinstaller -F -w -i ..\..\assets\albion-stats-icon.ico meter.py -- ps: deactivate -- ps: mv dist\meter.exe ..\..\albion-online-stats.exe +- ps: mv dist\aostats.exe albion-online-stats.exe - ps: ls -- ps: ls ..\ artifacts: path: albion-online-stats.exe name: binary diff --git a/Cargo.lock b/backend/Cargo.lock similarity index 94% rename from Cargo.lock rename to backend/Cargo.lock index 2c9f8cc..bdd37d2 100644 --- a/Cargo.lock +++ b/backend/Cargo.lock @@ -8,6 +8,30 @@ dependencies = [ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "aho-corasick" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aostats" +version = "0.1.0" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cpython 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fake_clock 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "packet_sniffer 0.1.0", + "photon_protocol 0.1.0", + "simplelog 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "timer 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "arrayref" version = "0.3.5" @@ -332,22 +356,6 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "meter" -version = "0.1.0" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cpython 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fake_clock 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "packet_sniffer 0.1.0", - "photon_protocol 0.1.0", - "simplelog 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "timer 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nodrop" version = "0.1.13" @@ -474,10 +482,10 @@ dependencies = [ [[package]] name = "pnet_macros" -version = "0.22.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.42.2 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -497,7 +505,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "pnet_base 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pnet_macros 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pnet_macros 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "pnet_macros_support 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.42.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -537,7 +545,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.61 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -612,19 +620,38 @@ dependencies = [ [[package]] name = "regex" -version = "1.0.6" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex-syntax" -version = "0.6.11" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -814,6 +841,11 @@ dependencies = [ "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ucd-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-xid" version = "0.0.3" @@ -869,6 +901,7 @@ dependencies = [ [metadata] "checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" +"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" @@ -922,7 +955,7 @@ dependencies = [ "checksum pnet 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63d693c84430248366146e3181ff9d330243464fa9e6146c372b2f3eb2e2d8e7" "checksum pnet_base 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4df28acf2fcc77436dd2b91a9a0c2bb617f9ca5f2acefee1a4135058b9f9801f" "checksum pnet_datalink 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b34f8ca857599d05b6b082e9baff8d27c54cb9c26568cf3c0993a5755816966" -"checksum pnet_macros 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f16d1fa7fd0edebc36055587b8b5af8a109bbc29a55fb484a37e2029b971a7" +"checksum pnet_macros 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d228096fd739d4e3e60dee9e1e4f07d9ae0f3f309c876834192538748e561e4" "checksum pnet_macros_support 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "84684f2cddefc37a06f2fe2ca4dcc3457fc3b282734b5246507d8ee75d2780ae" "checksum pnet_packet 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a6cdcdaddc5174f18286298842a4e31cd3cc018933d42af51434b1fa07dcbe" "checksum pnet_sys 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "682b2eca84cc440bce8336813f78eb6d3cb0fed89fe0e87ae22acfca8363f176" @@ -937,8 +970,10 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" -"checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" -"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" +"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" +"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" +"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" +"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" "checksum rust-argon2 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81ed8d04228b44a740c8d46ff872a28e50fff3d659f307ab4da2cc502e019ff3" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" @@ -962,6 +997,7 @@ dependencies = [ "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum timer 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a9522a9ec40055e2f9e514e38d2415a496e81dbfc1ece15d98d2fe55c44946b3" +"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" "checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" diff --git a/Cargo.toml b/backend/Cargo.toml similarity index 93% rename from Cargo.toml rename to backend/Cargo.toml index ac6b78a..7fde997 100644 --- a/Cargo.toml +++ b/backend/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "meter" +name = "libaostats" version = "0.1.0" authors = ["Wiktor Mazur "] edition = "2018" @@ -7,7 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -name = "meter" +name = "libaostats" crate-type = ["dylib"] [dependencies.cpython] diff --git a/backend/aostats/__init__.py b/backend/aostats/__init__.py new file mode 100644 index 0000000..3832a76 --- /dev/null +++ b/backend/aostats/__init__.py @@ -0,0 +1 @@ +from libaostats import * diff --git a/lib/packet-sniffer/Cargo.toml b/backend/lib/packet-sniffer/Cargo.toml similarity index 100% rename from lib/packet-sniffer/Cargo.toml rename to backend/lib/packet-sniffer/Cargo.toml diff --git a/lib/packet-sniffer/src/lib.rs b/backend/lib/packet-sniffer/src/lib.rs similarity index 100% rename from lib/packet-sniffer/src/lib.rs rename to backend/lib/packet-sniffer/src/lib.rs diff --git a/lib/photon-protocol/Cargo.lock b/backend/lib/photon-protocol/Cargo.lock similarity index 100% rename from lib/photon-protocol/Cargo.lock rename to backend/lib/photon-protocol/Cargo.lock diff --git a/lib/photon-protocol/Cargo.toml b/backend/lib/photon-protocol/Cargo.toml similarity index 100% rename from lib/photon-protocol/Cargo.toml rename to backend/lib/photon-protocol/Cargo.toml diff --git a/lib/photon-protocol/src/lib.rs b/backend/lib/photon-protocol/src/lib.rs similarity index 100% rename from lib/photon-protocol/src/lib.rs rename to backend/lib/photon-protocol/src/lib.rs diff --git a/lib/photon-protocol/src/types.rs b/backend/lib/photon-protocol/src/types.rs similarity index 100% rename from lib/photon-protocol/src/types.rs rename to backend/lib/photon-protocol/src/types.rs diff --git a/backend/setup.py b/backend/setup.py new file mode 100644 index 0000000..3d55965 --- /dev/null +++ b/backend/setup.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +import sys + + +from setuptools import setup + +try: + from setuptools_rust import RustExtension, Binding +except ImportError: + import subprocess + + errno = subprocess.call([sys.executable, "-m", "pip", "install", "setuptools-rust"]) + if errno: + print("Please install setuptools-rust package") + raise SystemExit(errno) + else: + from setuptools_rust import RustExtension, Binding + +setup_requires = ["setuptools-rust>=0.10.1", "wheel"] +install_requires = [] + +setup( + name="aostats", + packages=["aostats"], + rust_extensions=[RustExtension("libaostats", 'Cargo.toml', binding=Binding.RustCPython)], + install_requires=install_requires, + setup_requires=setup_requires, + include_package_data=True, + zip_safe=False, +) \ No newline at end of file diff --git a/src/core.rs b/backend/src/core.rs similarity index 100% rename from src/core.rs rename to backend/src/core.rs diff --git a/src/game_protocol/message.rs b/backend/src/game_protocol/message.rs similarity index 100% rename from src/game_protocol/message.rs rename to backend/src/game_protocol/message.rs diff --git a/src/game_protocol/mod.rs b/backend/src/game_protocol/mod.rs similarity index 100% rename from src/game_protocol/mod.rs rename to backend/src/game_protocol/mod.rs diff --git a/src/game_protocol/packet.rs b/backend/src/game_protocol/packet.rs similarity index 100% rename from src/game_protocol/packet.rs rename to backend/src/game_protocol/packet.rs diff --git a/src/game_protocol/protocol.rs b/backend/src/game_protocol/protocol.rs similarity index 100% rename from src/game_protocol/protocol.rs rename to backend/src/game_protocol/protocol.rs diff --git a/src/lib.rs b/backend/src/lib.rs similarity index 98% rename from src/lib.rs rename to backend/src/lib.rs index 82ceca6..59f58da 100644 --- a/src/lib.rs +++ b/backend/src/lib.rs @@ -160,8 +160,7 @@ fn initialize(_py: Python, skip_non_party_members: bool) -> PyResult { Ok(0) } - -py_module_initializer!(libmeter, initliblibmeter, PyInit_libmeter, |py, m| { +py_module_initializer!(libaostats, initlibaostats, PyInit_libaostats, |py, m| { m.add(py, "__doc__", "This module is implemented in Rust")?; m.add(py, "initialize", py_fn!(py, initialize(skip_non_party_members: bool)))?; m.add(py, "stats", py_fn!(py, stats(stat_type: StatType)))?; diff --git a/src/meter/mod.rs b/backend/src/meter/mod.rs similarity index 100% rename from src/meter/mod.rs rename to backend/src/meter/mod.rs diff --git a/src/meter/player.rs b/backend/src/meter/player.rs similarity index 100% rename from src/meter/player.rs rename to backend/src/meter/player.rs diff --git a/src/meter/traits.rs b/backend/src/meter/traits.rs similarity index 100% rename from src/meter/traits.rs rename to backend/src/meter/traits.rs diff --git a/src/meter/types.rs b/backend/src/meter/types.rs similarity index 100% rename from src/meter/types.rs rename to backend/src/meter/types.rs diff --git a/frontend/aostats.py b/frontend/aostats.py new file mode 100644 index 0000000..ec408f2 --- /dev/null +++ b/frontend/aostats.py @@ -0,0 +1,3 @@ +if __name__ == "__main__": + from src import run + run() \ No newline at end of file diff --git a/gui/requirements.txt b/frontend/requirements.txt similarity index 66% rename from gui/requirements.txt rename to frontend/requirements.txt index 52884d1..0548439 100644 --- a/gui/requirements.txt +++ b/frontend/requirements.txt @@ -2,4 +2,5 @@ pyside2~=5.13 pyinstaller clipboard toml~=0.10 -requests~=2.22 \ No newline at end of file +requests~=2.22 +./backend \ No newline at end of file diff --git a/frontend/src/__init__.py b/frontend/src/__init__.py new file mode 100644 index 0000000..3193130 --- /dev/null +++ b/frontend/src/__init__.py @@ -0,0 +1,2 @@ +from .app import run + diff --git a/gui/src/about.py b/frontend/src/about.py similarity index 100% rename from gui/src/about.py rename to frontend/src/about.py diff --git a/gui/src/meter.py b/frontend/src/app.py similarity index 73% rename from gui/src/meter.py rename to frontend/src/app.py index 97e9bdc..691e9a1 100644 --- a/gui/src/meter.py +++ b/frontend/src/app.py @@ -1,18 +1,21 @@ import sys +import os + +sys.path.append(os.path.dirname(os.path.abspath('__file__'))) from PySide2.QtCore import Qt from PySide2.QtWidgets import QApplication from PySide2.QtWidgets import QMessageBox -import libmeter +from .config import config +from .main import MainWidget +from .engine import initialize +from .styling import style +from .version import current_version as get_current_version +from .version import latest_version as get_latest_version +from .version import latest_url -from config import config -from main import MainWidget -from engine import initialize -from styling import style -from version import current_version, latest_version, latest_url - -if __name__ == "__main__": +def run(): initialize() conf = config() window_config = conf['window'] @@ -37,7 +40,7 @@ if __name__ == "__main__": widget.setWindowFlag(Qt.FramelessWindowHint) widget.show() - current_version, latest_version = (current_version(), latest_version()) + current_version, latest_version = (get_current_version(), get_latest_version()) if latest_version and current_version != latest_version: msg = QMessageBox() diff --git a/gui/src/config.py b/frontend/src/config.py similarity index 100% rename from gui/src/config.py rename to frontend/src/config.py diff --git a/gui/src/engine.py b/frontend/src/engine.py similarity index 87% rename from gui/src/engine.py rename to frontend/src/engine.py index 848f526..b4a4178 100644 --- a/gui/src/engine.py +++ b/frontend/src/engine.py @@ -1,7 +1,8 @@ import os -import libmeter -from config import config +import aostats + +from .config import config TESTING_ENABLED = bool(os.getenv('TESTING')) @@ -67,7 +68,7 @@ def zone_stats(): {'player': 'D'*20, 'damage': 0, 'time_in_combat': 12.0, 'dps': 0} ] else: - session = libmeter.stats(StatType.Zone) + session = aostats.stats(StatType.Zone) return stats(session) @@ -79,7 +80,7 @@ def overall_stats(): 'time_in_combat': 12.0, 'dps': 12.4234}, ] else: - session = libmeter.stats(StatType.Overall) + session = aostats.stats(StatType.Overall) return stats(session) @@ -91,7 +92,7 @@ def last_fight_stats(): 'time_in_combat': 12.0, 'dps': 12.4234}, ] else: - session = libmeter.stats(StatType.LastFight) + session = aostats.stats(StatType.LastFight) return stats(session) @@ -99,23 +100,23 @@ def get_party_members(): if TESTING_ENABLED: return ['a', 'b', 'c'] else: - return libmeter.get_players_in_party() + return aostats.get_players_in_party() def reset_zone_stats(): - libmeter.reset(StatType.Zone) + aostats.reset(StatType.Zone) def reset_last_fight_stats(): - libmeter.reset(StatType.LastFight) + aostats.reset(StatType.LastFight) def reset_stats(): - libmeter.reset(StatType.Overall) + aostats.reset(StatType.Overall) def initialize(): if TESTING_ENABLED: return cfg = config() try: - libmeter.initialize(cfg['app']['skip_non_party_players']) + aostats.initialize(cfg['app']['skip_non_party_players']) except: pass diff --git a/gui/src/main.py b/frontend/src/main.py similarity index 98% rename from gui/src/main.py rename to frontend/src/main.py index a49c727..a03d20e 100644 --- a/gui/src/main.py +++ b/frontend/src/main.py @@ -12,9 +12,9 @@ from PySide2.QtWidgets import QComboBox import clipboard -from table import Table -import about -import engine +from .table import Table +from . import about +from . import engine class Mode: CURRENT_ZONE = 'Statistics: Current zone' diff --git a/gui/src/styling.py b/frontend/src/styling.py similarity index 89% rename from gui/src/styling.py rename to frontend/src/styling.py index 5f4f2bd..2a5e12f 100644 --- a/gui/src/styling.py +++ b/frontend/src/styling.py @@ -1,4 +1,4 @@ -from config import config +from .config import config cfg = config() font_size = cfg['window']['font-size'] diff --git a/gui/src/table.py b/frontend/src/table.py similarity index 100% rename from gui/src/table.py rename to frontend/src/table.py diff --git a/gui/src/version.py b/frontend/src/version.py similarity index 100% rename from gui/src/version.py rename to frontend/src/version.py diff --git a/gui/albion-stats b/gui/albion-stats deleted file mode 100755 index 0e15859..0000000 --- a/gui/albion-stats +++ /dev/null @@ -1,3 +0,0 @@ -#/bin/bash - -python $(dirname "$0")/src/meter.py \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d92a12a..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pyside2~=5.13 -pyinstaller -clipboard \ No newline at end of file