{"componentChunkName":"component---src-templates-post-tsx","path":"/posts/2018/01/setup.py/","result":{"data":{"markdownRemark":{"fields":{"slug":"/2018/01/setup.py/"},"frontmatter":{"title":"A successful py2app setup.py code","tag":["python","pyapp","setup.py"],"image":"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTWTqh2q4wZ4ZT52Vfr_yoed2HUhOdAUOq3CANT8UBkNGiu_L_E"},"correctedDateEpoch":1516986000000,"html":"<p>py2app and py2exe are how to compile a Python package bundle into a single file app. However, I had problem simply running <code>py2applet --make-setup PatientLogbook.py database/user.db</code>, so I have to edit the config file myself.</p>\n<p>Root causes of the problem running <code>python setup.py py2app</code> include the following.</p>\n<!-- excerpt_separator -->\n<ul>\n<li>Misplaced data file, default not in the correct directory</li>\n<li><code>passlib</code> in <code>py2app</code> defaulted to using <code>bcryptor</code> instead of <code>bcrypt</code></li>\n<li>Even though I changed <code>from passlib.hash import bcrypt</code> to <code>import bcrypt</code>, I still need <code>cffi</code> for <code>bcrypt</code> to work</li>\n</ul>\n<p>Here is a working <code>setup.py</code>.</p>\n<pre><code class=\"language-python\">\"\"\"\nUsage:\npython setup.py py2app\n\"\"\"\n\nfrom setuptools import setup\n\nAPP = ['PatientLogbook.py']\nDATA_FILES = [\n    ('database',['database/user.db'])\n]\nOPTIONS = {\n    'includes': ['cffi'],\n    'plist': {\n        'CFBundleName': 'Patient Logbook'\n    }\n}\n\nsetup(\n    app=APP,\n    data_files=DATA_FILES,\n    options={'py2app': OPTIONS},\n    setup_requires=['py2app','PyQt5','bcrypt','cffi'],\n)\n</code></pre>"}},"pageContext":{"slug":"/2018/01/setup.py/"}}}