Skip to content

Commit 17bf44a

Browse files
committed
To minimize what seems to be an increased risk of segfaults when using virtualenv with system packages, this commit introduces an alternative, which does away with the general system package availability, but adds symlinks to two svn related system packages when running checks.
- Legacy-Id: 12208
1 parent 4e77d64 commit 17bf44a

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

ietf/checks.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import os
2+
import sys
23
import time
34
from textwrap import dedent
45

6+
import debug # pyflakes:ignore
7+
58
from django.conf import settings
69
from django.core import checks
710
from django.utils.module_loading import import_string
@@ -213,6 +216,19 @@ def cache_error(msg, errnum):
213216
@checks.register('cache')
214217
def check_svn_import(app_configs, **kwargs):
215218
errors = []
219+
#
220+
site_packages_dir = None
221+
for p in sys.path:
222+
if ('/env/' in p or '/venv/' in p) and '/site-packages' in p:
223+
site_packages_dir = p
224+
break
225+
if site_packages_dir:
226+
for path in settings.SVN_PACKAGES:
227+
dir, name = os.path.split(path)
228+
package_link = os.path.join(site_packages_dir, name)
229+
if not os.path.exists(package_link):
230+
os.symlink(path, package_link)
231+
#
216232
if settings.SERVER_MODE == 'production':
217233
try:
218234
import svn # pyflakes:ignore
@@ -225,14 +241,15 @@ def check_svn_import(app_configs, **kwargs):
225241
226242
However, the subversion bindings seem to be unavailable. The subversion
227243
bindings are not available for install using pip, but must be supplied by
228-
the system package manager. In order to be available within a python
229-
virtualenv, the virtualenv must have been created with the
230-
--system-site-packages flag, so that the packages installed by the system
231-
package manager are visible.
244+
the system package manager. In order to be available within the python
245+
virtualenv, ietf.checks.check_svn_import() tries to create a symlink from
246+
the configured location of the system-provided svn package to the
247+
site-packages directory of the virtualenv. If you get this message, that has
248+
failed to provide the svn package.
232249
233250
Please install 'python-subversion' (Debian), 'subversion-python' (RedHat,
234-
CentOS, Fedora), 'subversion-python27bindings' (BSD); and set up a
235-
virtualenv using the --system-site-packages flag. Further tips are
251+
CentOS, Fedora), 'subversion-python27bindings' (BSD); and provide the
252+
correct path to the svn package in settings.SVN_PACKAGE. Further tips are
236253
available at https://trac.edgewall.org/wiki/TracSubversion.
237254
238255
""").replace('\n', '\n ').rstrip(),

ietf/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ def skip_unreadable_post(record):
666666
TRAC_ISSUE_URL_PATTERN = "https://trac.ietf.org/trac/%s/report/1"
667667
TRAC_SVN_DIR_PATTERN = "/a/svn/group/%s"
668668
TRAC_SVN_URL_PATTERN = "https://svn.ietf.org/svn/group/%s/"
669+
SVN_PACKAGES = [
670+
"/usr/lib/python2.7/dist-packages/svn",
671+
"/usr/lib/python2.7/dist-packages/libsvn",
672+
]
669673

670674
TRAC_ENV_OPTIONS = [
671675
('project', 'name', "{name} Wiki"),

0 commit comments

Comments
 (0)