0

I am building an application which uses MySQLdb, whihc appears to build correctly, but when running this on another Mac it quits unexpectedly. Is there any required steps to get MySQLdb included correctly with py2app? Here is my setup.py:

from setuptools import setup

APP = ['myApplication.py']
DATA_FILES = []
OPTIONS = {
                   'iconfile':'myIcon.icns',
                   'plist': {'CFBundleShortVersionString':'1.0',
                             'NSHumanReadableCopyright': u"Copyright © 2016, All Rights Reserved"}}

setup(
    app=APP,
    name='Transcoder_V1.0',
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

I have previously built this successfully using this exact setup and the exact same myApplication.py, which does run on other Macs, so the only thing which has changed is the version numbers, which are:

Python: 2.7.11
MySQL-Python: 1.2.5
mysql-connector-python: 2.0.4
mysqlclient: 1.3.7
py2app: 0.9
setuptools: 20.3

Is there anything I can try to fix?

UPDATE: I just tried adding into the setup:

PACKAGES = ['MySQLdb']
INCLUDES = ['MySQLdb']
OPTIONS = {'argv_emulation': True,
          'packages': PACKAGES,
          'includes': INCLUDES,
          } 

But I still get the quit unexpedidly, this is the start of the console crash log:

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libmysqlclient.18.dylib             0x000000010baf5e18 mysql_server_init + 132
1   _mysql.so                           0x00000001095b0fc1 0x1095ad000 + 16321
2   org.python.python                   0x00000001022c410c PyEval_EvalFrameEx + 40108
3   org.python.python                   0x00000001022c4ff3 PyEval_EvalCodeEx + 2131

Any other ideas I could try please?

UPDATE: I am connecting to a MySQL Server version 5.6, do I need to update this?

speedyrazor
  • 3,127
  • 7
  • 33
  • 51

1 Answers1

0

EDIT: Ups, sorry. My first answer was for py2exe. I don't know if py2app creates a log on execution. In any case try the same approach suggested earlier:

    PACKAGES = ['MySQLdb']
    INCLUDES = ['MySQLdb']
    OPTIONS = {'argv_emulation': True,
              'packages': PACKAGES,
              'includes': INCLUDES,
              }  

ORIGINAL POST (I'll leave it just in case): The .exe file in the build should give you a log with more specific information about what failed. In any case you might want to try including "MySQL" package directly in the setup:

    # setup.py
    from distutils.core import setup
    import py2exe

    includes = ["_mysql","MySQLdb","_mysql_exceptions",]

    options = {"py2exe": { # create a compressed zip archive
                          "compressed": 1,
                          "optimize": 2,
                          "includes": includes,
                              }}
    setup(
        options = options,
        console=['hamtainfo.py'],

        )

This code came directly from py2exe Mailing List

armatita
  • 12,825
  • 8
  • 48
  • 49
  • I just tried adding in the py2app stuff, same result, see my UPDATE above? – speedyrazor Mar 16 '16 at 10:36
  • Yep, the log isn't very informative but it seems to failing in finding libmysqlclient.18.dylib. Check if the file is inside the distribution you are making. There's a question in Stackoverflow specifically for that file, see it helps you: http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib – armatita Mar 16 '16 at 10:45
  • File is present in that location, do you need to have MySQL installed on the target machine? – speedyrazor Mar 16 '16 at 10:52
  • Anything to do with disabling SIP? – speedyrazor Mar 16 '16 at 10:55
  • If py2app does what I think it does you should have everything packed inside your build. But seeing the post from the other guy in the link I gave you it seems he's getting that file from a MySQL installation. Nevertheless this should be a path problem. I have no idea what to do about SIP but notice the other post (in the same link) suggest actually fixing the lib. I think you should try it first. – armatita Mar 16 '16 at 11:04
  • I am using MySQL communty server 5.6 on Windows, is this the issue, do I need to update? – speedyrazor Mar 16 '16 at 11:04
  • I thought you were always working on Unix. Can py2app build in one system to another? It's really a question since I don't know. – armatita Mar 16 '16 at 11:06
  • No, my application is runing on Mac, but the MySQL Server is on a windows box, connecting over the network, so was aking if I need to upgrade the MySQL server version? – speedyrazor Mar 16 '16 at 11:09
  • I really don't know. The library should be more stable in Unix than in Windows but still, updating will only help if there was a change that specifically dealt with that issue (like solving any path issues). I wouldn't rely on it (although it might work). Here's what I would try first: If py2app works anything like py2exe in your build you should have a folder for libraries (in python source). Just copy the folder of MySQLlib to that place (possibly overwriting the contents there) and see if changes something in the execution log. py2exe sometimes forgot "stuff" behind. – armatita Mar 16 '16 at 11:22