From c4c8fe16b8d682a0d06732fe513fc6550030c2df Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Thu, 6 Aug 2020 01:55:54 +0530 Subject: initial commit --- Ubuntu/executable.md | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 Ubuntu/executable.md (limited to 'Ubuntu') diff --git a/Ubuntu/executable.md b/Ubuntu/executable.md new file mode 100644 index 0000000..9ac54a1 --- /dev/null +++ b/Ubuntu/executable.md @@ -0,0 +1,94 @@ +NGHDL Executable (Ubuntu OS) +==== + +> Note: It is not updated for the recently ported GUI to PyQt5 and Ubuntu 20.04 LTS. Currently, packaging for Ubuntu OS is done directly with the source code and not the executable. + +It contains the documentation for making NGHDL executable using PyInstaller on Ubuntu 16.04 and above. + + +## Freeze NGHDL source code: + +1. Download `virtualenv` package and create virtual environment as: + + $ pip install virtualenv + $ virtualenv -p /usr/bin/python3 nghdl + + OR + + $ sudo apt install -y python3-venv + $ python3 -m venv nghdl + +2. Activate the virtual environment as: + + $ source nghdl/bin/activate + +3. Install all Python dependencies for NGHDL within the virtual environment as: + + $ pip install wheel + $ pip install pyinstaller + $ pip install --upgrade 'setuptools<45.0.0' + $ sudo apt install build-essential python3-dev libqt4-dev qt4-dev-tools + $ mkdir nghdl/build + $ cd nghdl/build/ + $ wget http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.12.3/PyQt4_gpl_x11-4.12.3.tar.gz + $ wget https://www.riverbankcomputing.com/static/Downloads/sip/4.19.21/sip-4.19.21.tar.gz + $ tar xzvf sip-4.19.21.tar.gz + $ tar xvzf PyQt4_gpl_x11-4.12.3.tar.gz + $ cd sip-4.19.21/ + $ python configure.py --sip-module PyQt4.sip + $ make + $ make install + $ cd ../PyQt4_gpl_x11-4.12.3/ + $ python configure.py + $ make + $ make install + +4. Now uninstall PyQt4, sip, matplotlib, numpy, dateutil and cycler globally (if any). + +5. Test whether only NGHDL dependencies are available or not: + + $ pip freeze + +> Note : Following dependencies should be available - +> - PyQt4 +> - sip + +6. Create spec file as: + + $ pyi-makespec --onefile -n nghdl /src/ngspice_ghdl.py + +7. Add `PyQt4.sip` as hiddenimports in the generated spec file. + +8. Create onefile executable using pyinstaller as: + + $ pyinstaller -F --clean nghdl.spec + +9. Verify whether all NGHDL `src` files (`*.py`) have been included in `Analysis-00.toc` file under the build folder generated by PyInstaller. + + +## Fully-Static Bundled Version of NGHDL: + +1. To create a [fully-static bundled version](https://github.com/pyinstaller/pyinstaller/wiki/FAQ#GNULinux) of NGHDL (through PyInstaller), use a tool like [StaticX](https://github.com/JonathonReinhart/staticx/). + +2. To create fully-static NGHDL : + + - Activate the virtual environment as: + + $ source nghdl/bin/activate + + - Install StaticX as: + + $ pip install staticx + $ pip install patchelf-wrapper + + - Create static NGHDL as: + + $ staticx /path/to/executable/nghdl /path/to/output/executable/nghdl + +3. To verify if all dynamic libraries are removed : + + - Type following command in a terminal : + + $ ldd path/to/output/executable/nghdl + + - Output of above command should be similar to ` not a dynamic executable` -- cgit