Menu

Leopard build problems

Help
2008-01-25
2012-09-19
  • Robert Moggach

    Robert Moggach - 2008-01-25

    I've been unsuccessful at building mysql-python for my i386 architecture MacBook Pro.

    I would prefer not to use fink or macports.

    I've taken the following steps per many sites recommendations:

    1) modify site.cfg
    - disable threadsafe -> set threadsafe = False
    - explicitly set mysql_config to my local build of mysql -> mysql_config = /usr/local/mysql/bin/mysql_config

    2) modify _mysql.c
    - comment out the following lines
    #ifndef uint
    #define uint unsigned int
    #endif

    Build, then sudo install... I get the following error:

    ImproperlyConfigured: Error loading MySQLdb module: dlopen(/var/tmp/.python_eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
    /var/tmp/.python_eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so: no matching architecture in universal wrapper

    My mysql is built with the following configuration:

    MACOSX_DEPLOYMENT_TARGET=10.5 \ CC=gcc \ CFLAGS="-O3 -fno-omit-frame-pointer \ -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64" \ CXX=gcc \ CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors \ -fno-exceptions -fno-rtti \ -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64" \ ./configure --prefix=/usr/local/mysql \ --disable-dependency-tracking --with-extra-charsets=complex --enable-thread-safe-client \ --enable-local-infile --disable-shared

    MySQL is working, mod-python is working, mysql-python is not.

    Please help!

    thanks in advance for any help...

     
    • Robert Moggach

      Robert Moggach - 2008-01-25

      here's the raw output of running 'mysql_config'
      ~/src/MySQL-python-1.2.2 > mysql_config
      Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
      Options:
      --cflags [-I/usr/local/mysql/include/mysql -fno-omit-frame-pointer -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64]
      --include [-I/usr/local/mysql/include/mysql]
      --libs [-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64 -L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm]
      --libs_r [-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64 -L/usr/local/mysql/lib/mysql -lmysqlclient_r -lz -lm]
      --socket [/tmp/mysql.sock]
      --port [3306]
      --version [5.0.51]
      --libmysqld-libs [-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64 -L/usr/local/mysql/lib/mysql -lmysqld -lz -lm]

       
      • geert

        geert - 2008-03-11

        I'm having similar problems, and have een posting down at the mod_wsgi group about them. I have a macmini running 10.5.2 (leopard) , python2.5 at 32-bits, mysql 64. Have been studying the various posts here and there, also from this list. MySQLdb installs, but I keep getting errors when importing the module.

        >>> import MySQLdb
        Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "build/bdist.macosx-10.5-i386/egg/MySQLdb/init.py", line 19, in <module>
        File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 7, in <module>
        File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 6, in bootstrap
        ImportError: dynamic module does not define init function (init_mysql)
        >>>

        >>> import _mysql
        Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 7, in <module>
        File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 6, in bootstrap
        ImportError: dynamic module does not define init function (init_mysql)
        >>>

        I've tried rebuilding (several times :( ) and reinstalling, tried removing old failed installs, etc etc. Also tried setting ARCHFLAGS manually to all architectures (ppc, ppc64, i386, h x86_)

        Has anyone gotten this to work on 10.5.2 with the above specs? It all works perfectly on my dev machine, which is an older MacBook Pro running 32-bit apps only. I really, really need mysql for my django project.

        Geert

         
    • geert

      geert - 2008-03-11

      Just a bit more on this so you know what I've done:

      Rebuilding MySQLdb with ARCHFLAGS set to all architectures

      logict45:MySQL-python-1.2.2 geert$ sudo python setup.py build
      Password:
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.5-i386-2.5
      copying _mysql_exceptions.py -> build/lib.macosx-10.5-i386-2.5
      creating build/lib.macosx-10.5-i386-2.5/MySQLdb
      copying MySQLdb/init.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb
      copying MySQLdb/converters.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb
      copying MySQLdb/connections.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb
      copying MySQLdb/cursors.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb
      copying MySQLdb/release.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb
      copying MySQLdb/times.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb
      creating build/lib.macosx-10.5-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/init.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/CR.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/ER.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb/constants
      running build_ext
      building '_mysql' extension
      creating build/temp.macosx-10.5-i386-2.5
      gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -pipe -Dversion_info=(1,2,2,'final',0) -Dversion=1.2.2 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.5-i386-2.5/_mysql.o -Os -arch x86_64 -fno-common
      gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc build/temp.macosx-10.5-i386-2.5/_mysql.o -L/usr/local/mysql/lib -lmysqlclient -lz -lm -o build/lib.macosx-10.5-i386-2.5/_mysql.so
      ld: warning in build/temp.macosx-10.5-i386-2.5/_mysql.o, file is not of required architecture
      ld: warning in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of required architecture
      ld: warning in build/temp.macosx-10.5-i386-2.5/_mysql.o, file is not of required architecture
      ld: warning in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of required architecture

      I'm looking at the -arch flags specifically now. It doesn't look as if I'm overriding the arch flags at all. The docs state that setup goes for mysql_config, but looking at the arch flags there, it says:

      logict45:MySQL-python-1.2.2 geert$ mysql_config
      Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
      Options:
      --cflags [-I/usr/local/mysql/include -Os -arch x86_64 -fno-common]
      --include [-I/usr/local/mysql/include]
      --libs [-L/usr/local/mysql/lib -lmysqlclient -lz -lm]
      --libs_r [-L/usr/local/mysql/lib -lmysqlclient_r -lz -lm]
      --socket [/tmp/mysql.sock]
      --port [3306]
      --version [5.0.51a]
      --libmysqld-libs [-L/usr/local/mysql/lib -lmysqld -lz -lm]

      so just x86_64

      Anyway, this could all be the wrong road to take to get the thing working. Anyone?

      Geert

       
      • Kyle VanderBeek

        Kyle VanderBeek - 2008-03-11

        It looks like you have x86_64 MySQL client libraries and (possibly) a i386 32-bit python. That won't fly. What is the output of "python-config --cflags"?

         
    • geert

      geert - 2008-03-12

      -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE

       
    • geert

      geert - 2008-03-12

      And - anyone using my setup - which is 10.5.2 on a new (intel) mac - would be running into this. Someone MUST have gotten this running, no?

      Geert

       
      • Robert Moggach

        Robert Moggach - 2008-03-22

        The problem is the architecture of mysql, mysql-python, mod-python, and apache.... I made all the same and was able to get it working. Obviously it's nice to use the out of the box installs which is possible but you have to trim off the PowerPC code using ditto or lipo. First check the architecture of each of the applications in question and the .so files for the plugins using the 'file' command and then backup your fat files and create a slimmed set of files with a consistent architecture. I have django runnning smoothly and had to run through this again after the last security update updated apache.

         
        • Leo Hourvitz

          Leo Hourvitz - 2008-03-23

          Thanks for posting all your progress. Interestingly, I just upgraded to Mac OS X 10.5 and my old Python+MySQLdb+Django+mod_python+Apache2 all continued to work fine unmodified (I'm not using the python that came with the system: for version reasons I had to create a separate Python in /usr/local before, and I'm continuing to use that).

          It's consistent with what you said, presumably all my old versions have a consistent architecture, even those I would get different results if I rebuilt now with the 10.5 Developer Tools.

          Leo

           
    • Portante

      Portante - 2008-03-22

      $ # On my Leopard installation (10.5.2, MacBook Pro), I have
      $ # Python 2.5.2 and MySQL 5.0.51a (32 bit) installed.
      $
      $ mysql_config --cflags
      -I/usr/local/mysql/include -Os -arch i386 -fno-common
      $ python-config --cflags
      -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 \ -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 \ -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd \ -fno-common -dynamic -DNDEBUG -g -O3
      $
      $ # From what I can tell:
      $ #
      $ # MySQL-python-1.2.2's setup_posix.py file specifies the
      $ # 'extra_compile_args' as '-Os -arch i386 -fno-common',
      $ # the output from the 'mysql_config --clfags' above.
      $ #
      $ # The distutils uses extra_compile_args when it constructs
      $ # the compiler command lines. However, the compile command
      $ # setup for MacOS eats all "-arch" flags from the python
      $ # derived flags if extra_compile_args has a -arch. From the
      $ # distutils/unixcompile.py's _darwin_compiler_fixup():
      $ #
      $ # This function will strip '-isysroot PATH' and
      $ # '-arch ARCH' from the compile flags if the user
      $ # has specified one them in extra_compile_args.
      $ # This is needed because '-arch ARCH' adds another
      $ # architecture to the build, without a way to
      $ # remove an architecture. Furthermore GCC will
      $ # barf if multiple '-isysroot' arguments are present.
      $ #
      $ # You apparently have a 64-bit MySQL installed, x86_64,
      $ # with a 32-bit Python universal binary installed, i386
      $ # and ppc.
      $ #
      $ # If you uninstall the 64-bit MySQL, and install a 32
      $ # bit version, which is NOT a fat binary, you will
      $ # still see the above warnings, "file is not of required
      $ # architecture", which are generated because the above
      $ # -arch stripping for darwin platforms is a bit
      $ # incomplete, since the link step still has them
      $ # specified.
      $ #
      $ # A simple fix is to just copy the link line above, and
      $ # relink it without the -arch ppc, and you'll be fine.
      $ #
      $ # Another fix is to have MySQL-python's setup_posix.py
      $ # figure out the overlap between MySQL's CFLAGS and
      $ # Python's CFLAGS and only set extra_compile_args to
      $ # those flags from MySQL's list not already present in
      $ # Python's list.

       
    • Portante

      Portante - 2008-03-22

      Sorry, that second fix is not going to work, since you can only build the architectures for which MySQL has provided.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.