stevenlovegrove / Pangolin

Pangolin is a lightweight portable rapid development library for managing OpenGL display / interaction and abstracting video input.
MIT License
2.39k stars 854 forks source link

python pangolin install #916

Closed twistxj closed 7 months ago

twistxj commented 8 months ago

i'm having trouble installing the python pangolin component. When I run: cmake --build build -t pypangolin_pip_install

It goes through most of the steps and then says this at the end:

Successfully installed numpy-1.26.4 pillow-10.2.0 pybind11-2.12.0 pyopengl-3.1.7 pyopengl-accelerate-3.1.7 pypangolin-0.9.1
WARNING: Skipping M:\gitRepos\Pangolin\build\pypangolin-0.9.1.dist-info due to invalid metadata entry 'name'
WARNING: Skipping M:\gitRepos\Pangolin\build\pypangolin-0.9.1.dist-info due to invalid metadata entry 'name'
WARNING: Skipping M:\gitRepos\Pangolin\build\pypangolin-0.9.1.dist-info due to invalid metadata entry 'name'

I can't run any of the python examples so I don't think it installed correctly. Any thoughts?

twistxj commented 8 months ago

this is how the build outputs:

$ cmake -B build -GNinja
-- The C compiler identification is GNU 13.1.0
-- The CXX compiler identification is GNU 13.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Strawberry/c/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Strawberry/c/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'Release' as none was specified.
-- Found Eigen: 'M://include/eigen3'
CMake Deprecation Warning at components/pango_python/pybind11/CMakeLists.txt:8 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- pybind11 v2.10.2
-- pybind11::lto disabled (problems with undefined symbols for MinGW for now)
-- pybind11::thin_lto disabled (problems with undefined symbols for MinGW for now)
-- Selected Python: 'C:/Users/olive_000/AppData/Local/Programs/Python/Python312/python.exe'. cmake --build . -t pypangolin_pip_install to use pypangolin module.
-- Found PkgConfig: C:/pkgconf/bin/pkg-config.exe (found version "0.26")
-- Configuring done (3.8s)
-- Generating done (0.1s)
-- Build files have been written to: M:/gitRepos/Pangolin/build
christian-rauch commented 7 months ago

It looks like you are using Windows. Note the information in the README about the Python bindings:

NOTE The python wheel and install targets are only currently working on MacOS and Linux. On Windows, you're out of luck right now. Help appreciated!

So you may just be out of luck on Windows.

Nevertheless, I am checking now that cmake --build build -t pypangolin_wheel works in the CI (https://github.com/stevenlovegrove/Pangolin/pull/918) and I can run the SimpleDisplay.py example (python ./examples/PythonExamples/SimpleDisplay.py).

Can you provide details on what is not working?

weixr18 commented 1 week ago

So sad TvT I wish I could see this issue earlier(and read README more carefully!!!), or I won't spend a whole day wondering why Windows+MinGW+pypangolin would fail.

I managed to solve all the compiling problems and got executable dlls, with perfect running example exes, but the .pyd just doesn't work.

>>> import pypangolin
>>> import pypangolin
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
 ImportError: DLL load failed while importing pypangolin: The specified module could not be found. 

Moreover, I tried to analysis the dependencies a/o symbols with MinGW commands ldd nm and strings. Here's what I got.

$ ldd pypangolin.cp312-win_amd64.pyd
ldd: pypangolin.cp312-win_amd64.pyd: Exec format error

$ nm pypangolin.cp312-win_amd64.pyd
E:\OPEN\GCC\mingw-w64-x86_64-8.1.0\bin\nm.exe: pypangolin.cp312-win_amd64.pyd: no symbols

$ strings pypangolin.cp312-win_amd64.pyd | grep dll
python312.dll
glew32.dll
libgcc_s_seh-1.dll
KERNEL32.dll
msvcrt.dll
OPENGL32.dll
libwinpthread-1.dll
libstdc++-6.dll
libpango_core.dll
libpango_display.dll
libpango_image.dll
libpango_opengl.dll
libpango_plot.dll
libpango_vars.dll
libpango_video.dll

Hope no one else would repeat my tragedy [Facepalm]

christian-rauch commented 1 week ago

So sad TvT I wish I could see this issue earlier(and read README more carefully!!!), or I won't spend a whole day wondering why Windows+MinGW+pypangolin would fail.

Actually, it should work now. I haven't tried this myself on an actual Windows installation, but since https://github.com/stevenlovegrove/Pangolin/pull/960, we install and run the Python wheel in the CI. See https://github.com/stevenlovegrove/Pangolin/actions/runs/11627142146/job/32379980092.

I managed to solve all the compiling problems and got executable dlls, with perfect running example exes, but the .pyd just doesn't work.

>>> import pypangolin
>>> import pypangolin
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
 ImportError: DLL load failed while importing pypangolin: The specified module could not be found. 

Moreover, I tried to analysis the dependencies a/o symbols with MinGW commands ldd nm and strings. Here's what I got.

$ ldd pypangolin.cp312-win_amd64.pyd
ldd: pypangolin.cp312-win_amd64.pyd: Exec format error

$ nm pypangolin.cp312-win_amd64.pyd
E:\OPEN\GCC\mingw-w64-x86_64-8.1.0\bin\nm.exe: pypangolin.cp312-win_amd64.pyd: no symbols

$ strings pypangolin.cp312-win_amd64.pyd | grep dll
python312.dll
glew32.dll
libgcc_s_seh-1.dll
KERNEL32.dll
msvcrt.dll
OPENGL32.dll
libwinpthread-1.dll
libstdc++-6.dll
libpango_core.dll
libpango_display.dll
libpango_image.dll
libpango_opengl.dll
libpango_plot.dll
libpango_vars.dll
libpango_video.dll

Hope no one else would repeat my tragedy [Facepalm]

If you link dynamically, you may have to tell the Python interpreter where to find the libraries. The CI only tests the Windows wheel file only for static linking (´-D BUILD_SHARED_LIBS=OFF´), to avoid this.