From a0acfe4af9ec112796c037d88f005dd777483eca Mon Sep 17 00:00:00 2001 From: Burhanuddin Kalawadwala <147647006+saurondark22@users.noreply.github.com> Date: Thu, 4 Jun 2026 21:56:26 +0530 Subject: [PATCH] Add Linux local build script and update compile instructions - Add build-and-install-local-linux.sh for local install with launcher icon - Update build docs with clearer venv setup, platform-specific activation, and Linux install steps - Add autostart option and post-install usage info - Ignore Python venv, packaging, dist, and spec files in Windows_and_Linux - Fix README link to point to main branch instead of specific commit --- .gitignore | 7 +- .../To Compile the Application Yourself.md | 53 ++++-- ...ing Tools Directly from the Source Code.md | 8 + README.md | 4 +- .../build-and-install-local-linux.sh | 75 ++++++++ Windows_and_Linux/install-local-linux.sh | 176 ++++++++++++++++++ Windows_and_Linux/pyinstaller-build-script.py | 60 ++++-- 7 files changed, 354 insertions(+), 29 deletions(-) create mode 100755 Windows_and_Linux/build-and-install-local-linux.sh create mode 100755 Windows_and_Linux/install-local-linux.sh diff --git a/.gitignore b/.gitignore index c46af629..ee9c8732 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,9 @@ Windows_and_Linux/config.json # Xcode user-specific data **/xcuserdata/ -**/project.xcworkspace/xcuserdata/ \ No newline at end of file +**/project.xcworkspace/xcuserdata/ + +Windows_and_Linux/.venv/ +Windows_and_Linux/packaging/ +Windows_and_Linux/dist/ +Windows_and_Linux/Writing Tools.spec \ No newline at end of file diff --git a/README's Linked Content/To Compile the Application Yourself.md b/README's Linked Content/To Compile the Application Yourself.md index 829c9e9e..b967a508 100644 --- a/README's Linked Content/To Compile the Application Yourself.md +++ b/README's Linked Content/To Compile the Application Yourself.md @@ -3,32 +3,59 @@ ### Windows and Linux Version build instructions: Here's how to compile it with PyInstaller and a virtual environment: -1. First, create and activate a virtual environment: +1. Open Terminal (or Command Prompt) and enter the Windows/Linux app folder: ```bash -# Install virtualenv if you haven't already -pip install virtualenv +cd /path/to/WritingTools/Windows_and_Linux +``` -# Create a new virtual environment -virtualenv myvenv +2. Create and activate a virtual environment: +```bash +python3 -m venv .venv -# Activate it -# On Windows: -myvenv\Scripts\activate -# On Linux: -source myvenv/bin/activate -``` +# Linux: +source .venv/bin/activate -2. Once activated, install the required packages: +# Windows (PowerShell): +.venv\Scripts\Activate.ps1 + +# Windows (cmd): +.venv\Scripts\activate.bat +``` +3. Install dependencies: ```bash +python -m pip install --upgrade pip pip install -r requirements.txt ``` -3. Build Writing Tools: +4. Build Writing Tools: ```bash python pyinstaller-build-script.py ``` +The compiled binary is written to: ~/Windows_and_Linux/dist/Writing Tools + +5. Linux only (optional, recommended): install locally with launcher icon: +```bash +bash build-and-install-local-linux.sh +``` + +This creates: +- `~/.local/bin/writing-tools` +- `~/.local/share/applications/writing-tools.desktop` + +Optional autostart: +```bash +bash build-and-install-local-linux.sh --enable-autostart +``` + +After local install, you can launch Writing Tools with: +```bash +writing-tools +``` + +No daily recompilation is needed unless you changed source code and want a newer build. + ### macOS Version (by [Aryamirsepasi](https://github.com/Aryamirsepasi)) build instructions: 1. **Install Xcode** diff --git a/README's Linked Content/To Run Writing Tools Directly from the Source Code.md b/README's Linked Content/To Run Writing Tools Directly from the Source Code.md index 329df109..37d97f82 100644 --- a/README's Linked Content/To Run Writing Tools Directly from the Source Code.md +++ b/README's Linked Content/To Run Writing Tools Directly from the Source Code.md @@ -34,5 +34,13 @@ Of course, you'll need to have [Python installed](https://www.python.org/downloa python3 main.py ``` +If you want a launcher icon in your app menu and a reusable local install (so you do not need to run from terminal every day), use: + +```bash +bash build-and-install-local-linux.sh +``` + +from the `Windows_and_Linux` folder. + ### [**◀️ Back to main page**](https://github.com/theJayTea/WritingTools) diff --git a/README.md b/README.md index c1a1fcd0..f4829ae4 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ Aside from being the only Windows/Linux program like Apple's Writing Tools, and ### **🐧 Linux (work-in-progress)**: [Run it from the source code](https://github.com/theJayTea/WritingTools/blob/main/README's%20Linked%20Content/To%20Run%20Writing%20Tools%20Directly%20from%20the%20Source%20Code.md) +[Compile and install locally with launcher icon](https://github.com/theJayTea/WritingTools/blob/main/README's%20Linked%20Content/To%20Compile%20the%20Application%20Yourself.md) + Writing Tools works well on x11. On Wayland, there are a few caveats: - [it works on XWayland apps](https://github.com/theJayTea/WritingTools/issues/34#issuecomment-2461633556) - [and it works if you disable Wayland for individual Flatpaks with Flatseal.](https://github.com/theJayTea/WritingTools/issues/93#issuecomment-2576511041) @@ -220,7 +222,7 @@ These instructions are for any Writing Tools version, using the OpenAI-Compatibl ## 👨💻 To Compile the Application Yourself: -[Instructions here!](https://github.com/theJayTea/WritingTools/blob/8713e5a5de63a7892b05a43b9753172e692768fb/README's%20Linked%20Content/To%20Compile%20the%20Application%20Yourself.md) +[Instructions here!](https://github.com/theJayTea/WritingTools/blob/main/README's%20Linked%20Content/To%20Compile%20the%20Application%20Yourself.md) ## 🌟 Contributors diff --git a/Windows_and_Linux/build-and-install-local-linux.sh b/Windows_and_Linux/build-and-install-local-linux.sh new file mode 100755 index 00000000..51c88f86 --- /dev/null +++ b/Windows_and_Linux/build-and-install-local-linux.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +AUTOSTART_FLAG="" +SKIP_BUILD="no" + +print_usage() { + cat <<'USAGE' +Usage: + bash build-and-install-local-linux.sh [--enable-autostart|--disable-autostart] [--skip-build] + +Builds Writing Tools with PyInstaller, then installs it locally with: +- Launcher command: ~/.local/bin/writing-tools +- App menu entry: ~/.local/share/applications/writing-tools.desktop + +Options: + --enable-autostart Enable autostart after install + --disable-autostart Disable autostart after install + --skip-build Skip PyInstaller build and only run local install + -h, --help Show this help message +USAGE +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --enable-autostart|--disable-autostart) + AUTOSTART_FLAG="$1" + ;; + --skip-build) + SKIP_BUILD="yes" + ;; + -h|--help) + print_usage + exit 0 + ;; + *) + echo "ERROR: Unknown option: $1" + print_usage + exit 1 + ;; + esac + shift +done + +if ! command -v python3 >/dev/null 2>&1; then + echo "ERROR: python3 is required but was not found." + exit 1 +fi + +INSTALL_SCRIPT="${SCRIPT_DIR}/install-local-linux.sh" +if [[ ! -f "${INSTALL_SCRIPT}" ]]; then + echo "ERROR: Missing installer script at ${INSTALL_SCRIPT}" + exit 1 +fi + +pushd "${SCRIPT_DIR}" >/dev/null + +if [[ "${SKIP_BUILD}" != "yes" ]]; then + echo "Building with PyInstaller..." + python3 pyinstaller-build-script.py +else + echo "Skipping build as requested." +fi + +echo "Installing locally for current user..." +install_args=(--app-source "${SCRIPT_DIR}") +if [[ -n "${AUTOSTART_FLAG}" ]]; then + install_args+=("${AUTOSTART_FLAG}") +fi +bash "${INSTALL_SCRIPT}" "${install_args[@]}" + +popd >/dev/null + +echo "Done. Launch via: writing-tools" diff --git a/Windows_and_Linux/install-local-linux.sh b/Windows_and_Linux/install-local-linux.sh new file mode 100755 index 00000000..c3b04fd0 --- /dev/null +++ b/Windows_and_Linux/install-local-linux.sh @@ -0,0 +1,176 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +APP_SOURCE="${SCRIPT_DIR}" +ENABLE_AUTOSTART="" + +print_usage() { + cat <<'USAGE' +Usage: + bash install-local-linux.sh [--app-source