WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Cannot build a python extension (C or Cython) on piCore 9.0.3  (Read 2938 times)

Offline MarkF

  • Newbie
  • *
  • Posts: 7
I have been trying to create a Python extension on a rPI Z W (piCore 9.0.3) for 2 days.  Every time I try to build I get an error about a missing header file (limits.h).  Here are the outputs from building a C module and a Cython (.pyx) module -

Code: [Select]
tc@box:~/scripts$ python setup_cython.py build_ext --inplace
running build_ext
building 'Adafruit_SSD1306_Packer' extension
gcc -pthread -fno-strict-aliasing -O3 -pipe -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.7 -c Adafruit_SSD1306_Packer.c -o build/temp.linux-armv6l-2.7/Adafruit_SSD1306_Packer.o
gcc: error trying to exec 'as': execvp: No such file or directory
In file included from /tmp/tcloop/gcc/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/7.1.0/include-fixed/limits.h:194:0,
                 from /tmp/tcloop/gcc/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/7.1.0/include-fixed/syslimits.h:7,
                 from /tmp/tcloop/gcc/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/7.1.0/include-fixed/limits.h:34,
                 from /usr/local/include/python2.7/Python.h:19,
                 from Adafruit_SSD1306_Packer.c:24:
/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/7.1.0/include-fixed/limits.h:194:15: fatal error: limits.h: No such file or directory
 #include_next <limits.h>  /* recurse down to the real one */
               ^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

tc@box:~/scripts$ python setup_c.py build
running build
running build_ext
building 'packer' extension
gcc -pthread -fno-strict-aliasing -O3 -pipe -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.7 -c packer.c -o build/temp.linux-armv6l-2.7/packer.o
gcc: error trying to exec 'as': execvp: No such file or directory
In file included from /tmp/tcloop/gcc/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/7.1.0/include-fixed/limits.h:194:0,
                 from /tmp/tcloop/gcc/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/7.1.0/include-fixed/syslimits.h:7,
                 from /tmp/tcloop/gcc/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/7.1.0/include-fixed/limits.h:34,
                 from /usr/local/include/python2.7/Python.h:19,
                 from packer.c:3:
/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/7.1.0/include-fixed/limits.h:194:15: fatal error: limits.h: No such file or directory
 #include_next <limits.h>  /* recurse down to the real one */
               ^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

tc@box:~/scripts$

By the way, line 19 of /usr/local/include/python2.7/Python.h is -
Code: [Select]
#include <limits.h>

As you can see, the error outputs are exactly the same.  The limits.h file fails in some sort of recursion.

I loaded python, python-dev, gcc, cython, linux-4.9.y_api_headers and some other TCZs.  I thought python-dev would take care of any other dependencies that it has?

Any suggestions?  Is the order of loading TCZs important?  I'm new to piCore as a development environment so I hope this isn't an obvious or well known error.  :-[  My searching didn't find it.

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Re: Cannot build a python extension (C or Cython) on piCore 9.0.3
« Reply #1 on: April 03, 2019, 09:10:07 AM »
Did you load compiletc?

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: Cannot build a python extension (C or Cython) on piCore 9.0.3
« Reply #2 on: April 03, 2019, 09:11:00 AM »
Hi MarkF
You need  compiletc.tcz  for a proper toolchain.

Offline MarkF

  • Newbie
  • *
  • Posts: 7
Re: Cannot build a python extension (C or Cython) on piCore 9.0.3
« Reply #3 on: April 03, 2019, 12:22:48 PM »
Thanks Juanito and Rich!  I haven't loaded compiletc, but I will and will reply again.

Is there some documentation about this that I missed? (which TCs to fill out a toolchain?)

EDIT: Success!!!  Thanks, again.  Both compile now.
« Last Edit: April 03, 2019, 12:28:13 PM by MarkF »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: Cannot build a python extension (C or Cython) on piCore 9.0.3
« Reply #4 on: April 03, 2019, 12:44:35 PM »
Hi MarkF
... Is there some documentation about this that I missed? ...
If you look at:
http://wiki.tinycorelinux.net/wiki:creating_extensions
at the top of the page it does say:
Quote
Required:
 Your source code and all dependencies
 compiletc extension
 squash file tools extension


Quote
...  (which TCs to fill out a toolchain?) ...
That's the purpose of  compiletc.tcz , so you don't have to figure out which extensions are required for a toolchain. It's a meta
extension that consists of dependencies:
http://tinycorelinux.net/9.x/x86/tcz/compiletc.tcz.dep
or if you wish to see the entire dependency tree:
http://tinycorelinux.net/9.x/x86/tcz/compiletc.tcz.tree

Offline MarkF

  • Newbie
  • *
  • Posts: 7
Re: Cannot build a python extension (C or Cython) on piCore 9.0.3
« Reply #5 on: April 03, 2019, 03:28:30 PM »
Thanks Rich!

Offline MarkF

  • Newbie
  • *
  • Posts: 7
Re: Cannot build a python extension (C or Cython) on piCore 9.0.3
« Reply #6 on: April 03, 2019, 07:10:17 PM »
One last post (for me) and I'll be done.

I am making the Adafruit PiOLED and OLED Bonnet work on a Pi Z W with TC 9.0.3.  The original OLED support file from Adafruit is written in Python and require Pillow to support text and drawing.  I won't be drawing so I made changes so it supports FreeType for text.  After getting things to work, I did a speed test using pure Python and found I got ~11 frames per sec (fps) for a full screen update rate.  When I moved some of the "most executed" code into cython, I got ~20  fps.  By moving the critical code to a C-Module, I now get 118 fps.  Doing byte/bit/buffer manipulation (fill, bitblt, pack, unpack, etc.) in Python is slow.  Thanks to your help, I increased the fps rate by an order of magnitude.

My projects and I thank you.