Python supports running py (or pyc) files directly out of zip files.
There are two problems with this in pywin32:
First, in GetServiceClassString the fname correctly represents the full path to the python file, but the win32api.FindFiles method does not find it because it is inside of a zip file. I got around this by checking to see if the file exists and if not seeing if there was a file with a .zip extension that exists in the path. If so, assume that it is correct.
Second, when installing python files from within a zip file, the argv parameters from python are as follows:  – The full path to the python file,  – The full path to the zip file, [2:] – Any other parameters. To get around this, I check to see if  references a zip file that exists. If so, I delete . Another option would be to also determine if  was a substring of .
There are a couple steps to run python files out of a zip file.
- Create a zip file containing python files
- Create a pth file containing a full path to the zip file. Put the file into %PYTHON_HOME%/Lib/site-packages.
- If you are attempting to call the myPyFile.py file in the zip file residing at c:\myZipFile.zip, the command line would look something like: “%PYTHON_HOME%/python.exe –m myPyFile c:/myZipFile.zip install”
Log in to post a comment.