mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2025-04-20 11:59:53 +08:00
Compare commits
4 Commits
0ef4aeb4f3
...
d246913b4c
Author | SHA1 | Date | |
---|---|---|---|
d246913b4c | |||
aa641b4b82 | |||
e14ffbddb4 | |||
1b5c33c1d5 |
43
.github/workflows/builds.yml
vendored
Normal file
43
.github/workflows/builds.yml
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
name: build and test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 获取版本号
|
||||||
|
id: get_version
|
||||||
|
uses: sravinet/toml-select@v1.0.1
|
||||||
|
with:
|
||||||
|
file: ./ica-rs/Cargo.toml
|
||||||
|
field: "package.version"
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v5.0.0
|
||||||
|
with:
|
||||||
|
# Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset.
|
||||||
|
python-version: 3.8
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: cargo test --verbose
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cargo build --release
|
||||||
|
|
||||||
|
- name: 上传
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: ica-rs-b${{ github.run_number }}-${{ steps.get_version.outputs.value }}-py38-win-x64
|
||||||
|
path: ./target/release/ica-rs.exe
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -6,3 +6,8 @@ config.toml
|
||||||
*.pyc
|
*.pyc
|
||||||
*__pycache__/
|
*__pycache__/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Added by cargo
|
||||||
|
|
||||||
|
/target
|
||||||
|
|
2146
Cargo.lock
generated
Normal file
2146
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"ica-rs"
|
||||||
|
]
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
rust_socketio = { git = "https://github.com/shenjackyuanjie/rust-socketio.git", branch = "mult_payload" }
|
||||||
|
# pyo3 = { git = "https://github.com/PyO3/pyo3.git", branch = "main" }
|
|
@ -25,7 +25,3 @@ pyo3-asyncio = { version = "0.20.0", features = ["attributes", "tokio-runtime"]
|
||||||
|
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["time"] }
|
tracing-subscriber = { version = "0.3.18", features = ["time"] }
|
||||||
|
|
||||||
[patch.crates-io]
|
|
||||||
rust_socketio = { git = "https://github.com/shenjackyuanjie/rust-socketio.git", branch = "mult_payload" }
|
|
||||||
# pyo3 = { git = "https://github.com/PyO3/pyo3.git", branch = "main" }
|
|
||||||
|
|
|
@ -141,6 +141,20 @@ pub fn get_change_time(path: &PathBuf) -> Option<SystemTime> {
|
||||||
path.metadata().ok()?.modified().ok()
|
path.metadata().ok()?.modified().ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn py_module_from_code(content: &str, path: &str) -> PyResult<Py<PyAny>> {
|
||||||
|
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
|
||||||
|
let module: PyResult<Py<PyAny>> = PyModule::from_code(
|
||||||
|
py,
|
||||||
|
&content,
|
||||||
|
&path,
|
||||||
|
&path,
|
||||||
|
// !!!! 请注意, 一定要给他一个名字, cpython 会自动把后面的重名模块覆盖掉前面的
|
||||||
|
)
|
||||||
|
.map(|module| module.into());
|
||||||
|
module
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// 传入文件路径
|
/// 传入文件路径
|
||||||
/// 返回 hash 和 文件内容
|
/// 返回 hash 和 文件内容
|
||||||
pub fn load_py_file(path: &PathBuf) -> std::io::Result<(Option<SystemTime>, String)> {
|
pub fn load_py_file(path: &PathBuf) -> std::io::Result<(Option<SystemTime>, String)> {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user