opticspy / lightpipes

LightPipes for Python, "Pure Python version"
https://opticspy.github.io/lightpipes/
BSD 3-Clause "New" or "Revised" License
228 stars 53 forks source link

build windows wheels #9

Closed FredvanGoor closed 7 years ago

FredvanGoor commented 7 years ago

I have successfully build wheels for windows. For that I had to copy (manually or by a bat file) the 32- or 64 bits version of "libfftw3-3.dll" to the ".\build\lib.win-amd64-x.x" directory after the "py -x.x setup.py build_ext" command. After the "py -x.x setup.py bdist_wheel" command the wheel was created correctly.

If I did not copy the dll only the LightPipes.pyd file was in the wheel. I tried to use "package_data" in setup.py to put the dll into the wheel but that did not work. I also tried another directory structure with the setup.py outsite the sources directory, without success.

Copying was the only way I succeeded to get the libfftw3-3.dll in the root of site-packages along with the LightPipes.pyd file. This is required for successfully import LightPipes in Python. (Otherwise you get a DLL not found error).

Please let me know if there is another, more elegant, method to get the dll alongside the pyd in site-packages.

NB: I have updated the files in the LightPipes-Packages directory only (not in lightpipes directory). Fred.

guyskk commented 7 years ago

Maybe you need MANIFEST.in file to include dll. http://stackoverflow.com/questions/11848030/how-include-static-files-to-setuptools-python-package http://stackoverflow.com/questions/7522250/how-to-include-package-data-with-setuptools-distribute

FredvanGoor commented 7 years ago

I tried with a MANIFEST.in in the same directory as the setup.py. The MANIFEST.in, with the dll in fftw3-win64/, is:

include fftw3-win64/libfftw3-3.dll

I tried with- and without "include_package_data=True" but nothing seems to work: the dll is not included in the wheel.

Are there more options? Otherwise I am happy with the "copy" solution, which works.

FredvanGoor commented 7 years ago

I found a problem with pip uninstall: pip2 uninstall LightPipes works with the default python 2.7. It uninstalls LightPipes as expected. py -2.7 -m pip uninstall LightPipes does not work. It says:

Can't uninstall 'LightPipes'. No files were found to uninstall.

What's the difference between the two commands?

The opposite commands: py -2.7 -m pip install dist/LightPipes-1.1.0-cp27-cp27m-win32.whl and: pip2 install dist/LightPipes-1.1.0-cp27-cp27m-win32.whl work and do both the same thing: install LightPipes.... The same problem with python 3.5. I use pip version 9.0.1 (newest at this moment)

guyskk commented 7 years ago

I unzip lightpipes' linux whl file, found that setuptools will create a .libsLightPipes dir, and fftw is in the dir. I also unzip lightpipes' win32 whl file, but didn't found similar dir, I guess it's because fftw*.dll is not generate on building. Copy dll file may cause pip uninstall won't delete the file, but I didn't test yet,.

I'm sure python -m pip is the same as pip in Linux, cat $(which pip) can tell. Open the pip or pip2 file(it may be a script) in windows may found the result.

guyskk commented 7 years ago

You need MANIFEST.in, packages and include_package_data: https://github.com/guyskk/hello-cython

FredvanGoor commented 7 years ago

Hi, I re-wrote setup.py for creating the windows wheels. Copy to the build/lib.win... directory is now done in setup.py. Both the pyd and libfftw3-3.dll files are in the site-packages root directory. I could not get other alternatives working.

guyskk commented 7 years ago

OK