Ticket #232 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

cross-compiled python-2.6.2 doesn't provide ctypes-module

Reported by: spielc Owned by:
Priority: major Milestone: milestone4
Component: target Keywords:
Cc:

Description

After i finished my exams i was able to poke into OpenMoko?-stuff again. I tried to upgrade python to version 2.6.2 on both host and target and was only partly successfull. After a bit of poking around i was finally able to get host to compile ctypes-module successfully but i'm still unable to make it work on host.

python
Python 2.6.2 (r262:71600, Jun  3 2009, 13:43:47)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes;
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/ctypes/__init__.py", line 10, in <module>
    from _ctypes import Union, Structure, Array
ImportError: No module named _ctypes

On host it works on the other hand:

python
Python 2.6.2 (r262:71600, May 19 2009, 15:03:34)
[GCC 4.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes;
>>> quit();

I'll attach my build.log to the bug-report maybe somebody else can make a sense of it...

Attachments

buildlog.tar.bz2 (49.5 kB) - added by spielc 3 years ago.
python-2.6-enable-ctypes-cross-build.patch (2.3 kB) - added by spielc 3 years ago.
python-2.6-enable-ctypes-cross-build.2.patch (2.3 kB) - added by sleipnir 3 years ago.
Slightly modified spielc patch

Change History

Changed 3 years ago by spielc

  Changed 3 years ago by max_posedon

check that python at host and target from our overlay

Welcome back!)

follow-up: ↓ 4   Changed 3 years ago by sleipnir

Welcome back! When looking into your build.log I found the line

Failed to configure _ctypes module (res=256) or missing conffile=build/temp.linux-x86_64-2.6/libffi/fficonfig.py

Can you please try with ffi disabled!? I thing up to now nobody tried to compile this thing _with_ ffi, so maybe the patch for ctypes is wrong in this case.

  Changed 3 years ago by sleipnir

  • milestone changed from unsorted to milestone4

in reply to: ↑ 2   Changed 3 years ago by spielc

After a bit more digging i found the problem: autoreconf is a link to /usr/lib/ac-wrapper.sh.

If you you just run autoreconf it tries to run autoconf-2.63 (which is the latest version of autoconf installed on my computer) and the version of libffi that is bundled with python seems to choke on autoconf-2.63. if you run autoconf-2.13 directly instead everything works as expected.

python
Python 2.6.2 (r262:71600, Jun  4 2009, 17:02:57)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes;
>>> quit();

Here's the change i had to apply to python-2.6-enable-ctypes-cross-build.patch to make ctypes work again:

--- python-2.6-enable-ctypes-cross-build.patch.orig     2009-06-04 16:52:30.627777623 +0200
+++ python-2.6-enable-ctypes-cross-build.patch  2009-06-04 16:59:08.927080877 +0200
@@ -16,7 +16,7 @@
                  # CFLAGS to Python's; -g or -O2 is to be avoided.
 -                cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
 -                      % (ffi_builddir, ffi_srcdir, " ".join(config_args))
-+                cmd = "(cd %s && autoreconf -W cross) && (cd %s && env CFLAGS='' '%s/configure' %s)" \
++                cmd = "(cd %s && autoreconf-2.13) && (cd %s && env CFLAGS='' '%s/configure' %s)" \
 +                      % (ffi_srcdir, ffi_builddir, ffi_srcdir, " ".join(config_args))

                  res = os.system(cmd)

Replying to sleipnir:

Welcome back! When looking into your build.log I found the line {{{ Failed to configure _ctypes module (res=256) or missing conffile=build/temp.linux-x86_64-2.6/libffi/fficonfig.py }}} Can you please try with ffi disabled!? I thing up to now nobody tried to compile this thing _with_ ffi, so maybe the patch for ctypes is wrong in this case.

follow-up: ↓ 6   Changed 3 years ago by sleipnir

Hmmm I don't like the version number in there, as it means everyone needs this exact version to be installed... If I got you correctly, then the problem is in libffi. Can you dig a bit deeper and see what fails there with the new autoconf!? Is there an upstream bugreport on this (as I think this would affect more ppl)?

in reply to: ↑ 5   Changed 3 years ago by spielc

Well your wish is my command. I reworked python-2.6-enable-ctypes-cross-build.patch and this works without having to use a specific version number. The main problem is that the version of libffi that is bundled with python is quite old (libffi-3.0.5 was released on April 3, 2008) and Autoconf-2.63 is ALOT stricter when it comes to checks than earlier versions. That's why it bailed out on me. Anyway the attached patch made things work for me again.

Replying to sleipnir:

Hmmm I don't like the version number in there, as it means everyone needs this exact version to be installed... If I got you correctly, then the problem is in libffi. Can you dig a bit deeper and see what fails there with the new autoconf!? Is there an upstream bugreport on this (as I think this would affect more ppl)?

Changed 3 years ago by spielc

follow-up: ↓ 8   Changed 3 years ago by sleipnir

One question concerning your patch. Is the double ffi_srcdir necessary in the following line?

