ferric_crypto_lib 0.2.7

A library for Ferric Crypto
Documentation
#!/usr/bin/env just --justfile

# vars
name := "ferric_crypto_lib"
version := "0.2.6"
python_tag := "cp311"
abi_tag := "cp311"
platform_tag := "manylinux_2_34_x86_64"

# default to build both the Rust library and the whl file
default: build build-py-all

# Command to create all bioler plate code for a new crypto system
add-algo name:
    @echo "Creating a new crypto system: {{name}}"
    @sed "s/name/{{name}}/g; s/lower/{{lowercase(name)}}/g" templates/crypto_def_template.rs > src/crypto_systems/{{lowercase(name)}}.rs
    @echo "pub mod {{lowercase(name)}};\n" >> src/crypto_systems/mod.rs
    @sed "s/name/{{name}}/g; s/lower/{{lowercase(name)}}/g" templates/crypto_bf_template.rs > src/brute_force/{{lowercase(name)}}.rs
    @echo "pub mod {{lowercase(name)}};\n" >> src/brute_force/mod.rs
    @sed "s/name/{{name}}/g; s/lower/{{lowercase(name)}}/g" templates/crypto_encrypt_template.rs > src/encrypt/{{lowercase(name)}}.rs
    @echo "pub mod {{lowercase(name)}};\n" >> src/encrypt/mod.rs
    @sed "s/name/{{name}}/g; s/lower/{{lowercase(name)}}/g" templates/crypto_decrypt_template.rs > src/decrypt/{{lowercase(name)}}.rs
    @echo "pub mod {{lowercase(name)}};\n" >> src/decrypt/mod.rs
    @echo $(sed "s/name/{{name}}/g; s/lower/{{lowercase(name)}}/g" templates/error_template.rs) >> src/error.rs

# Command to build the Rust library
build: clean
    @echo "Building the Rust library"
    @cargo build --release

# command to test the Rust library
test:
    @echo "Testing the Rust library"
    @cargo test

build-py: clean-py
    @echo "Building the whl file"
    maturin build --release --manylinux {{platform_tag}}

# Command to build the whl file
build-py-all: clean-py
    @echo "Building the whl files for multiple Python versions"
    ./build-py.sh

# command to install the whl file
install-py: build-py
    @echo "Installing the whl file"
    pip install --force-reinstall target/wheels/{{name}}-{{version}}-{{python_tag}}-{{abi_tag}}-{{platform_tag}}.whl

# command to uninstall the whl file
uninstall-py:
    @echo "Uninstalling the whl file"
    pip uninstall -y target/wheels/{{name}}-{{version}}-{{python_tag}}-{{abi_tag}}-{{platform_tag}}.whl

publish-py: build-py-all
    @echo "Publishing the whl file"
    @twine upload target/wheels/*.whl

publish-local-py: build-py-all
    @devpi login root --password ''
    @devpi use root/local
    @devpi upload --formats=bdist_wheel target/wheels/*.whl

# command to publish to crates.io
publish:
    @echo "Publishing to crates.io"
    @cargo publish

# command to publish all targets
publish-all: publish publish-py

# command to build the docs
docs:
    @echo "Building the docs"
    @cargo doc --no-deps --document-private-items --open --release

# command to clean the build directory (target)
clean:
    @echo "Removing the target directory"
    @cargo clean || true

clean-py:
    @echo "Removing all wheels"
    @rm target/wheels/* || true

# command to display number of lines of code written in Rust
loc:
    @echo "Number of lines of code written in Rust"
    @cloc . --include-lang=Rust --exclude-dir=target