Fix build Nuitka : ne compiler que nos modules, copier les packages tels quels
- Re-ajoute --nofollow-import-to pour tous les packages externes lourds (onnxruntime, numpy, transformers, PIL, fitz, pdfplumber, etc.) - Ajoute --no-deployment-flag=excluded-module-usage pour autoriser leur import à l'exécution - Nouvelle étape : pip install --target=dist pour copier les packages Python directement dans le dossier de distribution - Nuitka ne compile en C que nos 4 modules + stdlib + tkinter - Les packages externes restent en bytecode Python natif (fiable) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ REM avec Nuitka (Python -> C -> .exe natif Windows)
|
||||
REM ============================================================
|
||||
REM Prerequis :
|
||||
REM - Python 3.10+ installe et dans le PATH
|
||||
REM - pip install nuitka orderedset zstandard
|
||||
REM - pip install nuitka zstandard
|
||||
REM - pip install -r requirements.txt
|
||||
REM - Visual Studio Build Tools (ou MinGW64)
|
||||
REM ============================================================
|
||||
@@ -13,6 +13,7 @@ REM ============================================================
|
||||
setlocal
|
||||
set APP_NAME=Pseudonymisation
|
||||
set ENTRY=Pseudonymisation_Gui_V5.py
|
||||
set DIST_DIR=build\Pseudonymisation_Gui_V5.dist
|
||||
set MODEL_ID=cmarkea/distilcamembert-base-ner
|
||||
|
||||
echo [build] Verification de Python...
|
||||
@@ -24,7 +25,7 @@ pip install nuitka zstandard 2>nul
|
||||
echo [build] Telechargement du modele NER si absent...
|
||||
python -c "from ner_manager_onnx import NerModelManager; m=NerModelManager(cache_dir='models'); m.load('%MODEL_ID%'); print('Modele OK'); m.unload()"
|
||||
|
||||
echo [build] Compilation avec Nuitka (cela peut prendre 20-40 min)...
|
||||
echo [build] Compilation avec Nuitka (cela peut prendre 10-20 min)...
|
||||
python -m nuitka ^
|
||||
--standalone ^
|
||||
--enable-plugin=tk-inter ^
|
||||
@@ -33,6 +34,27 @@ python -m nuitka ^
|
||||
--include-module=eds_pseudo_manager ^
|
||||
--include-data-dir=config=config ^
|
||||
--include-data-dir=models=models ^
|
||||
--nofollow-import-to=onnxruntime ^
|
||||
--nofollow-import-to=numpy ^
|
||||
--nofollow-import-to=transformers ^
|
||||
--nofollow-import-to=optimum ^
|
||||
--nofollow-import-to=tokenizers ^
|
||||
--nofollow-import-to=sentencepiece ^
|
||||
--nofollow-import-to=torch ^
|
||||
--nofollow-import-to=PIL ^
|
||||
--nofollow-import-to=pdfplumber ^
|
||||
--nofollow-import-to=pdfminer ^
|
||||
--nofollow-import-to=fitz ^
|
||||
--nofollow-import-to=pymupdf ^
|
||||
--nofollow-import-to=yaml ^
|
||||
--nofollow-import-to=huggingface_hub ^
|
||||
--nofollow-import-to=safetensors ^
|
||||
--nofollow-import-to=regex ^
|
||||
--nofollow-import-to=tqdm ^
|
||||
--nofollow-import-to=requests ^
|
||||
--nofollow-import-to=filelock ^
|
||||
--nofollow-import-to=packaging ^
|
||||
--no-deployment-flag=excluded-module-usage ^
|
||||
--windows-console-mode=disable ^
|
||||
--output-dir=build ^
|
||||
--company-name="Hopital" ^
|
||||
@@ -47,6 +69,9 @@ if %ERRORLEVEL% NEQ 0 (
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [build] OK — Dossier cree : build\%ENTRY:.py=.dist%\
|
||||
echo [build] Copie des packages Python dans le dossier dist...
|
||||
pip install --target="%DIST_DIR%" -r requirements.txt --no-warn-script-location
|
||||
|
||||
echo [build] OK — Dossier cree : %DIST_DIR%\
|
||||
echo [build] Le modele NER est embarque. Aucun telechargement necessaire.
|
||||
endlocal
|
||||
|
||||
Reference in New Issue
Block a user