Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work to update dict finder #22

Merged
merged 44 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
02c5857
Finished expand_dir_wildcards
tgross35 Aug 26, 2022
c610479
Merge remote-tracking branch 'origin/main' into dict-locator
tgross35 Aug 26, 2022
fca5274
Compiling but untested find_dict_from_path done
tgross35 Aug 26, 2022
8ac44ba
Updates for clippy
tgross35 Aug 26, 2022
98179e0
Small test clippy fixes
tgross35 Aug 26, 2022
d320b21
Further clippy tweaks
tgross35 Aug 26, 2022
3824f99
Fix find -> filter
tgross35 Aug 26, 2022
3b4fc02
Copy to clone
tgross35 Aug 26, 2022
4d357e5
Added test for find_dict_from_path
tgross35 Aug 27, 2022
663e1f6
Project restructuring; move CLI to separate crate
tgross35 Aug 27, 2022
6a918d7
Update github workflow
tgross35 Aug 27, 2022
9d5bfd3
Run tests with backtrace
tgross35 Aug 27, 2022
c84406e
Rename zspell_cli binary
tgross35 Aug 27, 2022
93abe6b
Work on downloader
tgross35 Aug 29, 2022
8036db3
Further work on downloader
tgross35 Aug 29, 2022
79f557c
Successful download mock test working
tgross35 Aug 29, 2022
119611e
Work further on downloader
tgross35 Aug 30, 2022
280369f
Hashsum corrections
tgross35 Aug 30, 2022
de93ec4
Update progress bar, test passing but needs more
tgross35 Aug 30, 2022
faec708
Remove unwrap_or_ret_err
tgross35 Sep 4, 2022
a63879d
Finished expand_dir_wildcards
tgross35 Aug 26, 2022
fd9ebed
Compiling but untested find_dict_from_path done
tgross35 Aug 26, 2022
bf40475
Updates for clippy
tgross35 Aug 26, 2022
365ab76
Small test clippy fixes
tgross35 Aug 26, 2022
51944ff
Further clippy tweaks
tgross35 Aug 26, 2022
8300376
Fix find -> filter
tgross35 Aug 26, 2022
c4c825f
Copy to clone
tgross35 Aug 26, 2022
d81936a
Added test for find_dict_from_path
tgross35 Aug 27, 2022
dcfef40
Project restructuring; move CLI to separate crate
tgross35 Aug 27, 2022
08260a5
Update github workflow
tgross35 Aug 27, 2022
71875b8
Run tests with backtrace
tgross35 Aug 27, 2022
228a1af
Rename zspell_cli binary
tgross35 Aug 27, 2022
040932b
Work on downloader
tgross35 Aug 29, 2022
d43fbaa
Further work on downloader
tgross35 Aug 29, 2022
ad310a0
Successful download mock test working
tgross35 Aug 29, 2022
070fced
Work further on downloader
tgross35 Aug 30, 2022
4c4ee83
Hashsum corrections
tgross35 Aug 30, 2022
9354628
Update progress bar, test passing but needs more
tgross35 Aug 30, 2022
c2b1d25
Remove unwrap_or_ret_err
tgross35 Sep 4, 2022
6286671
Update debug symbol stripping
tgross35 Nov 4, 2022
517936f
Merge branch 'dict-locator' of github.com:pluots/zspell into dict-loc…
tgross35 Nov 4, 2022
d03ac15
Rename zspell_cli and zspell_py to zspell-cli and zspell-py
tgross35 Nov 4, 2022
00946a4
Updates to fix clippy
tgross35 Nov 4, 2022
1915300
Skip download test, clarify that the module is unimplemented
tgross35 Nov 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/release-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
manylinux: auto
command: build
# container default is manylinux
args: --release -o dist --manifest-path crates/zspell_py/Cargo.toml
args: --release -o dist --manifest-path crates/zspell-py/Cargo.toml
- name: Build musl wheels
uses: messense/maturin-action@v1
with:
target: x86_64-unknown-linux-musl
manylinux: musllinux_1_1
command: build
args: --release -o dist -i 3.7 3.8 3.9 3.10 --manifest-path crates/zspell_py/Cargo.toml
args: --release -o dist -i 3.7 3.8 3.9 3.10 --manifest-path crates/zspell-py/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand All @@ -37,7 +37,7 @@ jobs:
- uses: messense/maturin-action@v1
with:
command: build
args: --release --no-sdist -o dist --manifest-path crates/zspell_py/Cargo.toml
args: --release --no-sdist -o dist --manifest-path crates/zspell-py/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand All @@ -51,7 +51,7 @@ jobs:
- uses: messense/maturin-action@v1
with:
command: build
args: --release --no-sdist -o dist --universal2 --manifest-path crates/zspell_py/Cargo.toml
args: --release --no-sdist -o dist --universal2 --manifest-path crates/zspell-py/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down
18 changes: 3 additions & 15 deletions .github/workflows/release-rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,8 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: build
# We only want to build zspell, not zspell_py (does not support cdylib)
args: --package zspell --release --verbose --target ${{ matrix.target }}
# Remove debug symbols
- name: Strip release binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/zspell"
# Remove debug symbols
- name: Strip release binary (arm)
if: matrix.build == 'linux-arm'
run: >
docker run --rm -v
"$PWD/target:/target:Z"
rustembedded/cross:arm-unknown-linux-gnueabihf
arm-linux-gnueabihf-strip
/target/arm-unknown-linux-gnueabihf/release/zspell
# We only want to build zspell-cli, not plain zspell or zspell-py (does not support cdylib)
args: --package zspell-cli --release --verbose --target ${{ matrix.target }}
# Create .zip or .tar.gz file
- name: Build archive
shell: bash
Expand All @@ -97,6 +84,7 @@ jobs:

# outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")"
# outdir=target/release/${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}${{ matrix.extension }}
# Find the output directory with the latest timestamp
cargo_outdir="$(find "${{ env.TARGET_DIR }}" -name zspell-stamp -print0 | xargs -0 ls -t | head -n1 | xargs dirname)"
ref_name=${GITHUB_REF##*/}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validation-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
manylinux: auto
command: build
# container default is manylinux
args: --release -o dist --manifest-path crates/zspell_py/Cargo.toml
args: --release -o dist --manifest-path crates/zspell-py/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand All @@ -30,6 +30,6 @@ jobs:
- uses: actions/checkout@v3
- uses: ammaraskar/sphinx-action@master
with:
docs-folder: "crates/zspell_py/docs/"
docs-folder: "crates/zspell-py/docs/"

# Add pytest here when applicable
2 changes: 2 additions & 0 deletions .github/workflows/validation-rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ jobs:
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
env:
RUST_BACKTRACE: "1"
with:
command: test

Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ version: 2

python:
install:
- requirements: crates/zspell_py/docs/requirements.txt
- requirements: crates/zspell-py/docs/requirements.txt
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

### Added

- Ability to automatically locate dictionaries on the system
- Command line option to download dictionaries

### Changed

### Removed
Expand Down
10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
[workspace]

members = ["crates/zspell", "crates/zspell_py"]
members = [
"crates/zspell",
"crates/zspell-py",
"crates/zspell-cli"
]

# Build with `cargo build --profile=release-debug`
# Alternatively `cargo bench --profile=release-debug`
# Useful for profiling, not for official releases
[profile.release-debug]
inherits = "release"
debug = true

[profile.release.package.zspell-cli]
# Minimize binary size by removing all symbols
strip = "symbols"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ discussions, for those who are interested.

There is a python wrapper for this library with prebuilt wheels, available
here: <https://pypi.org/project/zspell/>. Its source is located
in the [zspell_py crate](crates/zspell_py).
in the [zspell-py crate](crates/zspell-py).

### Usage via WASM

Expand Down
47 changes: 47 additions & 0 deletions crates/zspell-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "zspell-cli"
version = "0.1.4"
edition = "2021"
publish = false

# Note: this is symlinked from top level
readme = "README.md"
license-file = "LICENSE"

# Required to make name "zspell" instead of "zspell-cli"
[[bin]]
name = "zspell"
path = "src/main.rs"

[dependencies]
anyhow = "1.0"
cfg-if = "1.0"
clap = { version = "3.2", features = ["derive"] }
futures-util = "0.3"
hex = "0.4"
indicatif = "0.17"
reqwest = { version = "0.11", features = ["blocking", "stream"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sha1 = "0.10"
stringmetrics = "2.1"
termcolor = "1.1"
tokio = "1.20"
zspell = { path = "../zspell" }

[dev-dependencies]
criterion = "0.3"
assert_cmd = "2.0"
predicates = "2.1"
tempfile = "3.3"
httpmock = "0.6"
lazy_static = "1.4"
# util = { path = "util" }

[build-dependencies]
clap = { version = "3.2", features = ["derive"] }
clap_mangen = "0.1"
clap_complete = "3.0"

[package.metadata.release]
shared-version = true
File renamed without changes.
1 change: 1 addition & 0 deletions crates/zspell-cli/README.md
75 changes: 75 additions & 0 deletions crates/zspell-cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
use std::fs::File;
use std::io::Error;
use std::path::PathBuf;
use std::{env, path::Path};

use clap::{App, CommandFactory};
use clap_complete::{generate_to, shells::Shell};

include!("src/cli/mod.rs");

fn build_shell_completion(cmd: &mut App, outdir: &PathBuf) -> Result<(), Error> {
// Generate shell completion scripts for our
for shell in [
Shell::Bash,
Shell::Elvish,
Shell::Fish,
Shell::PowerShell,
Shell::Zsh,
] {
let path = generate_to(
shell, cmd, // We need to specify what generator to use
"zspell", // We need to specify the bin name manually
outdir, // We need to specify where to write
)?;

println!("cargo:warning=completion file written to {:?}", path);
}

Ok(())
}

fn build_man_pages(cmd: App, outdir: &Path) -> Result<(), Error> {
// Generate man pages
let man = clap_mangen::Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();

man.render(&mut buffer)?;

let manpage_out = outdir.join("zspell.1");

println!("cargo:warning=manpage written to {:?}", manpage_out);

std::fs::write(manpage_out, buffer)?;

Ok(())
}

fn main() -> Result<(), Error> {
// Output directory will be a cargo-generated random directory
let outdir = match env::var_os("OUT_DIR") {
Some(outdir) => std::path::PathBuf::from(outdir),
None => return Ok(()),
};

let profile = std::env::var("PROFILE").unwrap();

// Don't generate outputs if we're in debug mode
match profile.as_str() {
"debug" => (),
_ => {
// Create a dummy file to help find the latest output
let stamp_path = Path::new(&outdir).join("zspell-stamp");
if let Err(err) = File::create(&stamp_path) {
panic!("failed to write {}: {}", stamp_path.display(), err);
}

let mut cmd = Cli::command();

build_shell_completion(&mut cmd, &outdir)?;
build_man_pages(cmd, &outdir)?;
}
}

Ok(())
}
File renamed without changes.
Loading