first commit
This commit is contained in:
commit
73cc0e3ca9
88
.gitignore
vendored
Normal file
88
.gitignore
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
# Fichiers système
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
desktop.ini
|
||||
|
||||
# Dossiers de build et distributions
|
||||
/build/
|
||||
/dist/
|
||||
/out/
|
||||
/release/
|
||||
*.exe
|
||||
*.msi
|
||||
*.dmg
|
||||
*.pkg
|
||||
*.app
|
||||
|
||||
# Fichiers d'environnement et de configuration
|
||||
.env
|
||||
.env.local
|
||||
.env.development
|
||||
.env.test
|
||||
.env.production
|
||||
LINenv/
|
||||
WINenv/
|
||||
MACenv/
|
||||
|
||||
# Fichiers de dépendances
|
||||
/node_modules/
|
||||
/.pnp/
|
||||
.pnp.js
|
||||
/vendor/
|
||||
/packages/
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
|
||||
# Logs et bases de données
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
*.sqlite
|
||||
*.db
|
||||
|
||||
# Fichiers d'IDE et d'éditeurs
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
*.sublime-workspace
|
||||
*.sublime-project
|
||||
.vs/
|
||||
*.user
|
||||
*.userosscache
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
# Fichiers temporaires
|
||||
/tmp/
|
||||
/temp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*~
|
||||
|
||||
# Fichiers spécifiques à l'application
|
||||
# Ne pas ignorer le fichier options.json
|
||||
!options.json
|
||||
|
||||
# Dossier de cache
|
||||
.cache/
|
||||
.parcel-cache/
|
||||
|
||||
# Fichiers de couverture de test
|
||||
coverage/
|
||||
.nyc_output/
|
||||
.coverage
|
||||
htmlcov/
|
||||
|
||||
# Autres
|
||||
.vercel
|
||||
.next
|
||||
.nuxt
|
||||
.serverless/
|
66
BUILD.spec
Normal file
66
BUILD.spec
Normal file
@ -0,0 +1,66 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
# Load config.json
|
||||
config_path = Path("config.json")
|
||||
with config_path.open("r", encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
|
||||
# Extract values
|
||||
version = config.get("app_version", "0.0.0")
|
||||
arch = config.get("architecture", "x64")
|
||||
python_version = config.get("python_version", "3.x")
|
||||
os = config.get("app_os", "Windows")
|
||||
name = config.get("app_name", "HoDA")
|
||||
|
||||
# Construct dynamic name
|
||||
name = f"{name}-{os}-{arch}-v{version}"
|
||||
|
||||
# Optional icon path (can still be overridden via environment if needed)
|
||||
from os import getenv
|
||||
icon = getenv("ICON_PATH", "data/assets/icon.ico")
|
||||
|
||||
# Data files to bundle
|
||||
datas = [
|
||||
("data/assets/*", "data/assets/"),
|
||||
]
|
||||
binaries = []
|
||||
|
||||
a = Analysis(
|
||||
["main.py"],
|
||||
pathex=[],
|
||||
binaries=binaries,
|
||||
datas=datas,
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
noarchive=False,
|
||||
optimize=0,
|
||||
)
|
||||
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
[],
|
||||
name=name,
|
||||
icon=icon,
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
9
LICENSE
Normal file
9
LICENSE
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 LouisMazin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
51
build.bat
Normal file
51
build.bat
Normal file
@ -0,0 +1,51 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM === PATH SETUP ===
|
||||
set PARENT_DIR=%~dp0
|
||||
set BUILD_DIR=%~dp0..
|
||||
set VENV_PATH=%PARENT_DIR%\WINenv
|
||||
set PYTHON_IN_VENV=%VENV_PATH%\Scripts\python.exe
|
||||
set ICON_PATH=data/assets/icon.ico
|
||||
set CONFIG_FILE=%PARENT_DIR%\config.json
|
||||
|
||||
REM === Extract values from config.json ===
|
||||
for /f "delims=" %%i in ('powershell -NoProfile -Command ^
|
||||
"Get-Content '%CONFIG_FILE%' | ConvertFrom-Json | Select-Object -ExpandProperty python_version"') do set PYTHON_VERSION=%%i
|
||||
for /f "delims=" %%i in ('powershell -NoProfile -Command ^
|
||||
"Get-Content '%CONFIG_FILE%' | ConvertFrom-Json | Select-Object -ExpandProperty app_name"') do set APP_NAME=%%i
|
||||
for /f "delims=" %%i in ('powershell -NoProfile -Command ^
|
||||
"Get-Content '%CONFIG_FILE%' | ConvertFrom-Json | Select-Object -ExpandProperty architecture"') do set ARCHITECTURE=%%i
|
||||
|
||||
set EXE_NAME=%APP_NAME%-Windows-%ARCHITECTURE%
|
||||
|
||||
REM === Construct full python path from config.json ===
|
||||
set SYSTEM_PYTHON=C:\Logiciels\Python\%ARCHITECTURE%\%PYTHON_VERSION%\python.exe
|
||||
|
||||
REM === Verify Python existence ===
|
||||
if not exist "%SYSTEM_PYTHON%" (
|
||||
echo [ERROR] Python not found at: %SYSTEM_PYTHON%
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM === Check if virtual environment exists ===
|
||||
if not exist "%VENV_PATH%\Scripts\activate.bat" (
|
||||
echo [INFO] Virtual environment not found. Creating...
|
||||
"%SYSTEM_PYTHON%" -m venv "%VENV_PATH%"
|
||||
"%PYTHON_IN_VENV%" -m pip install --upgrade pip
|
||||
"%PYTHON_IN_VENV%" -m pip install -r "%PARENT_DIR%\requirements.txt"
|
||||
) else (
|
||||
echo [INFO] Virtual environment found.
|
||||
)
|
||||
|
||||
REM === Run PyInstaller ===
|
||||
"%PYTHON_IN_VENV%" -m PyInstaller ^
|
||||
--distpath "%BUILD_DIR%\Build" ^
|
||||
--workpath "%BUILD_DIR%\Building" ^
|
||||
--clean ^
|
||||
"%PARENT_DIR%\BUILD.spec"
|
||||
|
||||
REM === Clean build cache ===
|
||||
rmdir /s /q "%BUILD_DIR%\Building"
|
||||
|
||||
endlocal
|
7
config.json
Normal file
7
config.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"app_name": "HoDA_Verifier",
|
||||
"python_version": "3.11.7",
|
||||
"app_os": "Windows",
|
||||
"app_version": "1.0.0",
|
||||
"architecture": "x64"
|
||||
}
|
BIN
data/assets/icon.ico
Normal file
BIN
data/assets/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
data/assets/icon.png
Normal file
BIN
data/assets/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
53
main.py
Normal file
53
main.py
Normal file
@ -0,0 +1,53 @@
|
||||
## Interface with only a path widget (combo of QLineEdit and QPushButton to explore the file system)
|
||||
## and a button : verify (call a temp verify function)
|
||||
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLineEdit, QFileDialog
|
||||
import sys
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
def verify_path(path):
|
||||
# Temporary verification function
|
||||
if os.path.exists(path):
|
||||
print(f"Path '{path}' exists.")
|
||||
else:
|
||||
print(f"Path '{path}' does not exist.")
|
||||
|
||||
class PathWidget(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
self.layout = QVBoxLayout()
|
||||
|
||||
# Create a QLineEdit for the path input
|
||||
self.path_input = QLineEdit(self)
|
||||
self.path_input.setPlaceholderText("Enter or select a path")
|
||||
self.layout.addWidget(self.path_input)
|
||||
|
||||
# Create a QPushButton to open the file dialog
|
||||
self.browse_button = QPushButton("Browse", self)
|
||||
self.browse_button.clicked.connect(self.open_file_dialog)
|
||||
self.layout.addWidget(self.browse_button)
|
||||
|
||||
# Create a QPushButton to verify the path
|
||||
self.verify_button = QPushButton("Verify", self)
|
||||
self.verify_button.clicked.connect(self.verify_path)
|
||||
self.layout.addWidget(self.verify_button)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
self.setWindowTitle("Path Widget Example")
|
||||
|
||||
def open_file_dialog(self):
|
||||
path, _ = QFileDialog.getExistingDirectory(self, "Select Directory")
|
||||
if path:
|
||||
self.path_input.setText(path)
|
||||
|
||||
def verify_path(self):
|
||||
verify_path(self.path_input.text())
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
widget = PathWidget()
|
||||
widget.show()
|
||||
sys.exit(app.exec_())
|
48
open.bat
Normal file
48
open.bat
Normal file
@ -0,0 +1,48 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Set file paths
|
||||
set CONFIG_FILE=%~dp0config.json
|
||||
set REQUIREMENTS=requirements.txt
|
||||
set ENV_NAME=WINenv
|
||||
set ENV_PATH=%~dp0%ENV_NAME%
|
||||
|
||||
REM Extract config.json fields using PowerShell
|
||||
for /f "delims=" %%i in ('powershell -NoProfile -Command ^
|
||||
"Get-Content '%CONFIG_FILE%' | ConvertFrom-Json | Select-Object -ExpandProperty python_version"') do set PYTHON_VERSION=%%i
|
||||
|
||||
for /f "delims=" %%i in ('powershell -NoProfile -Command ^
|
||||
"Get-Content '%CONFIG_FILE%' | ConvertFrom-Json | Select-Object -ExpandProperty architecture"') do set ARCHITECTURE=%%i
|
||||
|
||||
REM Construct python executable path
|
||||
set PYTHON_EXEC=C:\Logiciels\Python\%ARCHITECTURE%\%PYTHON_VERSION%\python.exe
|
||||
|
||||
if not exist "%PYTHON_EXEC%" (
|
||||
echo [ERROR] Python introuvable à: %PYTHON_EXEC%
|
||||
echo Veuillez vérifier votre config.json ou le dossier d'installation.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Show config info
|
||||
echo [INFO] Configuration :
|
||||
echo Python: %PYTHON_EXEC%
|
||||
echo Env: %ENV_NAME%
|
||||
|
||||
REM Check if virtual environment exists
|
||||
if not exist "%ENV_PATH%\Scripts\activate.bat" (
|
||||
echo [INFO] Environnement virtuel introuvable, création...
|
||||
"%PYTHON_EXEC%" -m venv "%ENV_NAME%"
|
||||
call "%ENV_PATH%\Scripts\activate.bat"
|
||||
echo [INFO] Installation des dépendances...
|
||||
pip install --upgrade pip
|
||||
pip install -r "%REQUIREMENTS%"
|
||||
) else (
|
||||
echo [INFO] Environnement virtuel trouvé.
|
||||
)
|
||||
|
||||
REM Activate and launch VS Code
|
||||
call "%ENV_PATH%\Scripts\activate.bat"
|
||||
echo [INFO] Lancement de VS Code...
|
||||
start code "%~dp0"
|
||||
|
||||
exit /b 0
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
PyQt5
|
||||
pyinstaller
|
16
utils/paths.py
Normal file
16
utils/paths.py
Normal file
@ -0,0 +1,16 @@
|
||||
from os import path
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
def resource_path(relative_path: str) -> Path:
|
||||
"""
|
||||
Get absolute path to resource, works for dev and for PyInstaller bundle.
|
||||
|
||||
PyInstaller stores bundled files in _MEIPASS folder.
|
||||
"""
|
||||
try:
|
||||
base_path = Path(sys._MEIPASS) # PyInstaller temp folder
|
||||
except AttributeError:
|
||||
base_path = Path(__file__).parent.parent # Dev environment: source/ folder
|
||||
|
||||
return path.join(base_path, relative_path)
|
Loading…
x
Reference in New Issue
Block a user