takluyver / pynsist

Build Windows installers for Python applications
https://pynsist.readthedocs.io/
Other
896 stars 119 forks source link

Missing DLL #176

Open SecT0uch opened 5 years ago

SecT0uch commented 5 years ago

For Python 3.7+ with a vanilla updated Windows10, vcruntime140.dll is needed.

The check is made on ucrtbase.dll in System32. Would it be possible to check on SysWOW64\vcruntime.dll for 32 bits and System32\vcruntime.dll for 64 bits and add the missing DLL from Visual C++ Redistributable for Visual Studio 2015 in the corresponding directory.

This would ensure a compatibility for Python 3.7+

takluyver commented 5 years ago

@zooba does the above make sense to you? I thought the C runtime had reached a point where we wouldn't need to change how we were handling it any more?

SecT0uch commented 5 years ago

I would like to add that previous versions of python don't need this dll

zooba commented 5 years ago

VCRuntime140.dll is needed, mostly because extension modules need to use the same one so we can't statically link it (it contains shared state). It's also not versioned the same as ucrtbase, and is not itself part of Windows.

However, it's very small. Including it unconditionally shouldn't hurt, but if the VCRedist has been installed there will already be some copy of it on the system. For Python I decided keeping that one applocal made the most sense.

takluyver commented 5 years ago

Thanks! I'm still curious about:

  1. What changed from Python 3.6 to 3.7 in that regard?
  2. Are you saying this file is needed even if ucrtbase is already present on the system? I.e. it's not subject to the same check we already have for installing other msvcrt files:

https://github.com/takluyver/pynsist/blob/4bf55cbd6aad405f0d6e3d7127779a32b8d851b7/nsist/pyapp_msvcrt.nsi#L6-L7

  1. Where can we get a copy of this file?
  2. Should we expect the necessary files to change again with future versions of Python?
zooba commented 5 years ago
  1. Nothing, as far as I know. There was a brief bug where it wasn't being included, but I fixed that (I think it was during a 3.7 rc?). It's never been included with the embedded distro
  2. Basically, yeah. Just include it along with python3x.dll
  3. Comes with MSVC - mine is at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Redist\MSVC\14.16.27012\x64\Microsoft.VC141.CRT
  4. Eventually this one may change, I assume to vcruntime150.dll. But that's in some unpredictable future, and the MSVC team is trying very hard to avoid needing that kind of breaking change. (Put another way, I expect there to be other bigger changes before this one hits :) )
takluyver commented 5 years ago

Would it be possible to ship the necessary DLLs along with the embedded Python distribution? Either included in it, or as a separate bundle alongside each Python release?

I'm grateful for your attempts to explain this to me, but from my perspective it's still a mysterious set of binary blobs I have to cobble together from somewhere, and then everybody who runs a Pynsist-built installer implicitly trusts me and whatever system I got those files off. And I'm not at all sure whether distributing them like this really complies with the license.

The DLLs are, in some situations, an absolute requirement for running Python, but they depend on the OS and the installed updates in ways I don't really understand, and I can't predict when they will change. They're the biggest headache in maintaining Pynsist.

I'd love to see a flavour of the embedded distro which contains everything needed to run Python on any recent Windows platform, regardless of what else is installed on the system. So long as this doesn't exist, I'm effectively trying to maintain the same thing as part of Pynsist. And I'm a Python programmer who works in Linux 99% of the time. I don't have the knowledge to do this well, and it's not a problem that I find interesting.

mentaal commented 5 years ago

so just to confirm, pynsist bundles vcruntime140.dll such that the user is not required to install it if it's not present?

takluyver commented 5 years ago

It does not. You can see the list of bundled files here:

https://github.com/takluyver/pynsist/tree/master/nsist/msvcrt/x64

And the snippet that decides whether to install them here:

https://github.com/takluyver/pynsist/blob/master/nsist/pyapp_msvcrt.nsi

mentaal commented 5 years ago

Thanks for the clarification. It seems that without the bundling of this file, A user of pynsist will also need to bundle and run the redist package for the runtime. I don't understand why this file should be omitted from the list you mention. (Not being snarky, I know even less than you do about this and I'm just trying to understand what the best method of packaging a library is).

takluyver commented 5 years ago

I'm not saying that it shouldn't be bundled. Just that it's not at the moment, and I don't plan to do it. ;-)

I've got tired of trying to deal with the C-runtime part. There are lots of interesting challenges in Pynsist: finding Python packages, templating the NSIS script files, working out how to record errors, even how to test parts of it. The C runtime is not interesting. It's some opaque stuff that has to be done to make Python work on some computers, but I don't know whether I'm doing it correctly or when it might need changing. I'm not even sure whether distributing the DLLs with Pynsist is really allowed by whatever license agreement they're governed by.

So from now on, I'm leaving that as a problem for someone else to solve. My ideal answer would be for Python.org to provide the necessary runtime alongside the 'embeddable' Python build, but no-one seems to be pushing for that.

I'm happy in principle to accept PRs, but since I can't audit binary blobs, I'll only accept PRs to add/replace DLLs from people I already know well.

mentaal commented 5 years ago

No problem, that makes sense, thanks!

takluyver commented 5 years ago

Thanks for being understanding about my tantrum :stuck_out_tongue: