smart-mobile-software / gitstack

GitStack makes you Git server easy to install and manage on Windows.
http://gitstack.com
Other
125 stars 41 forks source link

Conflicts with already installed python environments #55

Open poiuytrez opened 12 years ago

cb55555 commented 12 years ago

Deployed on Windows Server 2008 R2 on Hyper-V Server 2008 R2.

IIS running multiple websites on port 80.

CollabNet Subversion Edge running Apache server on port 8081.

GitStack running Apache server on port 9091.

cb55555 commented 12 years ago

Here is my latest Apache error:

[Sun Apr 15 10:15:30 2012] [error] [client ::1] mod_wsgi (pid=5060): Target WSGI script 'D:/GitStack/app/django.wsgi' cannot be loaded as Python module. [Sun Apr 15 10:15:30 2012] [error] [client ::1] mod_wsgi (pid=5060): Exception occurred processing WSGI script 'D:/GitStack/app/django.wsgi'. [Sun Apr 15 10:15:30 2012] [error] [client ::1] Traceback (most recent call last): [Sun Apr 15 10:15:30 2012] [error] [client ::1] File "D:/GitStack/app/django.wsgi", line 11, in [Sun Apr 15 10:15:30 2012] [error] [client ::1] import django.core.handlers.wsgi [Sun Apr 15 10:15:30 2012] [error] [client ::1] ImportError: No module named django.core.handlers.wsgi

poiuytrez commented 12 years ago

Could you confirm that the test scenario is :

  1. Install IIS (port 80)
  2. Install GitStack on D:\
  3. Change gitstack port in apache configuration file
  4. Restart GitStack

I will proceed to the test after your confirmation.

cb55555 commented 12 years ago

That's it.

cb55555 commented 12 years ago

Another thing. I logged in as an Active Directory administrator when I installed. I'll see if it makes a difference if I log in as a local machine administrator.

cb55555 commented 12 years ago

One more thing... I had to change the php.ini from this:

extension_dir="C:\dev\gitstack\php\ext"

to:

extension_dir="D:\gitstack\php\ext"

This was missed by the installer.

cb55555 commented 12 years ago

I logged in as local administrator, reinstalled GitStack, and got the same django issue.

poiuytrez commented 12 years ago

I performed the test scenario, I did not get any issues.

Could you make sure that : D:\GitStack\python;D:\GitStack\python\Scripts;D:\GitStack\git\cmd is added to your PATH ?

poiuytrez commented 12 years ago

