This is an automated email from the ASF dual-hosted git repository. kentontaylor pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit f4ac641bcabcd7bdc199cd022fb13cf79cd93ff3 Author: Dave Brondsema <[email protected]> AuthorDate: Mon May 3 13:56:52 2021 -0400 [#8386] remove chardet, make requests library still work --- .travis.yml | 3 ++- Allura/allura/lib/custom_middleware.py | 2 +- Allura/allura/lib/helpers.py | 15 +++++++++++++++ Allura/allura/lib/phone/nexmo.py | 1 + Allura/allura/lib/project_create_helpers.py | 2 +- Allura/allura/lib/search.py | 2 +- Allura/allura/lib/security.py | 2 +- Allura/allura/lib/solr.py | 2 +- Allura/allura/webhooks.py | 2 +- Allura/docs/getting_started/install_each_step.rst | 2 +- Allura/docs/getting_started/installation.rst | 2 +- AlluraTest/alluratest/validation.py | 3 ++- ForgeImporters/forgeimporters/github/__init__.py | 1 + .../forgeimporters/tests/github/functional/test_github.py | 2 +- ForgeImporters/forgeimporters/trac/__init__.py | 1 + requirements.txt | 2 -- update.sh | 6 +++--- 17 files changed, 34 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 529efcf..3b1cee2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,8 @@ jobs: - pip install https://sourceforge.net/projects/pysvn/files/pysvn/V1.9.12/pysvn-1.9.12.tar.gz install: - sudo apt-get install -qq libjpeg8-dev zlib1g-dev - - pip install -r requirements.txt + - pip install nose + - pip install -r requirements.txt --no-deps --upgrade --upgrade-strategy=only-if-needed - npm install script: - ./rebuild-all.bash diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py index 25b31bf..55f9ab6 100644 --- a/Allura/allura/lib/custom_middleware.py +++ b/Allura/allura/lib/custom_middleware.py @@ -29,11 +29,11 @@ from tg import tmpl_context as c from tg.support.middlewares import _call_wsgi_application as call_wsgi_application from timermiddleware import Timer, TimerMiddleware from webob import exc, Request -import pysolr import six from ming.odm import session from allura.lib import helpers as h +import pysolr # after 'h' import to get requests/chardet patched from allura.lib.utils import is_ajax from allura import model as M import allura.model.repository diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py index e63232a..d70f83a 100644 --- a/Allura/allura/lib/helpers.py +++ b/Allura/allura/lib/helpers.py @@ -43,6 +43,21 @@ from functools import partial from io import BytesIO import cgi +# https://forge-allura.apache.org/p/allura/tickets/8386/ +# we don't want to depend on LGPL'd chardet, but the requests library needs it +# so if we can't import it, we'll make it exist as a copy of cchardet +# this spot in the codebase is best, since it is imported by many things and is before 'requests' is imported +# if https://github.com/psf/requests/pull/5797 is resolved, this hack could be removed +try: + import chardet +except ImportError: + import sys + import cchardet + sys.modules['chardet'] = sys.modules['cchardet'] + import chardet + chardet.__version__ += '.cchardet' + + import emoji import tg import six diff --git a/Allura/allura/lib/phone/nexmo.py b/Allura/allura/lib/phone/nexmo.py index f251c93..f5025d7 100644 --- a/Allura/allura/lib/phone/nexmo.py +++ b/Allura/allura/lib/phone/nexmo.py @@ -22,6 +22,7 @@ from six.moves.urllib.parse import urljoin import cgi import json +from allura.lib import helpers as h # to get requests/chardet patched import requests import jinja2 diff --git a/Allura/allura/lib/project_create_helpers.py b/Allura/allura/lib/project_create_helpers.py index 5e08fb3..026b197 100644 --- a/Allura/allura/lib/project_create_helpers.py +++ b/Allura/allura/lib/project_create_helpers.py @@ -29,7 +29,6 @@ except ImportError: # py2 doesn't have typing yet import colander as col import bson -import requests import formencode import six from six.moves.urllib.parse import urlparse @@ -43,6 +42,7 @@ from tg import tmpl_context as c, app_globals as g from allura import model as M from allura.lib import helpers as h +import requests from allura.lib.plugin import ProjectRegistrationProvider diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py index 462ffc2..6d44361 100644 --- a/Allura/allura/lib/search.py +++ b/Allura/allura/lib/search.py @@ -30,9 +30,9 @@ import jinja2 from tg import redirect, url from tg import tmpl_context as c, app_globals as g from tg import request -from pysolr import SolrError from allura.lib import helpers as h +from pysolr import SolrError # after 'h' import to get requests/chardet patched from allura.lib.solr import escape_solr_arg from allura.lib.utils import urlencode import six diff --git a/Allura/allura/lib/security.py b/Allura/allura/lib/security.py index 4ff62f7..2889c9e 100644 --- a/Allura/allura/lib/security.py +++ b/Allura/allura/lib/security.py @@ -25,7 +25,6 @@ import sys import logging from collections import defaultdict import hashlib -import requests from tg import tmpl_context as c from tg import request @@ -563,6 +562,7 @@ class HIBPClient(object): Raises a named HIBPCompromisedCredentials exception if any found :param password: user-supplied password """ + import requests result = 0 try: # sha1 it diff --git a/Allura/allura/lib/solr.py b/Allura/allura/lib/solr.py index d97141e..138fa6d 100644 --- a/Allura/allura/lib/solr.py +++ b/Allura/allura/lib/solr.py @@ -21,10 +21,10 @@ import logging from tg import config from paste.deploy.converters import asbool -import pysolr import six from allura.lib.helpers import shlex_split +import pysolr # after helpers import to get requests/chardet patched log = logging.getLogger(__name__) diff --git a/Allura/allura/webhooks.py b/Allura/allura/webhooks.py index a5f0004..5778b44 100644 --- a/Allura/allura/webhooks.py +++ b/Allura/allura/webhooks.py @@ -25,7 +25,6 @@ import time import socket import ssl -import requests from bson import ObjectId from tg import expose, validate, redirect, flash, config from tg.decorators import with_trailing_slash, without_trailing_slash @@ -40,6 +39,7 @@ from paste.deploy.converters import asint, aslist from allura.app import AdminControllerMixin from allura.controllers import BaseController from allura.lib import helpers as h +import requests from allura.lib import validators as v from allura.lib.decorators import require_post, task from allura.lib.utils import DateJSONEncoder diff --git a/Allura/docs/getting_started/install_each_step.rst b/Allura/docs/getting_started/install_each_step.rst index 3d0a49c..f4ff725 100644 --- a/Allura/docs/getting_started/install_each_step.rst +++ b/Allura/docs/getting_started/install_each_step.rst @@ -112,7 +112,7 @@ We'll upgrade `pip <https://pip.pypa.io/en/stable/>`_ to make sure its a current (env-allura)~/src$ cd allura (env-allura)~/src/allura$ pip install -U pip - (env-allura)~/src/allura$ pip install -r requirements.txt + (env-allura)~/src/allura$ pip install -r requirements.txt --no-deps --upgrade --upgrade-strategy=only-if-needed This may take a little while. diff --git a/Allura/docs/getting_started/installation.rst b/Allura/docs/getting_started/installation.rst index d18d818..64ace8f 100644 --- a/Allura/docs/getting_started/installation.rst +++ b/Allura/docs/getting_started/installation.rst @@ -165,7 +165,7 @@ Update requirements and reinstall apps: .. code-block:: bash - docker-compose run web pip install -r requirements.txt + docker-compose run web pip install -r requirements.txt --no-deps --upgrade --upgrade-strategy=only-if-needed docker-compose run web ./rebuild-all.bash You may want to restart at least "taskd" container after that in order for it to diff --git a/AlluraTest/alluratest/validation.py b/AlluraTest/alluratest/validation.py index 30f9c46..b10a783 100644 --- a/AlluraTest/alluratest/validation.py +++ b/AlluraTest/alluratest/validation.py @@ -39,9 +39,10 @@ import six import webtest from webtest import TestApp from ming.utils import LazyProperty -import requests from allura.lib import utils +from allura.lib import helpers as h # to get requests/chardet patched +import requests log = logging.getLogger(__name__) diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py index 32098fa..2d570b3 100644 --- a/ForgeImporters/forgeimporters/github/__init__.py +++ b/ForgeImporters/forgeimporters/github/__init__.py @@ -29,6 +29,7 @@ from datetime import datetime from tg import config, session, redirect, request, expose from tg.decorators import without_trailing_slash from tg import tmpl_context as c +from allura.lib import helpers as h # to get requests/chardet patched from requests_oauthlib import OAuth2Session import requests from formencode import validators as fev diff --git a/ForgeImporters/forgeimporters/tests/github/functional/test_github.py b/ForgeImporters/forgeimporters/tests/github/functional/test_github.py index 5cb7b8f..c83cc50 100644 --- a/ForgeImporters/forgeimporters/tests/github/functional/test_github.py +++ b/ForgeImporters/forgeimporters/tests/github/functional/test_github.py @@ -16,7 +16,6 @@ # under the License. from __future__ import unicode_literals from __future__ import absolute_import -import requests import tg from mock import patch, call, Mock from alluratest.tools import assert_equal @@ -24,6 +23,7 @@ from unittest import TestCase from allura.tests import TestController from allura import model as M +import requests class TestGitHubImportController(TestController, TestCase): diff --git a/ForgeImporters/forgeimporters/trac/__init__.py b/ForgeImporters/forgeimporters/trac/__init__.py index 3a0949d..7ba6693 100644 --- a/ForgeImporters/forgeimporters/trac/__init__.py +++ b/ForgeImporters/forgeimporters/trac/__init__.py @@ -18,6 +18,7 @@ from __future__ import unicode_literals from __future__ import absolute_import from formencode import validators as fev +from allura.lib import helpers as h # to get requests/chardet patched import requests from allura.lib import validators diff --git a/requirements.txt b/requirements.txt index 453c318..cefd5ec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,8 +24,6 @@ certifi==2019.6.16 # via requests cffi==1.12.2 # via cryptography -chardet==3.0.4 - # via requests colander==1.7.0 # via -r requirements.in crank==0.8.1 diff --git a/update.sh b/update.sh index 9bf3a1e..f160744 100755 --- a/update.sh +++ b/update.sh @@ -25,12 +25,12 @@ fi echo 'Getting latest code with `git pull` ...' git pull -echo 'Updating python packages with `pip install -r requirements.txt` ...' -pip install -r requirements.txt +echo 'Updating python packages with pip install ...' +pip install -r requirements.txt --no-deps --upgrade --upgrade-strategy=only-if-needed if [ "$?" -gt 0 ]; then echo echo - echo 'Command `pip install -r requirements.txt` failed. Sometimes this is a random download error. If so, just try again.' + echo 'Command `pip install ...` failed. Sometimes this is a random download error. If so, just try again.' exit; fi
