Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuget installed vts fails in Jupyter notebook #6

Open
scottprahl opened this issue Apr 18, 2024 · 8 comments
Open

nuget installed vts fails in Jupyter notebook #6

scottprahl opened this issue Apr 18, 2024 · 8 comments

Comments

@scottprahl
Copy link
Contributor

Not sure what is going on. I installed vts using nuget

mkdir vts
cd vts
nuget install VirtualPhotonics.Vts

Then executed the following in a JupyterLab notebook

import os
import clr
import numpy as np
import matplotlib.pyplot as plt
from System.Diagnostics import FileVersionInfo

# Vts version installed using Nuget currently fails when the next cell is executed
nuget_dll = "/Users/prahl/vts/VirtualPhotonics.Vts.10.0.0/lib/net6.0/Vts.dll"
git_dll = "/Users/prahl/Documents/Code/git/vts/publish/local/Vts.dll"

print("stats for:", git_dll)
print("file size is ", os.path.getsize(git_dll))
print(FileVersionInfo.GetVersionInfo(git_dll))

print("stats for:", nuget_dll)
print("file size is ", os.path.getsize(nuget_dll))
print(FileVersionInfo.GetVersionInfo(nuget_dll))

Which shows identical versions, but different file sizes for the two dlls

file size is  10562560
File:             /Users/prahl/Documents/Code/git/vts/publish/local/Vts.dll
InternalName:     Vts.dll
OriginalFilename: Vts.dll
FileVersion:      10.0.0.0
FileDescription:  Vts
Product:          Vts
ProductVersion:   10.0.0
Debug:            False
Patched:          False
PreRelease:       False
PrivateBuild:     False
SpecialBuild:     False
Language:         Language Neutral

stats for: /Users/prahl/vts/VirtualPhotonics.Vts.10.0.0/lib/net6.0/Vts.dll
file size is  10601984
File:             /Users/prahl/vts/VirtualPhotonics.Vts.10.0.0/lib/net6.0/Vts.dll
InternalName:     Vts.dll
OriginalFilename: Vts.dll
FileVersion:      10.0.0.0
FileDescription:  Vts
Product:          Vts
ProductVersion:   10.0.0
Debug:            False
Patched:          False
PreRelease:       False
PrivateBuild:     False
SpecialBuild:     False
Language:         Language Neutral

if I follow the above code with

clr.AddReference(git_dll)
from Vts import *

then everything is fine. If I restart the kernel and then do

clr.AddReference(nuget_dll) 
from Vts import *

it fails with

ModuleNotFoundError: No module named 'Vts'
@scottprahl scottprahl changed the title Using nuget install of vts fails Using nuget install of vts fails in Jupyter notebook Apr 18, 2024
@scottprahl scottprahl changed the title Using nuget install of vts fails in Jupyter notebook nuget installed vts fails in Jupyter notebook Apr 18, 2024
@lmalenfant
Copy link
Member

I had this same issue, when you pull a reference from NuGet, it only has the Vts.dll, the other dependent dlls need to be in the same folder otherwise it cannot resolve them. How NuGet works is that the other dependencies are also in their own folders, they would need to be grouped into a single location for this to work.

@scottprahl
Copy link
Contributor Author

Oh I see.

The .dlls could readily extracted and copied to the parent directory with something like

cd vts
find . -name "*.dll" | xargs -I {} cp {} .

but this will require some nuget packaging work. Currently nuget installs dlls for all the target frameworks so who knows which framework version will be the last one copied. I will submit a patch that attempts to include only a single framework

@scottprahl
Copy link
Contributor Author

Sorry, I have no idea how to help here. I thought I had an idea, but I was wrong :-(

@scottprahl
Copy link
Contributor Author

You are also right about the just moving the dlls from the subdirectories to the parent folder. Once I did that, the nuget install version worked.

Unfortunately, I think that cloning the git repo, building, and then using "vts/publish/local/Vts.dll" is the easiest thing to ask people to do. Alternatively, you could just zip all the required dll files together and publish these with each release.

@lmalenfant
Copy link
Member

Thank you for looking into it, I appreciate it!

I did think about creating a zip with the dlls although we kind of already have that with the MCCL release, that zip file will contain all the necessary dlls. I was wondering if we could leverage that here.

@lmalenfant
Copy link
Member

lmalenfant commented May 20, 2024

@dcuccia I'm glad you are making progress, could you put your updates for using NuGet with Python in this issue?

@lmalenfant
Copy link
Member

@dcuccia I just wanted to reach out and see how your progress is going on bringing the libraries into the Notebook using NuGet. We need to create a VTS release and if this is not a feasible solution we will need to have the zip file with the libraries.

Thank you!

@dcuccia
Copy link

dcuccia commented May 23, 2024

Hi Lisa,

I've been at a conference all week, so no new updates from me just yet. I came up with a solution to use a local .csproj to bring in Vts.dll and it's dependencies, which worked well and decently elegantly. Might have been running into the same thing Scott did, however, which was that the library imported might have been incomplete. Needed to spend more time on that, but if that checks out, that might reveal a problem with how we are packaging our library for Nuget.

David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants