seveas / python-prctl

Wrapping prctl for python

Home Page:http://packages.python.org/python-prctl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to disable the environment checks for cross-compiling

mawe42 opened this issue · comments

I'm using python-prctl 1.6.1 in a project where I cross-compile everything using buildroot. The Python setuptools infrastructure makes this very easy, it honors environment variables that tell it where to find the compiler, which cflags to use etc.

But I've got a small problem with the additional environment checks that are done in python-prctl's setup.py. They assume that python-prctl is compiled on the system that it will be eventually used on. I've recently set up a new development system that didn't have the libcap headers installed. And the build fails because the host cpp doesn't have the headers installed. When I remove the check from setup.py, it compiles without problems (as the target compiler has the headers available).

Do you think it would be possible to either honour the standard environment variables to find the compiler or add an argument to setup.py to disable these environment checks?

I'd rather not disable the checks, but making them use the right compiler in a cross-compilation setting would be a good idea. I have no experience with this though, would you mind creating a patch or pr that implements this?

Making the compiler and header checks work with cross-compilation will be fairly easy, I can prepare a pull request for those. But the other environment checks will probably never work in a cross-compilation scenario. Consider the case where somebody uses a Mac to cross-compile to Linux. The checks using sys.platform and os.uname() will always fail here.

Is the reason for these environment checks simply to give the user nicer error messages? Or is there a chance that compilation suceeds but the module will simply not work?

The sole reason is to give clear error messages instead of compilers complaining about headerfiles or symbols. I hadn't even thought of the compile-on-mac-for-linux scenario.

It seems that distutils.util.get_platform can be used to return the target platform when cross-compiling. At least pyinotify can be cross-compiled with those checks:
https://github.com/seb-m/pyinotify/blob/master/setup.py

I'll have a play around and draft a PR if I find something that works.

Closing this stale issue, a PR would still be welcome though.

Ah, I completely forgot about this issue, sorry. I am still using prctl and cross-compile it. Will check what I've done to make it work. It's quite a long time ago... :-)

Hm. Honestly I can't remember what the problem was. And I can't see any patch or workaround in use in my cross-compile buildroot setup for python-prcrl: https://github.com/midigurdy/mg-build/tree/master/package/python-prctl

So it seems the problem was either invalid or has since been fixed. Sorry for the noise!