[GH-ISSUE #39] Gunicorn/virtualenv compatibility issues #29

Closed
opened 2026-02-27 16:00:45 +03:00 by kerem · 16 comments
Owner

Originally created by @jlillis on GitHub (Mar 12, 2013).
Original GitHub issue: https://github.com/retspen/webvirtmgr/issues/39

I am attempting to deploy webvirtmgr using gunicorn within a virtualenv. So far, I have managed to get the interface up and running by making some changes to the wsgi config files, but am stuck with a libvirt import error when trying to view a connection's details.

The issue seems to be that I can't get the libvirt python module visible in the virtualenv. I'm not sure how to fix that (this isn't necessarily a webvirtmgr issue).

The current wsgi setup dosen't really play nice with gunicorn - I have got it to work by writing my own wsgi.py file and placing it in the top directory, however I'm not sure if it works with apache as well yet (I haven't tested it). Once I am able to confirm it does, I will commit for review. I would probably add a requirements.txt file for easy deployment, but I would need to be a little more familiar with the project's internals beforehand.

Any help would be appreciated, this project looks pretty cool and I would love to make use of / contribute to it.

Originally created by @jlillis on GitHub (Mar 12, 2013). Original GitHub issue: https://github.com/retspen/webvirtmgr/issues/39 I am attempting to deploy webvirtmgr using gunicorn within a virtualenv. So far, I have managed to get the interface up and running by making some changes to the wsgi config files, but am stuck with a libvirt import error when trying to view a connection's details. The issue seems to be that I can't get the libvirt python module visible in the virtualenv. I'm not sure how to fix that (this isn't necessarily a webvirtmgr issue). The current wsgi setup dosen't really play nice with gunicorn - I have got it to work by writing my own wsgi.py file and placing it in the top directory, however I'm not sure if it works with apache as well yet (I haven't tested it). Once I am able to confirm it does, I will commit for review. I would probably add a requirements.txt file for easy deployment, but I would need to be a little more familiar with the project's internals beforehand. Any help would be appreciated, this project looks pretty cool and I would love to make use of / contribute to it.
kerem closed this issue 2026-02-27 16:00:45 +03:00
Author
Owner

@retspen commented on GitHub (Mar 12, 2013):

Add support gunicorn

<!-- gh-comment-id:14797781 --> @retspen commented on GitHub (Mar 12, 2013): Add support gunicorn
Author
Owner

@retspen commented on GitHub (Mar 12, 2013):

After activate virtualenv need add python path when installed libvirt module: export PYTHONPATH=/usr/lib/python2.7/path to site-packages/

<!-- gh-comment-id:14798401 --> @retspen commented on GitHub (Mar 12, 2013): After activate virtualenv need add python path when installed libvirt module: <code>export PYTHONPATH=/usr/lib/python2.7/path to site-packages/</code>
Author
Owner

@jlillis commented on GitHub (Mar 13, 2013):

To fix the libvirt module error, I re-created the virtualenv using the --system-site-packages flag.

Also, the wsgi setup didn't actually work all that well, but I have changed it in my fork to work easily with gunicorn/django. I still haven't tested it with apache yet, however.

<!-- gh-comment-id:14816846 --> @jlillis commented on GitHub (Mar 13, 2013): To fix the libvirt module error, I re-created the virtualenv using the --system-site-packages flag. Also, the wsgi setup didn't actually work all that well, but I have changed it in my fork to work easily with gunicorn/django. I still haven't tested it with apache yet, however.
Author
Owner

@retspen commented on GitHub (Mar 13, 2013):

Virtualenv for apache - wsgi/django.wsgi

import logging
import os
import sys

# If you deploy virtualenv
import site
site.addsitedir('/var/www/webvirtmgr/venv/lib/python2.7/site-packages')

# Add this file path to sys.path in order to import settings
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '../..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'webvirtmgr.settings'
sys.stdout = sys.stderr

sys.path.append("/var/www/webvirtmgr/")

DEBUG = False

import django.core.handlers.wsgi
from django.conf import settings
application = django.core.handlers.wsgi.WSGIHandler()
<!-- gh-comment-id:14828215 --> @retspen commented on GitHub (Mar 13, 2013): Virtualenv for apache - wsgi/django.wsgi ``` import logging import os import sys # If you deploy virtualenv import site site.addsitedir('/var/www/webvirtmgr/venv/lib/python2.7/site-packages') # Add this file path to sys.path in order to import settings sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '../..')) os.environ['DJANGO_SETTINGS_MODULE'] = 'webvirtmgr.settings' sys.stdout = sys.stderr sys.path.append("/var/www/webvirtmgr/") DEBUG = False import django.core.handlers.wsgi from django.conf import settings application = django.core.handlers.wsgi.WSGIHandler() ```
Author
Owner

@jlillis commented on GitHub (Mar 13, 2013):

I guess my setup is pretty different from what your wsgi.py assumes - I put all the webvirtmgr stuff in /opt/webvirtmgr and run the gunicorn server from there, but using nginx as a proxy to serve static content (pretty much like http://mirobetm.blogspot.com/2012/03/ive-been-lighttpd-fastcgi-django-user.html). I changed a lot of stuff related to python paths in the settings files as well, so it's more flexible (I'm running this with Django 1.4, perhaps webvirtmgr assumes 1.3?).

<!-- gh-comment-id:14837454 --> @jlillis commented on GitHub (Mar 13, 2013): I guess my setup is pretty different from what your wsgi.py assumes - I put all the webvirtmgr stuff in /opt/webvirtmgr and run the gunicorn server from there, but using nginx as a proxy to serve static content (pretty much like http://mirobetm.blogspot.com/2012/03/ive-been-lighttpd-fastcgi-django-user.html). I changed a lot of stuff related to python paths in the settings files as well, so it's more flexible (I'm running this with Django 1.4, perhaps webvirtmgr assumes 1.3?).
Author
Owner

@retspen commented on GitHub (Mar 13, 2013):

Yes this is Django-1.3

<!-- gh-comment-id:14837558 --> @retspen commented on GitHub (Mar 13, 2013): Yes this is Django-1.3
Author
Owner

@retspen commented on GitHub (Mar 13, 2013):

Project http://www.webvirtmgr.net - work in Django-1.3, ngix, gunicorn, runit. That's all work fine!

<!-- gh-comment-id:14837730 --> @retspen commented on GitHub (Mar 13, 2013): Project http://www.webvirtmgr.net - work in Django-1.3, ngix, gunicorn, runit. That's all work fine!
Author
Owner

@jlillis commented on GitHub (Mar 13, 2013):

I see. It also seems to work fine in 1.4 with some small path/import changes. I guess I'll continue with 1.4/5 compatibility changes in my fork for now then.

<!-- gh-comment-id:14837940 --> @jlillis commented on GitHub (Mar 13, 2013): I see. It also seems to work fine in 1.4 with some small path/import changes. I guess I'll continue with 1.4/5 compatibility changes in my fork for now then.
Author
Owner

@retspen commented on GitHub (Mar 13, 2013):

No promblem update WebVirtMgr to 1.4/1.5, but many linux distro not have 1.4/1.5 in repositories (LTS and CentOS).

<!-- gh-comment-id:14838042 --> @retspen commented on GitHub (Mar 13, 2013): No promblem update WebVirtMgr to 1.4/1.5, but many linux distro not have 1.4/1.5 in repositories (LTS and CentOS).
Author
Owner

@jlillis commented on GitHub (Mar 13, 2013):

From what I can tell, most people are using virtualenvs to deploy django
apps. Which means that it's available via pip.
On Mar 13, 2013 8:21 AM, "Anatoliy Guskov" notifications@github.com wrote:

No promblem update WebVirtMgr to 1.4/1.5, but many linux distro not have
1.4/1.5 in repositories (LTS and CentOS).


Reply to this email directly or view it on GitHubhttps://github.com/retspen/webvirtmgr/issues/39#issuecomment-14838042
.

<!-- gh-comment-id:14838249 --> @jlillis commented on GitHub (Mar 13, 2013): From what I can tell, most people are using virtualenvs to deploy django apps. Which means that it's available via pip. On Mar 13, 2013 8:21 AM, "Anatoliy Guskov" notifications@github.com wrote: > No promblem update WebVirtMgr to 1.4/1.5, but many linux distro not have > 1.4/1.5 in repositories (LTS and CentOS). > > — > Reply to this email directly or view it on GitHubhttps://github.com/retspen/webvirtmgr/issues/39#issuecomment-14838042 > .
Author
Owner

@retspen commented on GitHub (Mar 13, 2013):

That's what you think. I read mail support@webvirtmgr.net and there written by those who do not know how to use virtualenv and pip. And for those who use pip and virtualenv not write letters of support.

<!-- gh-comment-id:14838588 --> @retspen commented on GitHub (Mar 13, 2013): That's what you think. I read mail support@webvirtmgr.net and there written by those who do not know how to use virtualenv and pip. And for those who use pip and virtualenv not write letters of support.
Author
Owner

@jlillis commented on GitHub (Mar 13, 2013):

Ah. Perhaps it would be best to have a 1.3 branch for compatibility and have the master be 1.5?

<!-- gh-comment-id:14839434 --> @jlillis commented on GitHub (Mar 13, 2013): Ah. Perhaps it would be best to have a 1.3 branch for compatibility and have the master be 1.5?
Author
Owner

@retspen commented on GitHub (Mar 13, 2013):

Support multiple branches will be very difficult. I did not have time to do it.

<!-- gh-comment-id:14839750 --> @retspen commented on GitHub (Mar 13, 2013): Support multiple branches will be very difficult. I did not have time to do it.
Author
Owner

@jlillis commented on GitHub (Mar 13, 2013):

I could help out with the 1.4/5 branch a bit, if needed
On Mar 13, 2013 9:04 AM, "Anatoliy Guskov" notifications@github.com wrote:

Support multiple branches will be very difficult. I did not have time to
do it.


Reply to this email directly or view it on GitHubhttps://github.com/retspen/webvirtmgr/issues/39#issuecomment-14839750
.

<!-- gh-comment-id:14839950 --> @jlillis commented on GitHub (Mar 13, 2013): I could help out with the 1.4/5 branch a bit, if needed On Mar 13, 2013 9:04 AM, "Anatoliy Guskov" notifications@github.com wrote: > Support multiple branches will be very difficult. I did not have time to > do it. > > — > Reply to this email directly or view it on GitHubhttps://github.com/retspen/webvirtmgr/issues/39#issuecomment-14839750 > .
Author
Owner

@retspen commented on GitHub (Mar 13, 2013):

Ok. I create new branch for django-1.4/5. But it is necessary to solve many other issue.

<!-- gh-comment-id:14840192 --> @retspen commented on GitHub (Mar 13, 2013): Ok. I create new branch for django-1.4/5. But it is necessary to solve many other issue.
Author
Owner

@retspen commented on GitHub (Mar 13, 2013):

Close ths issue and create new "Update Django-1.4/5"

<!-- gh-comment-id:14840265 --> @retspen commented on GitHub (Mar 13, 2013): Close ths issue and create new "Update Django-1.4/5"
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtmgr#29
No description provided.