4

I distribute a Python library that has wheels for OSX, Linux, and Windows. On Windows I have always included the DLLs using the data_files parameter to setup(). I copied this from an older package that I took over maintenance of, and it has always worked when I've tested it on Windows, but sometimes it doesn't work. I have no idea what the exact situation is that causes it not to work.

I recently asked the pip devs about why this was happening, and they said that the way I was specifying the file path was wrong, but they didn't know what the right way was. What is the right way to specify where DLLs should be installed in setup.py?

To be clear I am passing this value to data_files:

[("lib\\site-packages\\fugashi\\", [ ... build machine dll path ... ])]

This is kind of the same question as this one and this one, but the answer in both of those is to use data_files.

polm23
  • 14,456
  • 7
  • 35
  • 59
  • 1
    Use `package_data` instead of `data_files` which is unpredictable and unreliable. Smth like `package_data={'fugashi': ['lib/*.DLL']}`, then preload the DLL in Python code via e.g. `ctypes.CDLL(importlib.resources.path('fugashi', 'lib/mylib.dll'))`. Preloading isn't necessary on Unix with a `runtime_library_dirs` configured for the extension, but on Windows it doesn't work since not implemented in `disutils`. – hoefling Oct 28 '21 at 21:19

0 Answers0