Skip to content

Commit 37f859c

Browse files
committed
Detect virtualenv
1 parent e830be3 commit 37f859c

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

cms/conf.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ def __init__(self):
123123
self.pdf_printing_allowed = False
124124

125125
# Installed or from source?
126-
self.installed = sys.argv[0].startswith("/usr/") and \
127-
sys.argv[0] != '/usr/bin/ipython' and \
128-
sys.argv[0] != '/usr/bin/python2' and \
129-
sys.argv[0] != '/usr/bin/python'
126+
self.installed = (sys.argv[0].startswith("/usr/") and
127+
sys.argv[0] != '/usr/bin/ipython' and
128+
sys.argv[0] != '/usr/bin/python2' and
129+
sys.argv[0] != '/usr/bin/python')
130+
# Test for virtualenv (see http://stackoverflow.com/a/1883251/747654)
131+
self.installed |= hasattr(sys, 'real_prefix')
130132

131133
if self.installed:
132134
self.log_dir = os.path.join("/", "var", "local", "log", "cms")

cmsranking/Config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ def __init__(self):
6363
self.buffer_size = 100 # Needs to be strictly positive.
6464

6565
# File system.
66-
self.installed = sys.argv[0].startswith("/usr/") and \
67-
sys.argv[0] != '/usr/bin/ipython' and \
68-
sys.argv[0] != '/usr/bin/python2' and \
69-
sys.argv[0] != '/usr/bin/python'
66+
self.installed = (sys.argv[0].startswith("/usr/") and
67+
sys.argv[0] != '/usr/bin/ipython' and
68+
sys.argv[0] != '/usr/bin/python2' and
69+
sys.argv[0] != '/usr/bin/python')
70+
# Test for virtualenv (see http://stackoverflow.com/a/1883251/747654)
71+
self.installed |= hasattr(sys, 'real_prefix')
7072

7173
self.web_dir = pkg_resources.resource_filename("cmsranking", "static")
7274
if self.installed:

docs/Installation.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ Method 2: Virtual environment
161161

162162
.. warning::
163163

164-
At the moment, CMS does not work correctly when installed in a virtual environment. You can use virtual enviroment to run CMS non-installed. See :ref:`the instructions <installation_running-cms-non-installed>` on how to run CMS without installing it.
165-
166164
An alternative method to perform the installation is with a `virtual environment <https://virtualenv.pypa.io/en/latest/>`_, which is an isolated Python environment that you can put wherever you like and that can be activated/deactivated at will. The tool you need in order to create a virtual environment is called ``virtualenv``, and can be installed by looking for ``virtualenv`` using your Linux distribution's package manager. For example:
167165

168166
* Ubuntu 14.x: `python-virtualenv <http://packages.ubuntu.com/trusty/python-virtualenv>`_.

0 commit comments

Comments
 (0)