cmd = "(cd %s && aclocal && libtoolize && automake --add-missing --copy && autoreconf) && (cd %s && env CFLAGS='' '%s/configure' %s)" \
        % (ffi_srcdir, ffi_builddir, ffi_srcdir, " ".join(config_args))

in reply to: ↑ 7   Changed 3 years ago by spielc

Hmm good question. This part is from the original patch. The only thing i have changed are the additional calls of aclocal, automake... before running autoreconf. So my guess is that these things are necessary

Replying to sleipnir:

One question concerning your patch. Is the double ffi_srcdir necessary in the following line? {{{ cmd = "(cd %s && aclocal && libtoolize && automake --add-missing --copy && autoreconf) && (cd %s && env CFLAGS= '%s/configure' %s)" \ % (ffi_srcdir, ffi_builddir, ffi_srcdir, " ".join(config_args)) }}}

follow-up: ↓ 10   Changed 3 years ago by aelia

I have a little problem, ctypes is NOT compiled natively in my setup... I get a weird warning during autotools, and then an error :

creating build/temp.linux-armv4tl-2.6/libffi automake-1.10: unknown warning category `cross' configure.ac:31: required file `./compile' not found configure.ac:31: automake --add-missing' can install compile' configure.ac:32: required file `./ltmain.sh' not found automake-1.10: no `Makefile.am' found for any configure output automake-1.10: Did you forget AC_CONFIG_FILES([Makefile]) in configure.ac? autoreconf-2.63: automake failed with exit status: 1 Failed to configure _ctypes module (res=256) or missing conffile=build/temp.linux-armv4tl-2.6/libffi/fficonfig.py

I get the same thing twice, the first during compile, the second during install. Is it somhow linked to the cross-compile patch ? because a patch to make it cross-compile that breaks native compilation would be annoing...

in reply to: ↑ 9   Changed 3 years ago by spielc

That is the same error i got while trying to cross-compile python. I assume you have autoconf-2.63 installed and this ones alot stricter than older versions of autoconf (just look at my comment above). Could you try to replace the provided python-2.6-enable-ctypes-cross-build.patch with the version i attached to this bug-report and emerge it again? I guess that this patch should solve your problems.

Replying to aelia:

I have a little problem, ctypes is NOT compiled natively in my setup... I get a weird warning during autotools, and then an error : creating build/temp.linux-armv4tl-2.6/libffi automake-1.10: unknown warning category `cross' configure.ac:31: required file `./compile' not found configure.ac:31: automake --add-missing' can install compile' configure.ac:32: required file `./ltmain.sh' not found automake-1.10: no `Makefile.am' found for any configure output automake-1.10: Did you forget AC_CONFIG_FILES([Makefile]) in configure.ac? autoreconf-2.63: automake failed with exit status: 1 Failed to configure _ctypes module (res=256) or missing conffile=build/temp.linux-armv4tl-2.6/libffi/fficonfig.py I get the same thing twice, the first during compile, the second during install. Is it somhow linked to the cross-compile patch ? because a patch to make it cross-compile that breaks native compilation would be annoing...

follow-up: ↓ 13   Changed 3 years ago by sleipnir

spielc: Can you please test another patch for me? Please apply the attached patch and report back the result! This is a slightly modified version of your patch that replaces the original

autoreconf -W cross

with

autoreconf
}}}.

Changed 3 years ago by sleipnir

Slightly modified spielc patch

  Changed 3 years ago by dagger

last patch gives me:

var/tmp/paludis/dev-lang-python-2.6.2-r1/work/Python-2.6.2/Modules/mathmodule.c:574: warning: passing argument 1 of 'PyFPE_dummy' discards qualifiers from pointer target type configure.ac:31: required file `./compile' not found configure.ac:31: automake --add-missing' can install compile' configure.ac:32: required file `./ltmain.sh' not found Makefile.am: required file `./depcomp' not found Makefile.am: automake --add-missing' can install depcomp' Makefile.am:35: required file `./texinfo.tex' not found Makefile.am:35: automake --add-missing' can install texinfo.tex' autoreconf-2.63: automake failed with exit status: 1 Failed to configure _ctypes module (res=256) or missing conffile=build/temp.linux-x86_64-2.6/libffi/fficonfig.py

Failed to find the necessary bits to build these modules: _bsddb _tkinter bsddb185 sunaudiodev To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Done src_compile

in reply to: ↑ 11   Changed 3 years ago by spielc

Don't need to test that because that was the first idea for a fix that i came up with and the result was the same (see below or above just as you wish ;) ). I ONLY got it work with my patch.

Replying to sleipnir:

spielc: Can you please test another patch for me? Please apply the attached patch and report back the result! This is a slightly modified version of your patch that replaces the original {{{ autoreconf -W cross }}} with {{{ autoreconf }}}.

  Changed 3 years ago by dagger

  • status changed from new to closed
  • resolution set to fixed

That should be now fixed. Please sync the overlay and rebuild python.

If you still have problem, please re-open this ticket.

Note: See TracTickets for help on using tickets.