On 10/05/2010 7:08 AM, Bill Janssen wrote:
A few weeks ago, Mark mentioned that there's now a way to run a Windows
service without pythonservice.exe.

I'd like to hear more about that.  Right now, I'm stuck with my UpLib
system on Windows.  I'd like to be able to install everything in the
UpLib directory, including a private copy of Python and PyWin32.  But
then there's no way to tell pythonservice.exe where the modules are, and
so Python services don't start.

I'm thinking the problem is this code in PythonService.cpp:

// Our EXE entry point.
  1540
  1541 int _tmain(int argc, TCHAR **argv)
  1542 {
  1543  PyObject *module, *f;
  1544  PyThreadState *threadState;
  1545  HMODULE hmod;
  1546  FARPROC proc;
  1547  Py_Initialize();
  1548  PyEval_InitThreads();
  1549  module = PyImport_ImportModule("servicemanager");
  1550  if (!module) goto failed;

I've got the PyWin32 extensions installed in a private site-packages
directory under my stuff, which isn't the same as the Python
site-packages site.  I need a way to set PYTHONPATH, or in some other
way initialize the DLL load path and Python sys.path, before running the
pythonservice.exe, don't I?  Otherwise, this load of "servicemanager"
will fail (and Py_Initialize() will fail if I don't copy
pythonservice.exe to the same location as python.exe and python26.dll).

That's correct. Using python.exe as the host will involve having a .py script which imports the servicemanager module then call PrepareToHostSingle and instantiate the service class - or something like that :)

Another alternative is to ship a slightly modified pythonxx.dll - it has a feature where a certain string resource contains the basename of the registry key used at runtime to load the pythonpath - eg, you will find the resource has "2.6" for Python 2.6 builds. Using a resource editor (or even a script using pywin32) to change this to some custom value will mean the pythonpath can be loaded from a private key in the registry, meaning you still get isolation from other installed Python versions.

HTH,

Mark

Bill
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to