[python-win32] Creating distributable packages/installers from python code for the windows platform

Jacob Kruger jacob at blindza.co.za
Fri Apr 26 03:53:55 EDT 2024


Hi there


I am quite comfortable with having used things like pyInstaller, 
cx_freeze and, most recently, playing around with nuitka, in tems of 
compiling code into a form of executable for the iwindows platform, but, 
there seems to be another side issue - let me explain a bit more.


Firstly, while I normally focus on web-development, working with flask 
and/or django, where it's less of an issue since am then distributing my 
code, etc. to servers myself, a recent bit of development relates to 
creating a form of windows executable which must run as a windows 
background service, to carry out a form of network connectivity 
monitoring, and it then posts data packets to a RESTFul API every now 
and then, which have already put in place, using flask, which is running 
on an external/separate server.


The issue is just that we need to install the client software on 
multiple call-centre workstations, all running windows 11, so I wanted 
to create an installation package/installer to make it easier for 
technicians to carry out this task.


I firstly tried just compiling my code into a single executable file 
using pyInstaller, and, that worked fine here on my development machine, 
but, the test guys are telling me that kaspersky is blocking it's 
execution, so, even though I could tell them where to place it 
before-hand, and have it then carry out initial configuration tasks 
using things like subprocess command execution, etc., I looked into 
trying to sign the compiled executable, but, to obtain something like a 
software certificate for a once-off, relatively small project would 
probably be a bit too costly to make it worthwhile.


This was done, initially, just using pyInstaller to compile the software 
since that's the one I have used the most often.


But, I thought that, just maybe, if I used something like inno setup to 
create an installer, it might help work around that initial distribution 
issue, but, the odd thing is inno setups compression/packaging seems to 
corrupt my executable - as in, I am suddenly receiving error messages in 
output when running it after installation, with messages relating to 
something like incorrect + operator for str and None, which doesn't make 
sense in terms of the code, etc. - my guess is something to do with a 
form of character set encoding, or something along the way, in the process.


I then tried switching over to cx_freeze for compiling my code, and, no 
output at all, and, have now just tried nuitka, in case, and, seems to 
not want to run executable at all, even if haven't packaged it using 
inno setup.


In other words - sorry for long message - just wondering if any of you 
have ideas about how to handle this type of thing since, sorry, but I 
have very limited experience in terms of producing compiled packages 
like this, and, main thing is to try make them more-or-less 
distributable, even if focusing on a form of internal target market?


And, if relevant, the modules am making use of in the primary operation 
of the software are things like requests, subprocess, dotenv, 
sqlalchemy, dateutil and pythonping, but anyway - don't think those 
could necessarily cause issues in this context?


Thanks in advance


-- 

Jacob Kruger
Skype: BlindZA
"...resistance is futile!...acceptance is versatile..."


More information about the python-win32 mailing list