4

I have a working cross compile of Python, however I've tried cross compiling the py-smbus extension from i2c-tools using distutilscross and can't get past the command line.

The documentation (https://pypi.python.org/pypi/distutilscross) suggests that it should be as easy as python setup.py build -x (after setting appropriate environment variables), however when I run that command the '-x' triggers a bad-argument error.

Does anyone know how to fix this?

Sparky
  • 2,694
  • 3
  • 21
  • 31
  • Did you ever find an answer to this? I'm running into the exact same problem and trying to using distutilscross with no success. – Brian McFarland Feb 20 '15 at 19:38
  • I think this has remained a mystery, I think in the end I gave up end and wrote my own C shim for it. Sorry! – Sparky Feb 23 '15 at 11:47
  • First I ended up just pulling all the CFLAGS stuff out of the main Makefile for the x-compiled Python, but there's also info in [here](https://docs.python.org/2/extending/extending.html#compilation-and-linkage) on how to include you modules directly in the main compilation of Python which is probably better long-term for my purposes. – Brian McFarland Feb 23 '15 at 13:57

2 Answers2

1

Something along the lines of this approach worked for me:

export CC=your-platform-triple-gcc
export LDSHARED="your-platform-triple-ld -shared"
python setup.py build
ulidtko
  • 14,740
  • 10
  • 56
  • 88
1

This is probably because the setup.py file uses distutils instead of setuptools. If you look in the comments of Chris' post, he has a quick fix for this problem:

python -c "import setuptools; execfile('setup.py')" -x build

http://whatschrisdoing.com/blog/2009/10/16/cross-compiling-python-extensions/