Bonjour, je suis depuis quelques temps sur un projet, et j'ai besoin pour ce projet d'accéder à des fonction python via un programme en c#.
Mon gros problème et que la partie python n'est qu'une extention d'un logiciel (jeu assetto corsa) et elle utilise des import que je ne peux accéder.

Pour être plus claire :
Le jeu assetto corsa est une simulation automobile, il peut contenir des "apps", applications diverses et créer par des modders.
Lorsqu'on crée une app, c'est en python et on peut utiliser "import ac" (le using de python) qui contient plein de choses du jeu mais on ne peut pas avoir accés au fichier ac.py.
Donc j'ai une application en python avec plusieurs fonction, certaines utilise la bibliotheque ac et d'autre non.
Je veux executer une fonction de ce script (qui elle n'a pas besoin de la librairie ac) via un programme en c#.
Le problème est que le compilateur me dit que ac n'est pas trouvable :

Voila le test que je fais, ce n'est pas mon code python mais je l'utilise pour mes test car il est simple.

Le fichier SteeringLock.py qui est en fait une application du jeu :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
##############################################################
# Kunos Simulazioni
# AC Python tutorial 04 : Get data from AC
#
# To activate create a folder with the same name as this file
# in apps/python. Ex apps/python/tutorial01
# Then copy this file inside it and launch AC
#############################################################
 
 
 
import ac
import acsys
 
label1=0
 
def acMain(ac_version):
    global label1
    appWindow=ac.newApp("TUTORIAL 5")
    ac.setSize(appWindow,300,200)
    label1=ac.addLabel(appWindow,"Hellow world in a label!")
    ac.setPosition(label1,10,50)
    ac.log("I have created the App")
    return "AC Python Tutorial 05"
 
 
def acUpdate(deltaT):
    global label1
 
    # ac.getCarState may return values in vector form, depending on the information requested,
	# check PythonDoc.txt for more info
	# this happends for example in the following example: 
    x,y,z=ac.getCarState(0,acsys.CS.AccG)
 
    # Put the gravitational acceleration inside the label with the following sintax
	# the digits are rounded to the second decimal value
    ac.setText(label1,"G meter: \n x={0} \n y={1} \n z={2}".format(round(x,2),round(y,2),round(z,2)))
 
def isodd(n): return 1 == n % 2;
La ligne qui m’intéresse via mon programme en C# est la derniere, elle retourne true si je lui mets 1 en parametre et false sinon.

Voici ma classe c# :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    public class C_Py
    {
        /// <summary>
        /// Log
        /// </summary>
        /// <param name="str">Log</param>
        private void log(string str)
        {
            Debug.WriteLine(str, "C_Py");
        }
 
        private string dir_python_SteeringLock = "E://Steam/SteamApps/common/assettocorsa/apps/python/SteeringLock/SteeringLock.py";
 
        public C_Py()
        {
            ScriptEngine pyEng = Python.CreateRuntime().GetEngine("python");
            ScriptSource source = pyEng.CreateScriptSourceFromFile(dir_python_SteeringLock);
            ScriptScope scope = pyEng.CreateScope();
            source.Execute(scope);
 
 
            Func<int, bool> IsOdd = scope.GetVariable<Func<int, bool>>("isodd");
            log("test : " + IsOdd(1) + "  " + IsOdd(2));
        }
    }
Ce qui me donne :
"No module named ac"
(il faut savoir que sinon la communication avec python fonctionne, si je supprime tout sauf la dernière ligne du .py tout est ok.)
Le problème est que la bibliotheque ac ne sert à rien à mon programme, il sert à la partie python, coté jeu. Comment je peux forcer la compilation? Dois-je recréer un fake ac? J'ai essayé mais je n'y arrive pas, mais avant d'aller plus loin dans cette farce je voudrais avoir vos avis.