I have created a bug for the php.ini issue ( #57 )

cb55555 commented 12 years ago

Yes, I have those folders in my path. Also, I never noticed this earlier. It could be related. I thought this was just information, but these are actually warnings.

[Mon Apr 16 12:10:35 2012] [warn] pid file D:/GitStack/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run? [Mon Apr 16 12:10:43 2012] [warn] mod_wsgi: Compiled for Python/2.7. [Mon Apr 16 12:10:43 2012] [warn] mod_wsgi: Runtime using Python/2.7.2. [Mon Apr 16 12:10:43 2012] [notice] Apache/2.2.22 (Win32) PHP/5.3.10 mod_wsgi/3.3 Python/2.7.2 configured -- resuming normal operations [Mon Apr 16 12:10:43 2012] [notice] Server built: Mar 19 2012 19:56:33 [Mon Apr 16 12:10:43 2012] [notice] Parent: Created child process 2092 [Mon Apr 16 12:10:43 2012] [warn] mod_wsgi: Compiled for Python/2.7. [Mon Apr 16 12:10:43 2012] [warn] mod_wsgi: Runtime using Python/2.7.2. [Mon Apr 16 12:10:43 2012] [notice] Child 2092: Child process is running [Mon Apr 16 12:10:46 2012] [notice] Child 2092: Acquired the start mutex. [Mon Apr 16 12:10:46 2012] [notice] Child 2092: Starting 64 worker threads. [Mon Apr 16 12:10:46 2012] [notice] Child 2092: Starting thread to listen on port 9091. [Mon Apr 16 12:10:46 2012] [notice] Child 2092: Starting thread to listen on port 9091. [Tue Apr 17 06:14:42 2012] [error] [client ::1] mod_wsgi (pid=2092): Target WSGI script 'D:/GitStack/app/django.wsgi' cannot be loaded as Python module. [Tue Apr 17 06:14:42 2012] [error] [client ::1] mod_wsgi (pid=2092): Exception occurred processing WSGI script 'D:/GitStack/app/django.wsgi'. [Tue Apr 17 06:14:42 2012] [error] [client ::1] Traceback (most recent call last): [Tue Apr 17 06:14:42 2012] [error] [client ::1] File "D:/GitStack/app/django.wsgi", line 11, in [Tue Apr 17 06:14:42 2012] [error] [client ::1] import django.core.handlers.wsgi [Tue Apr 17 06:14:42 2012] [error] [client ::1] ImportError: No module named django.core.handlers.wsgi

poiuytrez commented 12 years ago

It seems like Django is not installed... Could you open a command prompt and type : python (in the python prompt ) : import django print django.get_version()

Let me know the result.

cb55555 commented 12 years ago

"ImportError: No module named django"

That seems to be the issue. Where is django supposed to be installed?

poiuytrez commented 12 years ago

I am pretty sure that there is an issue with the python distribution provided by CollabNet Subversion Edge ( http://subversion.open.collab.net/ds/viewMessage.do?dsForumId=4&dsMessageId=386993 ).

You are running the python distribution provided by CollabNet. What you can do is to install django and jsonpickle on collab's python. To do so, copy : d:\gitstack\python\Lib\sites-packages\django and d:\gitstack\python\Lib\sites-packages\jsonpickle to your collabnet's python sites-packages directory.

It's a bit tricky but it might work.

cb55555 commented 12 years ago

But in this case, CollabNet was installed first, and GitStack was installed second.

I can't really do what you're suggesting because the version of mod_wsgi that you're using works with Python 2.7.2 while the CollabNet uses Python 2.5.

poiuytrez commented 12 years ago

You are right. I am really sorry but I do not have a solution for you. Let me know if you have an idea on how to run two python environments on the same machine.

craftyjon commented 12 years ago

VirtualEnv (http://www.virtualenv.org/en/latest/index.html) works on Windows, and seems like a good idea for something like GitStack that packages its own Python. Note that I haven't tried it with Apache+ModWSGI, so there might be some fiddling involved in getting that to use the right Python.

poiuytrez commented 12 years ago

I am not sure VirtualEnv works for this issue because it is made to have one installation of python (2.7 for example) and then multiple "library" environments.

We are looking for a solution to run python 2.5 (collab svn) with python 2.7, which are two complete different environments.

craftyjon commented 12 years ago

Well, could you use a method vaguely related to this: http://nedbatchelder.com/blog/201007/installing_python_packages_from_windows_installers_into.html

Roughly: 1) Detect if an existing (system-wide) Python installation is on the system (in this case, there is already a Python 2.5 installation) 2) backup the PythonPath/InstallPath for Python 2.5 3) Install your distributed Python 2.7 in the gitstack directory 4) Create a new virtualenv using your Python 2.7 (which is currently in registry) 5) Switch the PythonPath/InstallPath back to Python 2.5 6) Modify GitStack to use the VirtualEnv'd Py2.7 instead of the (now system default again) Py2.5 7) Proceed with GitStack site-packages install

This seems complicated, but I can't seem to find a way to run the Python installer on Windows without it updating the PythonPath/InstallPath...

poiuytrez commented 12 years ago

I think we have to dig this solution : http://stackoverflow.com/questions/4583367/how-to-run-multiple-python-version-on-windows

but I don't know yet how to specify the full path to python using mod_wsgi...

By the way, I am not using the python installer but portable python.

craftyjon commented 12 years ago

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonHome ?

poiuytrez commented 12 years ago

Thanks for the link, it seems quite relevant.

poiuytrez commented 12 years ago

I have updated the ticket name.

poiuytrez commented 12 years ago

