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
286 stars 74 forks source link

Change configure for building for Python >= 3.7 on MacOS >= 10.14? #83

Closed Themanwithoutaplan closed 4 years ago

Themanwithoutaplan commented 4 years ago

It's looks like configure needs some updating for more recent versions of Python. I'm using MacOS 10.14 (Mojave) and use MacPorts to manage my versions of Python. I've followed instructions and, with some minimal changes to Configure, I have managed to get libpff to build but the Python bindings are empty. I did see something about a missing header file by but my C/C++ skills are non-existent.

I'm including the adjusted Configure and the log. I created a link for python3-config to python-config which is mandatory and this is the command

I used CFLAGS=-I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/ LDFLAGS=-L/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/ ./configure --enable-python3 configure.txt config.log

joachimmetz commented 4 years ago

configure is auto-generated from configure.ac, can you indicate what you've changed?

Themanwithoutaplan commented 4 years ago

As you can see not much

diff configure configure.txt
51604c51604
<   ax_python_progs="python python2 python2.7 python2.6 python2.5 python3 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0"
---
>   ax_python_progs="python python2 python2.7 python3 python3.7 python3.6 python3.5"
52148c52148
<   ax_python3_progs="python3 python3.4 python3.3 python3.2 python3.1 python3.0"
---
>   ax_python3_progs="python3 python3.7 python3.6 python3.5"
joachimmetz commented 4 years ago

I see, similar changes had been made to the development version in https://github.com/libyal/libpff/commit/f3a2f8e124d00851646d5a9ab38cf74b5a04eee6#diff-359d523afb08173765a8cf63d0291c0e

Themanwithoutaplan commented 4 years ago

Should I try using the checkout? If so, based on the notes on building, what exactly do I need to do, ie. get the dependencies?

joachimmetz commented 4 years ago

what exactly do I need to do, ie. get the dependencies?

That's described here: https://github.com/libyal/libpff/wiki/Building#git

Should I try using the checkout?

Is up to you, know that the Python bindings are still work in progress https://github.com/libyal/libpff/issues/2

Themanwithoutaplan commented 4 years ago

Well, it compiles okay but the end result is much the same: pypff exists buts is empty.

 /bin/sh ../libtool   --mode=install /usr/bin/install -c   pypff.la '/usr/local/lib/python3.8/site-packages'
libtool: install: /usr/bin/install -c .libs/pypff.so /usr/local/lib/python3.8/site-packages/pypff.so
libtool: install: /usr/bin/install -c .libs/pypff.lai /usr/local/lib/python3.8/site-packages/pypff.la
libtool: install: /usr/bin/install -c .libs/pypff.a /usr/local/lib/python3.8/site-packages/pypff.a
libtool: install: chmod 644 /usr/local/lib/python3.8/site-packages/pypff.a
libtool: install: ranlib /usr/local/lib/python3.8/site-packages/pypff.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libcerror_support.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libcdata_error.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libcdata_support.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libclocale_wide_string.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libcfile_error.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libcfile_notify.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libcpath_error.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libcpath_support.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libbfio_error.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/python3.8/site-packages/pypff.a(libbfio_support.o) has no symbols
joachimmetz commented 4 years ago

what do you mean with empty ?

If you're referring to "pypff.a(libbfio_support.o) has no symbols" pypff.a is not the python module pyfff.so is

Themanwithoutaplan commented 4 years ago

I thought it was clear from the paste "no symols" but this from the shell:

Python 3.8.0 (default, Oct 16 2019, 08:51:22)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pypff
>>> dir(pypff)
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> pypff.get_version()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pypff' has no attribute 'get_version'

I wonder if I'm doing something stupid?

joachimmetz commented 4 years ago

I thought it was clear from the paste "no symols" but this from the shell

pypff.a is not the Python module, pypff.so is so that warning is not relevant. Also it warns about internally used local libraries only.

I wonder if I'm doing something stupid?

what does the following tell you: print(pypff.__file__)

Themanwithoutaplan commented 4 years ago
>>> import pypff
>>> print(pypff.__file__)
None
joachimmetz commented 4 years ago
Themanwithoutaplan commented 4 years ago

I followed the instructions on the Wiki: passed in the CFLAGS and LFLAGS into configure and use port select python to set the correction version then make && sudo make install.

joachimmetz commented 4 years ago

The flags mentioned here https://github.com/libyal/libpff/wiki/Building#mac-os-x-1 are for the system Python version (on older versions of Mac OS X). They are very specific to your version of Mac OS X and Python.

If you've installed Python via ports those locations are likely to be different.

For troubleshooting try running the Python module directly from the source directory, this would look something like:

DYLD_LIBRARY_PATH="libpff/.libs" PYTHONPATH="pypff/.libs" python

Or (if you only want a Python module) try using ./setup.py instead

Themanwithoutaplan commented 4 years ago

>>> import pypff
>>> print(pypff.__file__)
/Users/charlieclark/temp/libpff/pypff/.libs/pypff.so
>>> pypff.get_version()
'20190904'
``´
I can probably work with that, thanks.

python-config is managed by port select python so the flags should be available to the build process but I did use the paths for the relevant Python versions but if I didn't include them then configure refuses to run.
joachimmetz commented 4 years ago

Seeing it is working from the source directory, you likely have another build of pypff.so somewhere on your system that was not build properly. Look for it find / -name pypff.so and I opt to remove it, or replace it with the working version.

Themanwithoutaplan commented 4 years ago

Looks I had some remnants from my previous attempts. Removing them an replacing them with the one form pyff/.libs doesn't work, however.

Themanwithoutaplan commented 4 years ago

Are the Python docs out of date? I can open my PST but the methods don't match the docs. FWIW it is just an address book that I'm hoping will be easier to work with than a CSV with all the line breaks.

>>> pff_file = pypff.file()
>>> pff_file.open("backup.pst")
>>> pff_file.items
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'pypff.file' object has no attribute 'items'
>>> help(pff_file)

>>> dir(pff_file)
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'ascii_codepage', 'close', 'content_type', 'encryption_type', 'get_ascii_codepage', 'get_content_type', 'get_encryption_type', 'get_message_store', 'get_name_to_id_map', 'get_number_of_orphan_items', 'get_orphan_item', 'get_root_folder', 'get_root_item', 'get_size', 'message_store', 'name_to_id_map', 'number_of_orphan_items', 'open', 'open_file_object', 'orphan_items', 'root_folder', 'root_item', 'set_ascii_codepage', 'signal_abort', 'size']
joachimmetz commented 4 years ago

Documentation updated, per https://github.com/libyal/libpff/issues/2 Python bindings are under development, closing issue