Bonjour,
Je développe actuellement un module complémentaire JMP qui s'appuie sur des scripts Python intégrés.
Au démarrage, le module complémentaire installe les packages Python requis (à l'aide d'un référentiel wheel local) avant d'exécuter tout code Python.
Le problème auquel je suis confronté est que, lorsque le complément est lancé pour la première fois, il ne parvient parfois pas à exécuter les fonctions Python intégrées définies dans les fichiers soumis juste après l'installation du package.
It looks like JMP continues executing the script avant que le processus d'installation de PowerShell ne soit réellement terminé.
The error I get is that Python cannot find one of the functions defined in the two Python Submit File calls.
Après la première installation réussie, tout fonctionne bien (probablement parce que les packages sont déjà présents et que les scripts sont alors chargés correctement).
How can I make sure that JMP waits until the PowerShell installation process is fully completed before running Python Submit File()?
Voici la partie pertinente de mon code :
strPathjpip = dest_path || "\jpip.bat";
If( !File Exists( strPathjpip ),
Python Send( dest_path );
Python Submit( "
import jmp
import jmputils
jmputils.create_jpip(dest_path)
" );
);
// Build command to run
cmd = Eval Insert( "\[& "^strPathjpip^" install --no-index --find-links "^strPathPythonLibs^" numpy pandas scipy]\" );
Eval( Eval Expr( commands = {Expr( cmd )} ) );
icommand = 0;
// Use Run Program to execute the script
rp = Run Program(
Executable( "PowerShell.exe" ),
ReadFunction( Function( {this}, Write( this << Read ) ) ),
WriteFunction(
Function( {this},
icommand++;
If( icommand <= N Items( commands ),
this << Write( commands[icommand] ),
this << WriteEOF
);
)
)
);
// Include Python scripts
Python Submit File( strPathAddin || "include/PYTHON/exttolint.py" );
Python Submit File( strPathAddin || "include/PYTHON/normtolint.py" );
L'utilisation de la fonction Read("texte") est une option
Names Default To Here(1);
RP = Run Program(
Executable("PING.EXE"/*path probably not needed*/ ),
Options({"-n 5", "localhost"}),
ReadFunction("text")
);
Show(RP);
Write("\!NDONE");