Build Windows installers for Python applications
pynsist 1.5 — pynsist 1.5 documentation
I would like to package a Python3-PyGObject program with pynsist. The repository has an example for PyGTK and it made me think that it shouldn't be too hard to change the example.
The example can be found here:
In this file (https://github.com/takluyver/pynsist/blob/master/examples/pygtk/grab_files.sh) I think one just has to grab the files targeting GTK 3 (http://www.gtk.org/download/win32.php):
wget -O gtkbundle.zip http://win32builder.gnome.org/gtk+-bundle_3.6.4-20130921_win32.zip
wget -O pygobject.exe http://sourceforge.net/projects/pygobjectwin32/files/pygi-aio-3.14.0_rev12-setup.exe/download
wget -O pycairo.zip http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo_1.10.2-2_win32.zip
I am not sure what to do with the fourth line, because it is my current understanding that those bindings should already be inside the gtk or pygobject bundle:
wget -O pygtk.exe http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-2.24.0.win32-py2.7.exe
I then tried to customize this file (https://github.com/takluyver/pynsist/blob/master/examples/pygtk/installer.cfg) to include (use gi
instead of gi.repository
):
[Include]
packages=gi
This resulting error is:
raise ExtensionModuleMismatch(extensionmod_errmsg % ('Windows', path))
nsist.copymodules.ExtensionModuleMismatch: Found an extension module that will not be usable on Windows:
/usr/lib/python3/dist-packages/gi/_gi.cpython-34m-x86_64-linux-gnu.so
Put Windows packages in pynsist_pkgs/ to avoid this.
Does anyone know what the correct approach for a program (like e.g. one of these: https://python-gtk-3-tutorial.readthedocs.org) would be?
Edit 1
After packaging and installing the program on Windows, starting the test-program produces the following traceback:
Traceback (most recent call last):
File "C:\Program Files (x86)\hellogtk\hellogtk.launch.pyw", line 31, in <module>
from gtk_test import main
File "C:\Program Files (x86)\hellogtk\pkgs\gtk_test.py", line 3, in <module>
from gi.repository import Gtk
File "C:\Program Files (x86)\hellogtk\pkgs\gi\__init__.py", line 42, in <module>
from . import _gi
ImportError: DLL load failed: The specified module could not be found.
It is odd that this ImportError occurs because there is a _gi.pyd
-file in the same directory (gi
) as the __init__.py
This is the current layout:
- directory
|- pynsist_pkgs
|-- cairo
|--- _cairo.pyd
|--- __init__.py
|-- gi
|--- _gobject
|--- overrides
|--- repository
|--- __init__.py
|--- _gi.pyd
|--- ...
|-- gtk
|--- bin
|--- etc
|--- lib
|--- manifest
|--- share
|-- dbus
|--- __init__.py
|--- ...
|-- gnome
|--- ...
|-- pygtkcompat
|--- ...
|-- _dbus_bindings.pyd
|-- _dbus_glib_bindings.pyd
|-- ...
|- gtk_test.py
|- grab_files.sh
|- installer.cfg
|- gtk_preamble.py
And I used the py-3.4-64
folder of the pygobject bindings. The Linux I am creating the package on is 64 bit, and the Windows I am running the program is also 64 bit.
Edit 2:
Using Dependency-Walker I can see that 2 DLLs are missing: GPSVC.DLL
and IESHIMS.DLL
.
Edit 3:
I found those 2 DLLs on the system and copied them in different directories of the test-program, but it didn't work.
Edit 4:
This might be useful for the import-error:
Source: (StackOverflow)
Hi I've installed pynsist in order to make my python files into executables but I am having some issues. The project consists of two files that I've written. The main program to be run is Filereader.py and a supplied file called spuriousReq.py which Filereader.py uses a function from. Currently my installer.cfg file looks like this
[Application]
name=WFilereader
version=1.0
entry_point=Filereader
console=true
[Python]
version=3.4.0
[Include]
packages = matplotlib
statistics
bisect
files = spuriousReq.py
I've moved the installer.cfg file and both python files to the C:\Python34\Scripts folder in order to access them from the cmd (Yes I am new at this..). But I get the following error which I dont know how to interpret or solve..
C:\Python34\Scripts>"C:\Python34\python.exe" "C:\Python34\Scripts\\pynsist" inst
aller.cfg
Traceback (most recent call last):
File "C:\Python34\Scripts\\pynsist", line 3, in <module>
main()
File "C:\Python34\lib\site-packages\nsist\__init__.py", line 393, in main
shortcuts = configreader.read_shortcuts_config(cfg)
File "C:\Python34\lib\site-packages\nsist\configreader.py", line 172, in read_
shortcuts_config
appcfg = cfg['Application']
File "C:\Python34\lib\configparser.py", line 937, in __getitem__
raise KeyError(key)
KeyError: 'Application'
Source: (StackOverflow)
I'm trying this new tool out to distribute Python projects, which is called Pynsist (http://pynsist.readthedocs.org/en/latest/index.html).
It works great and everything but for some reason no packages are found after install, what solves the problem is if you move packages from "pkg" folder to the main folder, which is really peculiar. My installer.cfg:
[Application]
name=Seek scrapper
version=1.0
# How to launch the app - this calls the 'main' function from the 'myapp' package:
entry_point=Scrape_pages_to_txt:main
[Python]
version=3.3.5
bitness=32
[Include]
# Importable packages that your application requires, one per line
packages = requests
bs4
selenium
xlsxwriter
# Other files and folders that should be installed
files = ad_urls.txt
xlsx_writer.py
Scrape_ads_from_urls.py
What am I doing wrong here?
Source: (StackOverflow)