How to construct environment for developing using PyQt5, cx_freeze, python3.4

How to construct environment for developing using PyQt5, cx_freeze, python3.4 on OSX(mavricks)


Qt5's latest version is 5.2.1(maybe 5.3 is trying to be released). Qt5.2 has very great feature. and PyQt5 try to follow its all of feature as all as possible. 

PyQt5 is good on python 3(i tried on its latest version - 3.4)(I didn't try to build it on python 2.7. above all riversebank didn't release stable version for python 2.7). python has pyinstaller as great packaging software. but it does not support python3 not yet(developing).I tried to other packaging software for distribute python as bundle app in mac, i didn't find it except cx_freeze. but in pure installed version, I have faced difficult problem. if you try to solve them, you can summarise like as follow:   

1. modify python 3.4 source code and build it


when you use cx_freeze without modification source and rebuild, you will fail. related 'bootstrap' - you will meet error message related 'bootstrap'(sorry i cannot remember it detaily. now I write this article for unforgetting about it. but i think it will be fixed it ASAP)

anyway you should modify as follow:

Python-3.4.0/Lib/importlib/__init__.py 

25: _bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py')

->

    try:
        _bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py')
    except NameError:
        pass

keep its syntax rule and indents. I'm sorry that this document is not pretty
.

then build and install it.(find how to build python module by yourself. sorry)

2. modify cx_Freeze-4.3.2/cx_Freeze/macdist.py and build cx_Freeze


114 :         files = os.listdir(self.binDir)


->

        files = os.listdir(self.binDir)
        files.extend( [os.path.join('platforms',fn) for fn in os.listdir( os.path.join(self.binDir, 'platforms') )] )

then build and install it


3. How to make PyQt5 module bundle app.

cx_freeze has various build option for many kind of platform.

on OSX, you can use bdist_mac like as follow:(target module name is example.py)

first. make setup
> cx_freeze-quickstart example.py

then you can input some information to build bundle
second. make bundle app

> python setup.py bdist_mac --qt-menu-nib=[qt_menu.nib path]

in this case, you can find [qt_menu.nib path] in Qt 5.2.1 installed subdirectory. 


then you can execute your bundle.app using 'open'



 








댓글