From 17bf44af3cd2a464ebc593830a656246d694edae Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 25 Oct 2016 00:11:31 +0000 Subject: [PATCH] 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 --- ietf/checks.py | 29 +++++++++++++++++++++++------ ietf/settings.py | 4 ++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ietf/checks.py b/ietf/checks.py index e440d5038..43f1a6d9e 100644 --- a/ietf/checks.py +++ b/ietf/checks.py @@ -1,7 +1,10 @@ import os +import sys import time from textwrap import dedent +import debug # pyflakes:ignore + from django.conf import settings from django.core import checks from django.utils.module_loading import import_string @@ -213,6 +216,19 @@ def check_cache(app_configs, **kwargs): @checks.register('cache') def check_svn_import(app_configs, **kwargs): errors = [] + # + site_packages_dir = None + for p in sys.path: + if ('/env/' in p or '/venv/' in p) and '/site-packages' in p: + site_packages_dir = p + break + if site_packages_dir: + for path in settings.SVN_PACKAGES: + dir, name = os.path.split(path) + package_link = os.path.join(site_packages_dir, name) + if not os.path.exists(package_link): + os.symlink(path, package_link) + # if settings.SERVER_MODE == 'production': try: import svn # pyflakes:ignore @@ -225,14 +241,15 @@ def check_svn_import(app_configs, **kwargs): However, the subversion bindings seem to be unavailable. The subversion bindings are not available for install using pip, but must be supplied by - the system package manager. In order to be available within a python - virtualenv, the virtualenv must have been created with the - --system-site-packages flag, so that the packages installed by the system - package manager are visible. + the system package manager. In order to be available within the python + virtualenv, ietf.checks.check_svn_import() tries to create a symlink from + the configured location of the system-provided svn package to the + site-packages directory of the virtualenv. If you get this message, that has + failed to provide the svn package. Please install 'python-subversion' (Debian), 'subversion-python' (RedHat, - CentOS, Fedora), 'subversion-python27bindings' (BSD); and set up a - virtualenv using the --system-site-packages flag. Further tips are + CentOS, Fedora), 'subversion-python27bindings' (BSD); and provide the + correct path to the svn package in settings.SVN_PACKAGE. Further tips are available at https://trac.edgewall.org/wiki/TracSubversion. """).replace('\n', '\n ').rstrip(), diff --git a/ietf/settings.py b/ietf/settings.py index 98d3dfc37..56762b927 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -666,6 +666,10 @@ TRAC_WIKI_URL_PATTERN = "https://trac.ietf.org/trac/%s/wiki" TRAC_ISSUE_URL_PATTERN = "https://trac.ietf.org/trac/%s/report/1" TRAC_SVN_DIR_PATTERN = "/a/svn/group/%s" TRAC_SVN_URL_PATTERN = "https://svn.ietf.org/svn/group/%s/" +SVN_PACKAGES = [ + "/usr/lib/python2.7/dist-packages/svn", + "/usr/lib/python2.7/dist-packages/libsvn", +] TRAC_ENV_OPTIONS = [ ('project', 'name', "{name} Wiki"),