I have scheduled this feature for the 1.5 release.

cb55555 commented 12 years ago

If you set WSGIPythonPath and WSGIPythonHome in mod_wsgi, will you even need VirtualEnv?

poiuytrez commented 12 years ago

You are right, I do not need VirtualEnv. (that's why I closed the issue 53).

craftyjon commented 12 years ago

You need to make sure that if you install packages (Django) you are targeting the right Python. You could use VirtualEnv for that, or a special installer for your packages, or modify the registry PythonPath if using the default installer.

orf commented 12 years ago

Virtualenv would be fairly simple to integrate, surely?

poiuytrez commented 12 years ago

The issue is more complex that it seems : -VirtualEnv cannot be used because GitStack is using a mod_wsgi version which requires python 2.7. Collabsvn uses python 2.5 which is not compatible with mod_wsgi 3.3 -The WSGIPythonHome instruction ( http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonHome ) does not work on Windows

I have contacted the mod_wsgi team to check if there is a workaround.

cb55555 commented 12 years ago

It's amazing that there isn't already a widely-known workaround for having multiple, different-versioned Python deployments on a single machine. One would think that there are many more use cases for this possibility than just having two different version control systems on the same machine.

cb55555 commented 12 years ago

I looked at the WSGI docs, and it states that if you are loading mod_python in addition to mod_wsgi, then the environment variables set by mod_python will be used instead of the variables set by mod_wsgi.

I'm not sure if GitStack uses mod_python, but CollabNet does.

And with mod_python, you can set PythonPath, which doesn't have different behavior based on what OS you have it installed on.

cb55555 commented 12 years ago

Setting PythonPath in mod_python doesn't do it. Back to the drawing board.

poiuytrez commented 12 years ago

Link to the discussion on the mod_wsgi google groups : https://groups.google.com/forum/?fromgroups#!topic/modwsgi/fQn7zOwdkP4

I do not have any reply yet.

localpcguy commented 12 years ago

My feelings are that issues such as this (multiple python installs) and the default to port 80 will limit adoption of GitStack, as the people most likely to give it a try are developers, and we are likely to try it out locally on our development machine prior to installing it on one of our servers. GitStack should be installable without interfering with any of the other packages installed on the machine, including Python.

poiuytrez commented 12 years ago

Feel free to provide a solution to the current issue. (multiple python environments).

Stevie-O commented 10 years ago

This almost became a dealbreaker for me -- right out of the box, GitStack failed to work. A real shame, because it looks like a lot of work went into making it a very professional system!

It looks like the best way to solve this would be to have GitStack create a local account to run under, and set that local account's PATH and PYTHON_xxx settings accordingly. (This would also mean that GitStack is no longer running as LocalSystem, which is a dangerous account to be running an HTTP server under.)

However, without an installer to manage things, this is kind of a pain, because a whole bunch of extra crap needs to be done to make it all work ("log on as a service", plus who knows what else). Therefore, I found a solution that gets GitStack up and running without an extra user or installing or configuring any extra software:

I was able to get things to work by creating the following file 'gitstack.bat' in GitStack's 'apache' subdirectory:

@echo off
set PATH=D:\Stuff\GitStack\python;D:\Progz\GitStack\python\Scripts;D:\Progz\GitStack\php;D:\Progz\GitStack\git\cmd;D:\Progz\GitStack\git\bin;%PATH%
set PYTHONHOME=D:\Stuff\GitStack\python
set PYTHONPATH=D:\Stuff\GitStack\python\lib
D:\Stuff\GitStack\apache\bin\httpd.exe %*

Then I ran this from CMD.EXE:

sc config GitStack binPath= ^"\^"D:\Stuff\GitStack\apache\bin\gitstack.bat\^" -k runservice^"

(The ^s and \s are to deal with bizarre quoting rules of CMD.EXE, which are insane due to decades of backwards-compatibility tweaks.)

Once I did this, I was able to "sc start gitstack", and Apache started right up!

(Windows Server 2008 R2 64-bit)

poiuytrez commented 10 years ago

Thank a lot for your input about this issue.