Ajoute les lanceurs double-cliquables (Windows, macOS, Linux)
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 <nul pour ne pas vider l'entrée standard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
90982e71c9
commit
d4faa4872c
@@ -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
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
@echo off
|
||||
rem Assistant de generation des supports (Windows) : double-cliquer sur ce fichier.
|
||||
setlocal
|
||||
chcp 65001 >nul <nul
|
||||
cd /d "%~dp0"
|
||||
|
||||
call :trouver_python
|
||||
if defined PY goto lancer
|
||||
|
||||
echo Python est nécessaire mais n'a pas été trouvé sur cet ordinateur.
|
||||
choice /c ON /m "Installer Python automatiquement (via winget)"
|
||||
if errorlevel 2 goto manuel
|
||||
winget install -e --id Python.Python.3.12 --accept-source-agreements --accept-package-agreements
|
||||
call :trouver_python
|
||||
if not defined PY goto manuel
|
||||
|
||||
:lancer
|
||||
%PY% scripts\assistant.py
|
||||
echo.
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:manuel
|
||||
echo.
|
||||
echo Installez Python depuis la page qui va s'ouvrir,
|
||||
echo en cochant la case "Add python.exe to PATH", puis relancez ce fichier.
|
||||
start "" https://www.python.org/downloads/
|
||||
pause
|
||||
exit /b 1
|
||||
|
||||
:trouver_python
|
||||
set "PY="
|
||||
py -3 -c "import venv" <nul >nul 2>nul && set "PY=py -3" && exit /b
|
||||
python -c "import venv" <nul >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
|
||||
Executable
+32
@@ -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... "
|
||||
Executable
+53
@@ -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... "
|
||||
Reference in New Issue
Block a user