From d4faa4872cbd44af7414f820bb52a4d6f82383ff Mon Sep 17 00:00:00 2001 From: Artemia Date: Sun, 18 Oct 2026 16:38:02 +0200 Subject: [PATCH] Ajoute les lanceurs double-cliquables (Windows, macOS, Linux) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chaque lanceur trouve ou propose d'installer Python puis appelle l'assistant. .gitattributes impose LF pour .sh/.command et CRLF pour .bat ; bit exécutable posé dans git. Sous Windows, chcp et les tests Python lisent --- .gitattributes | 4 +++ Generer-documents.bat | 36 ++++++++++++++++++++++++++ Generer-documents.command | 32 +++++++++++++++++++++++ generer-documents.sh | 53 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 Generer-documents.bat create mode 100755 Generer-documents.command create mode 100755 generer-documents.sh diff --git a/.gitattributes b/.gitattributes index d4d0158..56464d4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,6 @@ *.odt binary * text=auto +# Fins de ligne impos?es pour les lanceurs (sinon ils ?chouent sur l'autre syst?me) +*.sh text eol=lf +*.command text eol=lf +*.bat text eol=crlf diff --git a/Generer-documents.bat b/Generer-documents.bat new file mode 100644 index 0000000..5e92241 --- /dev/null +++ b/Generer-documents.bat @@ -0,0 +1,36 @@ +@echo off +rem Assistant de generation des supports (Windows) : double-cliquer sur ce fichier. +setlocal +chcp 65001 >nul nul 2>nul && set "PY=py -3" && exit /b +python -c "import venv" nul 2>nul && set "PY=python" && exit /b +for /d %%D in ("%LOCALAPPDATA%\Programs\Python\Python3*") do if exist "%%~D\python.exe" set PY="%%~D\python.exe" +exit /b diff --git a/Generer-documents.command b/Generer-documents.command new file mode 100755 index 0000000..001dd94 --- /dev/null +++ b/Generer-documents.command @@ -0,0 +1,32 @@ +#!/bin/bash +# Assistant de génération des supports (macOS) : double-cliquer sur ce fichier dans le Finder. +cd "$(dirname "$0")" || exit 1 + +trouver_python() { + for c in python3 /opt/homebrew/bin/python3 /usr/local/bin/python3; do + if command -v "$c" >/dev/null 2>&1 && "$c" -c "import venv" >/dev/null 2>&1; then + PY="$c" + return 0 + fi + done + return 1 +} + +if ! trouver_python; then + echo "Python 3 est nécessaire mais n'a pas été trouvé." + read -r -p "L'installer automatiquement (outils de développement Apple) ? [O/n] " rep + if [[ ! "$rep" =~ ^[nN] ]]; then + xcode-select --install 2>/dev/null + read -r -p "Suivez la fenêtre d'installation, puis appuyez sur Entrée une fois terminé... " + fi + if ! trouver_python; then + echo "Installez Python depuis la page qui va s'ouvrir, puis relancez ce fichier." + open "https://www.python.org/downloads/" + read -r -p "Appuyez sur Entrée pour fermer... " + exit 1 + fi +fi + +"$PY" scripts/assistant.py +echo +read -r -p "Appuyez sur Entrée pour fermer... " diff --git a/generer-documents.sh b/generer-documents.sh new file mode 100755 index 0000000..f7a2f12 --- /dev/null +++ b/generer-documents.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# Assistant de génération des supports (Linux) : clic droit > « Exécuter comme un programme », +# ou dans un terminal : ./generer-documents.sh +cd "$(dirname "$(readlink -f "$0")")" || exit 1 + +# Lancé hors d'un terminal (double-clic) : on se relance dans une fenêtre de terminal. +if [ ! -t 0 ]; then + for t in x-terminal-emulator gnome-terminal konsole xfce4-terminal xterm; do + if command -v "$t" >/dev/null 2>&1; then + case "$t" in + gnome-terminal) exec "$t" -- "$0" ;; + *) exec "$t" -e "$0" ;; + esac + fi + done +fi + +trouver_python() { + if command -v python3 >/dev/null 2>&1 && python3 -c "import venv, ensurepip" >/dev/null 2>&1; then + PY=python3 + return 0 + fi + return 1 +} + +if ! trouver_python; then + echo "Python 3 (avec le module venv) est nécessaire mais n'a pas été trouvé." + if command -v apt-get >/dev/null 2>&1; then + cmd="sudo apt-get install -y python3 python3-venv" + elif command -v dnf >/dev/null 2>&1; then + cmd="sudo dnf install -y python3" + elif command -v pacman >/dev/null 2>&1; then + cmd="sudo pacman -S --needed --noconfirm python" + elif command -v zypper >/dev/null 2>&1; then + cmd="sudo zypper install -y python3" + fi + if [ -n "$cmd" ]; then + read -r -p "Lancer l'installation ($cmd) ? Votre mot de passe sera demandé. [O/n] " rep + if [[ ! "$rep" =~ ^[nN] ]]; then + $cmd + fi + fi + if ! trouver_python; then + echo "Installez Python 3 et son module venv avec le gestionnaire de paquets de votre distribution," + echo "puis relancez ce fichier." + read -r -p "Appuyez sur Entrée pour fermer... " + exit 1 + fi +fi + +"$PY" scripts/assistant.py +echo +read -r -p "Appuyez sur Entrée pour fermer... "