libyal / libpff

Library and tools to access the Personal Folder File (PFF) and the Offline Folder File (OFF) format
GNU Lesser General Public License v3.0
289 stars 74 forks source link

Python Bindings Not Being Built #52

Closed fligi7 closed 6 years ago

fligi7 commented 6 years ago

Specifying to build Python bindings as specified here. However, it's not working as expected.

This is on Fedora 24 with Linux 4.11.12-100.fc24.x86_64 x86_64 kernel.

$ ./configure --enable-python ... checking whether to enable build static executables (binaries)... (cached) no checking whether to enable enable verbose output... (cached) no checking whether to enable enable debug output... (cached) no checking whether to enable build Java bindings... (cached) no checking whether to use use `python-config --prefix' to determine the prefix of pythondir instead of --prefix... (cached) no checking whether to enable build Python bindings... (cached) yes checking whether to use use to specify the Python directory (pythondir)... (cached) no checking for python... python checking for python2.7-config... python2.7-config checking for Python includes... -I/usr/include/python2.7 -I/usr/include/python2.7 checking for Python libraries... -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic checking Python.h usability... yes checking Python.h presence... yes checking for Python.h... yes checking whether to enable build Python 2 bindings... (cached) no checking whether to use use to specify the Python 2 directory (pythondir2)... (cached) no checking whether to enable build Python 3 bindings... (cached) no checking whether to use use to specify the Python 3 directory (pythondir3)... (cached) no checking for stdarg.h... (cached) yes checking for varargs.h... (cached) no checking for dlfcn.h... (cached) yes checking for fmemopen... yes checking for dlsym in -ldl... yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating include/Makefile config.status: creating common/Makefile config.status: creating libcerror/Makefile config.status: creating libcthreads/Makefile config.status: creating libcdata/Makefile config.status: creating libclocale/Makefile config.status: creating libcnotify/Makefile config.status: creating libcsplit/Makefile config.status: creating libuna/Makefile config.status: creating libcfile/Makefile config.status: creating libcpath/Makefile config.status: creating libbfio/Makefile config.status: creating libfcache/Makefile config.status: creating libfdata/Makefile config.status: creating libfdatetime/Makefile config.status: creating libfguid/Makefile config.status: creating libfvalue/Makefile config.status: creating libfwnt/Makefile config.status: creating libfmapi/Makefile config.status: creating libpff/Makefile config.status: creating libcsystem/Makefile config.status: creating pfftools/Makefile config.status: creating jpff/Makefile config.status: creating pypff/Makefile config.status: creating pypff-python2/Makefile config.status: creating pypff-python3/Makefile config.status: creating po/Makefile.in config.status: creating po/Makevars config.status: creating manuals/Makefile config.status: creating tests/Makefile config.status: creating msvscpp/Makefile config.status: creating include/libpff.h config.status: creating include/libpff/definitions.h config.status: creating include/libpff/features.h config.status: creating include/libpff/types.h config.status: creating libpff/libpff_definitions.h config.status: creating common/types.h config.status: creating dpkg/changelog config.status: creating dpkg/copyright config.status: creating libpff/libpff.rc config.status: creating libpff.pc config.status: creating libpff.spec config.status: creating common/config.h config.status: common/config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands config.status: executing po-directories commands config.status: creating po/POTFILES config.status: creating po/Makefile configure: Building: libcerror support: local libcthreads support: local libcdata support: local libclocale support: local libcnotify support: local libcsplit support: local libuna support: local libcfile support: local libcpath support: local libbfio support: local libfcache support: local libfdata support: local libfdatetime support: local libfguid support: local libfvalue support: local libfwnt support: local libfmapi support: local DEFLATE compression support: zlib libcsystem support: local Features: Multi-threading support: pthread Wide character type support: no pfftools are build as static executables: no Java (jpff) support: no Python (pypff) support: 2.7 Python version 2 (pypff) support: no Python version 3 (pypff) support: no Verbose output: no Debug output: no

$ cat Parse_Msg.py import pypff pypff.get_version()

$ python Parse_Msg.py Traceback (most recent call last): File "Parse_Msg.py", line 1, in import pypff ImportError: No module named pypff

Any ideas what's going wrong here?

joachimmetz commented 6 years ago
fligi7 commented 6 years ago

Yes, ran both make and make install. No pypff to be found...

$ ls -l /usr/lib/python3.5/site-packages/ | grep pypff Nothing found. $ ls -l /usr/lib/python2.7/site-packages/ | grep pypff Nothing found.

joachimmetz commented 6 years ago

What does the output of make install tell you where pypff.so is installed?

fligi7 commented 6 years ago

make install

...

/bin/mkdir -p '/usr/local/lib' /bin/sh ../libtool --mode=install /bin/install -c libpff.la '/usr/local/lib' libtool: install: /bin/install -c .libs/libpff.so.1.0.0 /usr/local/lib/libpff.so.1.0.0 libtool: install: (cd /usr/local/lib && { ln -s -f libpff.so.1.0.0 libpff.so.1 || { rm -f libpff.so.1 && ln -s libpff.so.1.0.0 libpff.so.1; }; }) libtool: install: (cd /usr/local/lib && { ln -s -f libpff.so.1.0.0 libpff.so || { rm -f libpff.so && ln -s libpff.so.1.0.0 libpff.so; }; }) libtool: install: /bin/install -c .libs/libpff.lai /usr/local/lib/libpff.la libtool: install: /bin/install -c .libs/libpff.a /usr/local/lib/libpff.a libtool: install: chmod 644 /usr/local/lib/libpff.a libtool: install: ranlib /usr/local/lib/libpff.a libtool: finish: PATH="/sbin:/bin:/usr/sbin:/usr/bin:/sbin" ldconfig -n /usr/local/lib

Libraries have been installed in: /usr/local/lib

joachimmetz commented 6 years ago

Can you try:

./configure --prefix /usr/ --enable-python
make
sudo make install
fligi7 commented 6 years ago

That seemed to work. Any ideas what happened to prevent this in the future?

joachimmetz commented 6 years ago

What I assume is that pypff.so might have been installed under /usr/local/.

fligi7 commented 6 years ago

Though this appears to have successfully installed for python2.7, it does not appear to have installed for python3.

$ python2.7 Python 2.7.13 (default, May 10 2017, 20:04:36) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. $ import pypff $ exit()

$ python3 Python 3.5.3 (default, May 11 2017, 09:10:41) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. $ import pypff Traceback (most recent call last): File "", line 1, in ImportError: No module named 'pypff' $ exit()

How might I get the python3 bindings installed?

ektich commented 6 years ago

@fligi7 try running ./configure --prefix /usr/ --with-python --with-python3 before running make and make install

joachimmetz commented 6 years ago

Assuming questions have been answered closing issue

fligi7 commented 6 years ago

Sorry for not seeing this. I tried it again per https://github.com/libyal/libpff/issues/52#issuecomment-378676492.

While it works for importing pypff in interactive python mode (as I did here https://github.com/libyal/libpff/issues/52#issuecomment-373797742), it still produces an ImportError when used in a python program.

So, not sure what all is going on here.

joachimmetz commented 6 years ago

My guess your Python configuration is not able to find pypff.so. You'll need to compile the bindings for both Python 2 and 3 and install it in the python version specific site-packages / dist-packages directory (for both Python versions independently). Running python -vv will give you more debug output, that might hint what is going on.

Otherwise try inside a virtualenv, pip install libpff-python

tomrade commented 5 years ago

Hey I had this issue but found that on ubuntu (18.04) moving the module from "python3" to "python3.6" fixed the import error. When I had an interactive prompt it use the "python3" path as noted by fligi7. sudo cp /usr/local/lib/python3/dist-packages/pypff.* /usr/local/lib/python3.6/dist-packages/ fixed this for me (in scripts)

apdullahyayik commented 4 years ago

I have successfully implemented binding on Ubuntu 19.10, however at windows 10 there exist an error after the commands below. Any help will be appreciated.

Thanks

Commands: cd libpff ./synclibs.sh ./autogen.sh ./configure --prefix /usr/ --with-python –with-python3 Error: to use local version... (cached) auto-detect ./configure: line 15879: syntax error near unexpected token newline' ./configure: line 15879: PKG_CHECK_MODULES('

joachimmetz commented 4 years ago

@apdullahyayik

  1. you are hijacking a closed thread with your issue, please don't do this !
  2. don't build from git directly unless you want to develop libpff (see: https://github.com/libyal/libpff/wiki/Building#read-first)
  3. provide more detail about your build environment (Cygwin, MinGW)