12/25/2016

Install the latest cmake to Ubuntu

Step 1 : Download the latest and stable cmake from https://cmake.org/download/

I download the source of cmake with v3.7.1 to my Ubuntu 14.04.

Step2 : Extract the compressed file and build it

$ cd cmake-3.7.1
$ ./bootstrap --prefix=/usr
$ make
$ sudo make install

Step3 : Check it

$ cmake --version

Expected output:  cmake version 3.7.1

12/07/2016

Make python program executable and compile for Windows exe on Linux

  This week, I spend some time to make one of my repositories, LablelImg,  on Github become an executable file. The LablelImg is implemented  in Python, and it has some dependencies like lxml and pyQt. In order to let other people use the tool easier without installing python and their dependencies, I decide to make it a standalone executable. I described as below about how I have done to compile it for Window exe and Linux binary on Ubuntu. In Python, there are some packages which can let python files become an executable file, e.g pyexe, pyinstaller, and so on.
Then, I decide to pick pyinstaller because its document and relevant reference are concise.

Environment : 

OS: Ubuntu 14.04
Necessary packages and tools :
  1.   wine (1.6.2)
  2.   pyinstaller (2.1)
  3.   virtual-wine (0.1)
  4.   python-2.7.8.msi
  5.   pywin32-218.win32-py2.7.exe 
  6.   PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe
  7.   lxml-2.3.win32-py2.7.exe
The steps to install or download them:
wine : $ apt-get install wine
pyinstaller : $ git clone https://github.com/pyinstaller/pyinstaller
virtual-wine : $ git clone https://github.com/htgoebel/virtual-wine.git
python-2.7.8 : Download from https://www.python.org/ftp/python/2.7.8/python-2.7.8.msi
pywin32-218.win32-py2.7 : Download from http://nchc.dl.sourceforge.net/project/pywin32/pywin32/Build%20218/pywin32-218.win32-py2.7.exe
PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe: https://www.riverbankcomputing.com/software/pyqt/download
lxml-2.3.win32-py2.7.exe : Download from  https://pypi.python.org/pypi/lxml/2.3/

Install packages to virtual env

Create a virtual wine environments using virtual-wine:
$ apt-get install scons
$ ./virtual-wine/vwine-setup venv_wine

Active virutal env:
$ . venv_wine/bin/activate

Use wine to install python packages to your virtual env: 
$ wine msiexec -i python-2.7.8.msi
$ wine pywin32-218.win32-py2.7.exe
$ wine PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe
$ wine lxml-2.3.win32-py2.7.exe

Build your python files using pyinstall under virtual environment

$ wine c:/Python27/python.exe pyinstaller/pyinstaller.py -D -F -n AppName -c "main.py" 
The exe file will be located under dist directory

Check out my scripts, you will be more clear

Check out my script to setup the environment and make pyQt executable.
https://github.com/tzutalin/labelImg/tree/master/build-tools