Search code examples
pythonyamlpyyamllibyaml

PyYAML: how to specify an include directory?


I build libyaml and install it into a local area:

yaml-0.1.5 $ ./configure --prefix=/usr/local/sqlminus
yaml-0.1.5 $ make install

yaml-0.1.5 $ ls -l /usr/local/sqlminus/include/yaml.h
-rw-r--r--@ 1 mh admin 54225 Jan 5 09:05 /usr/local/sqlminus/include/yaml.h

But when I build PyYAML, it cannot find yaml.h.

PyYAML-3.11 $ /usr/local/sqlminus/bin/python setup.py build

checking if libyaml is compilable
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall 
    -Wstrict-prototypes -I/usr/local/sqlminus/include/python2.7
-c build/temp.macosx-10.4-x86_64-2.7/check_libyaml.c
-o build/temp.macosx-10.4-x86_64-2.7/check_libyaml.o
build/temp.macosx-10.4-x86_64-2.7/check_libyaml.c:2:10:
fatal error: 'yaml.h'
      file not found
#include <yaml.h>
         ^
1 error generated.

How can I tell PyYAML where I've installed libyaml?


Solution

  • (update) Based on dotslash's comment below, editing setup.cfg and adding these two lines made everything work smoothly.

    include_dirs=/usr/local/sqlminus/include
    library_dirs=/usr/local/sqlminus/lib
    

    (end update)

    I think you should install dependencies.

    If you are using Ubuntu or Debian based system, you could search by this

    apt-cache search libyaml
    

    Then you may find there are some packages related.

    I would suggest you try to install this: apt-get install libyaml-dev -y

    If you are using Mac OS, you could change the source in file check_libyaml.c, tell it what the absolute path of yaml.h is.

    Or just specify the path while compiling

    python setup.py config --with-includepath=/path/to/your/install/of/python/includes/
    

    Then go compiling.

    More info can be found here.

    Hope this be helpful.