2 releases
Uses new Rust 2024
new 0.1.1 | Mar 15, 2025 |
---|---|
0.1.0 | Mar 15, 2025 |
#776 in Development tools
10KB
63 lines
SDK.py Wrapper
This project is a lightweight command-line wrapper designed for Windows. It facilitates the execution of a Python script (typically sdk.py
) located within the directory specified by the SIFLI_SDK_PATH
environment variable. The wrapper forwards command-line parameters, sets up the necessary environment, and manages process signals.
Project Overview
The sdk.py Wrapper primarily performs the following operations:
-
Environment Variable Reading:
Reads theSIFLI_SDK_PATH
environment variable, which should point to the root directory where thetools/sdk.py
script is located. -
Command Construction:
Constructs the full path to the Python script by joiningSIFLI_SDK_PATH
withtools/sdk.py
and then prepares the command line to invokepython.exe
with this script along with any additional command-line arguments provided by the user. -
Environment Setup for Subprocess:
Sets an environment variableSIFLI_SDK_PY_PROGRAM_NAME
to"sdk.py"
before launching the Python subprocess. This can be used by the script for internal configuration or logging purposes. -
Signal Handling (Ctrl+C):
Installs a handler using thectrlc
crate to capture the Ctrl+C signal and ignore it in order to prevent the parent process from immediately terminating. -
Version Reporting:
If the executable is run with--version
or-v
(and its name ends with.exe
), the program prints the version number (synchronized with the version set inCargo.toml
viaCARGO_PKG_VERSION
) and exits.
Supported Command-Line Parameters
-
--version
or-v
:
When provided (and if the executable's name ends with.exe
), the wrapper prints its version (fromCargo.toml
) and exits immediately. -
Additional Arguments:
Any other command-line arguments are passed through to the underlyingsdk.py
script.
Building the Project
Ensure you have Rust installed (preferably via rustup). Then, execute the following commands:
-
Build the Project in Release Mode:
cargo build --release
-
Rename the Executable (Optional):
By default, the binary will be namedsdk_py.exe
(on Windows) because crate names must follow certain naming rules. If you require the executable to be namedsdk.py.exe
, you can rename it manually:cd target\release ren sdk_py.exe sdk.py.exe
Alternatively, you can automate renaming with a custom build or deployment script.
Environment Setup
Before running the executable, make sure the SIFLI_SDK_PATH
environment variable is set. For example:
- For Windows CMD:
set SIFLI_SDK_PATH=C:\path\to\SiFli-SDK
- For PowerShell:
$env:SIFLI_SDK_PATH="C:\path\to\SiFli-SDK"
Usage Example
After setting up the environment, you can run the wrapper from the command line:
-
To execute the Python script with additional arguments:
sdk.py.exe --some-argument
-
To display the version information:
sdk.py.exe --version
License
This project is licensed under the Apache-2.0. Replace this text with the actual license if applicable.
Contributing
Contributions, issues, and feature requests are welcome! Please feel free to submit a pull request or open an issue to discuss any changes.
Dependencies
~1.5–8MB
~66K SLoC