Flask Development on a Raspberry Pi

Currently the flog project requires lxml as a dependency. I had some issues pulling this in.

~ $ cd py_toy/
~/py_toy $ cat dependencies.txt
lxml
~/py_toy $ virtualenv -p `which python3` venv
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in venv/bin/python3
Also creating executable in venv/bin/python
Installing setuptools, pip...done.
~/py_toy $ . venv/bin/activate
(venv)~/py_toy $ time pip install -r dependencies.txt
[ output truncated ]
    creating build/temp.linux-armv6l-3.4/src/lxml

    gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-3ikmlcvh/lxml/src/lxml/includes -I/usr/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-armv6l-3.4/src/lxml/lxml.etree.o -w

    gcc: internal compiler error: Killed (program cc1)

    Please submit a full bug report,

    with preprocessed source if appropriate.

    See <https://github.com/archlinuxarm/PKGBUILDs/issues> for instructions.

    /usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'

      warnings.warn(msg)

    error: command 'gcc' failed with exit status 4

    ----------------------------------------
    Command "/root/py_toy/venv/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-3ikmlcvh/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ytt52_hh-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/py_toy/venv/include/site/python3.4" failed with error code 1 in /tmp/pip-build-3ikmlcvh/lxml

real    27m18.069s
user    26m55.390s
sys     0m11.620s
(venv)~/py_toy $

I was exhausting all 512 MB of memory. As a workaround, I temporarily employed a 512 MB swapfile on the SD card.

(venv)~/py_toy $ sudo dd if=/dev/zero of=/swapfile bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 132.228 s, 4.1 MB/s
(venv)~/py_toy $ sudo mkswap /swapfile
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=c45c43c4-00dd-463b-a5ca-30ddeb0b102e
(venv)~/py_toy $ sudo chmod 600 /swapfile
(venv)~/py_toy $ sudo swapon /swapfile
(venv)~/py_toy $ time pip install -r dependencies.txt 
Collecting lxml (from -r dependencies.txt (line 1))
  Using cached lxml-3.4.2.tar.gz
    Building lxml version 3.4.2.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    Building against libxml2/libxslt in the following directory: /usr/lib
    /usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
Installing collected packages: lxml
  Running setup.py install for lxml
    Building lxml version 3.4.2.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    Building against libxml2/libxslt in the following directory: /usr/lib
    building 'lxml.etree' extension
    gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-8m8hfu47/lxml/src/lxml/includes -I/usr/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-armv6l-3.4/src/lxml/lxml.etree.o -w
    gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro build/temp.linux-armv6l-3.4/src/lxml/lxml.etree.o -L/usr/lib -L/usr/lib -lxslt -lexslt -lxml2 -lz -lm -lpython3.4m -o build/lib.linux-armv6l-3.4/lxml/etree.cpython-34m.so
    building 'lxml.objectify' extension
    gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-8m8hfu47/lxml/src/lxml/includes -I/usr/include/python3.4m -c src/lxml/lxml.objectify.c -o build/temp.linux-armv6l-3.4/src/lxml/lxml.objectify.o -w
    gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro build/temp.linux-armv6l-3.4/src/lxml/lxml.objectify.o -L/usr/lib -L/usr/lib -lxslt -lexslt -lxml2 -lz -lm -lpython3.4m -o build/lib.linux-armv6l-3.4/lxml/objectify.cpython-34m.so
    /usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
Successfully installed lxml-3.4.2

real	33m46.351s
user	32m43.210s
sys	0m16.700s
(venv)~/py_toy $

Success!