2) Add the include file to CFLAGS so it is included in every file being compiled, -fPIC to avoid linker errors at the end of the compile, and -lgcrypt to avoid errors importing lxml.gtree:
(myvenv)[ec2-user@ip-172-30-0-8 ~]$ python
Python 2.7.9 (default, Mar 4 2015, 20:43:00)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>> from bs4 import BeautifulSoup
>>> html = "<html><head></head<body><div>I like turnips.</div></body></html>"
>>> bs = BeautifulSoup(html, "lxml")
>>> bs.find('div')
<div>I like turnips.</div>
I was able to get this to compile on an Amazon Linux AMI by doing the following:
1) Create an include file somewhere that looks like this:
[ec2-user@ ip-172- 30-0-8 ~]$ cat tmp_gets.h
#include "stdio.h"
#ifndef gets
extern char *gets (char *__s);
#endif
2) Add the include file to CFLAGS so it is included in every file being compiled, -fPIC to avoid linker errors at the end of the compile, and -lgcrypt to avoid errors importing lxml.gtree:
STATIC_DEPS=true CFLAGS="-include /home/ec2- user/tmp_ gets.h -fPIC -lgcrypt" pip install lxml
(myvenv) [ec2-user@ ip-172- 30-0-8 ~]$ python <head>< /head<body> <div>I like turnips. </div>< /body>< /html>"
Python 2.7.9 (default, Mar 4 2015, 20:43:00)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>> from bs4 import BeautifulSoup
>>> html = "<html>
>>> bs = BeautifulSoup(html, "lxml")
>>> bs.find('div')
<div>I like turnips.</div>