warp icon indicating copy to clipboard operation
warp copied to clipboard

fix the loading-dll-error under Windows with Python 3.8

Open DesmondZhong opened this issue 3 years ago • 1 comments

This pull request fixes #24 and makes dll loading working correctly under Windows with python 3.8.

  1. By directly passing winmode=0 to ctypes.CDLL, we achieve the correct default behavior. See the following posts for more details.

This stackoverflow post pointed out the issue. https://stackoverflow.com/questions/59330863/cant-import-dll-module-in-python/64472088#64472088

The author of the above post has reported this bug and it has been fixed for future python versions. https://github.com/python/cpython/issues/86280

  1. The full path of warp.dll instead of the file name is used (L459 in context.py). This is now consistent with the logic under Mac (L464) and Linux (L469). Note that passing only the file name will still raise the FileNotFound error in my environment, so this change is necessary for me. I haven't tested it on Windows with Python 3.7 or lower yet, but I'm happy to do it if you are interested in merging this pull request!

My environment

  • OS: Windows 10
  • Python version: 3.8.10
  • MSVC Compiler Version (cl.exe version) 19.26.28806 for x64
  • Warp version: 0.1.25

DesmondZhong avatar May 04 '22 02:05 DesmondZhong

Note: this PR (adding winmode=0) would break the code for python versions 3.7 and lower (regardless of the OS), since in those versions, the __init__ method of ctypes.CDLL doesn't accept the argument winmode. So this PR could serve as a quick fix for people who face #24 for now.

DesmondZhong avatar May 04 '22 14:05 DesmondZhong

Looks like related changes were merged in a810b842fe82d3e0aa99871ca4f75df9ba892b4e a long time ago. Thanks for the suggestions!

shi-eric avatar Sep 17 '24 16:09 shi-eric