henon / Python.Included

A Python.NET based framework enabling .NET libraries to call into Python packages without depending on a local Python installation.
MIT License
313 stars 51 forks source link

Installer.InstallWheel doesn't install wheel dependencies #24

Closed Evangelink closed 3 years ago

Evangelink commented 3 years ago

I have create a wheel for some python modules and have defined some dependency (e.g. easyocr) and when doing the call to Installer.InstallWheel on a fresh system, I have noticed that the dependencies do not get installed but when doing the installation manually through pip the dependencies are correctly retrieved.

Is it the expected behavior? Or shall it be doing all the dependencies automatically?

henon commented 3 years ago

Actually, Python.Included uses pip to install wheels. Could you clone the code and investigate by single stepping through the install procedure? I'll be happy to accept a PR if you find out what our install routines are missing.

Evangelink commented 3 years ago

Sure thing! I am pretty full for the rest of the day but I will have a look tomorrow and get back to you.

Evangelink commented 3 years ago

I am about to start the debugging but before that I just wanted to dump the results of some tests in case I am missing something obvious.

Test 1

Code:

Installer.SetupPython().Wait();
Installer.InstallWheel(typeof(Foo).Assembly, "mywheel-0.1.0-py3-none-any.whl").Wait();
var isInstalled = Installer.IsModuleInstalled("mywheel");

Result: isInstalled is false Dependencies of the module are not downloaded nor installed Module content is unzipped in %LOCALAPPDATA%/python-3.7.3-embed-amd64/Lib directly and not under site-packages.

Test 2

Same as Test 1 but I have added Installer.TryInstallPip(); before the InstallWheel call just in case it was changing anything. Result is the same as for Test 1.

Test 3

Code:

Installer.SetupPython().Wait();
Installer.TryInstallPip();
Installer.PipInstallWheel(typeof(Foo).Assembly, "mywheel-0.1.0-py3-none-any.whl");
var isInstalled = Installer.IsModuleInstalled("mywheel");

Same result as for the previous tests.

Test 4

Repeat the 3 previous tests not with my own wheel (in case it wasn't built correctly) but with easyocr-1.2.5-py3-none-any.whl. Results are the same as previously described.

Test 5

Code:

Installer.SetupPython().Wait();
Installer.TryInstallPip();
Installer.PipInstallModule("<SOME_PATH>/mywheel-0.1.0-py3-none-any.whl").Wait();
var isInstalled = Installer.IsModuleInstalled("mywheel");

Result: isInstalled is true Dependencies of the module are installed Module content is unzipped in %LOCALAPPDATA%/python-3.7.3-embed-amd64/Lib/site-packages.

henon commented 3 years ago

so it was all because of the missing path?

Evangelink commented 3 years ago

Sorry I have to admit I totally skipped the debugging part. I will make sure to add it on my weekly todo and post results.

Conclusions of the tests were that the embedded wheels do not download dependencies while the installation through a path works. At the end the problem wasn't so critical for us because we want with the install from a path and we package (on the CI) the resulting python folder into our installer so we don't need any kind of embedding or download of dependencies at runtime.

henon commented 3 years ago

No need. If your problem is solved I'll just close this.