#642 Installation of windows service fails when py files in zip

open
nobody
win32 (141)
5
2013-05-14
2013-05-14
No

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: [0] – The full path to the python file, [1] – The full path to the zip file, [2:] – Any other parameters. To get around this, I check to see if [1] references a zip file that exists. If so, I delete [1]. Another option would be to also determine if [1] was a substring of [0].
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”

Discussion

  • Joshua Palmer

    Joshua Palmer - 2013-05-14

    Changes to win32serviceutil.py

     
  • Joshua Palmer

    Joshua Palmer - 2013-05-14

    Modified win32serviceutil.py

     
  • Joshua Palmer

    Joshua Palmer - 2013-05-14

    I have added files showing the changes I made in order to make this work for me.

     
  • Joshua Palmer

    Joshua Palmer - 2013-05-14
    • summary: Installation of python windows service fails when py files a --> Installation of windows service fails when py files in zip
     
  • Joshua Palmer

    Joshua Palmer - 2013-05-14

    This problem only occurs during service installation. Once the service is installed, it runs successfully.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks