From ac90ba92b83b788521d6d5a91f5ba3ccfccd371a Mon Sep 17 00:00:00 2001 From: Dave Hall Date: Thu, 21 Dec 2017 15:12:51 +0000 Subject: [PATCH] Trying to lose tox. It's been a right pain. --- .gitignore | 3 +- .travis.yml | 53 ++++++++++++++---- README.markdown | 10 ++-- setup.cfg | 6 ++ setup.py | 1 - tests/runtests.py | 6 ++ tests/test_watson/urls.py | 2 +- tox.ini | 44 --------------- watson/backends.py | 42 +------------- watson/south_migrations/0001_initial.py | 56 ------------------- watson/south_migrations/0002_installwatson.py | 46 --------------- watson/south_migrations/__init__.py | 0 12 files changed, 63 insertions(+), 206 deletions(-) create mode 100644 setup.cfg delete mode 100644 tox.ini delete mode 100644 watson/south_migrations/0001_initial.py delete mode 100644 watson/south_migrations/0002_installwatson.py delete mode 100644 watson/south_migrations/__init__.py diff --git a/.gitignore b/.gitignore index 5284c0e..f6623fe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ .project .pydevproject .settings -.tox *.pyc *.pyo .bzr @@ -14,4 +13,4 @@ Thumbs.db /dist *.sqlite3 *.egg-info -build \ No newline at end of file +build diff --git a/.travis.yml b/.travis.yml index 8612e64..642192e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,53 @@ -language: python sudo: false +language: python python: - - 2.7 - - 3.3 - - 3.4 - - 3.5 - 3.6 -cache: - directories: - - $HOME/.cache/pip + - 3.5 + - 2.7 +cache: pip +env: + global: + - PYTHONWARNINGS=default,ignore::PendingDeprecationWarning,ignore::ResourceWarning + matrix: + - DJANGO='>=2.0,<2.1' + - DJANGO='>=1.11,<1.12' + - DJANGO='>=1.10,<1.11' + - DJANGO='>=1.9,<1.10' + - DJANGO='>=1.8,<1.9' +matrix: + fast_finish: true + exclude: + - python: 2.7 + env: DJANGO='>=2.0,<2.1' +addons: + apt: + packages: + - libmysqlclient-dev services: - postgresql - mysql install: - - pip install tox-travis + - pip install flake8 coverage django$DJANGO psycopg2 mysqlclient -e . before_script: - - mysql -e 'create database test_project'; + - mysql -e 'create database test_project' - psql -c 'create database test_project;' -U postgres; -script: tox +script: + - flake8 + - coverage run -a tests/runtests.py + - coverage run -a tests/runtests.py -d psql + - coverage run -a tests/runtests.py -d mysql +after_success: + - coverage report +deploy: + provider: pypi + user: etianen + password: + secure: rzaq3pbJz25SVXyR/fn+gLaYxu0LqCEE+wcesg8pjA8cLLvFdLvXi0ZjmixxVl2u4HlndZrUgwTrRGVIQR1TOL0jGRYOUCJDzAaZqJkg+Qykz89iKSnentyOpNJe6fRAHsqFxBESYZjG8JEZvtRv+JIZLY+QR+KCA1xaeu4Afpw= + on: + tags: true + condition: $DJANGO='>=2.0,<2.1' + python: 3.6 + repo: etianen/django-reversion + distributions: sdist bdist_wheel notifications: email: false diff --git a/README.markdown b/README.markdown index ff588c7..feb5bc6 100644 --- a/README.markdown +++ b/README.markdown @@ -27,7 +27,7 @@ Please read the [Getting Started][] guide for more information. [Getting Started]: https://github.com/etianen/django-watson/wiki "Getting started with django-watson" - + Download instructions, bug reporting and links to full documentation can be found at the [main project website][]. @@ -51,8 +51,10 @@ You can run the test suite yourself from within a virtual environment with the f commands. ``` - pip install tox - tox + pip install psycopg2 mysqlclient -e . + tests/runtests.py + tests/runtests.py -d psql + tests/runtests.py -d mysql ``` More information @@ -63,7 +65,7 @@ from the [django-watson project site][]. [django-watson project site]: http://github.com/etianen/django-watson "django-watson on GitHub" - + Dave Hall is a freelance web developer, based in Cambridge, UK. You can usually find him on the Internet in a number of different places: diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..3018c47 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,6 @@ +[bdist_wheel] +universal = 1 + +[flake8] +max-line-length=120 +exclude=venv,migrations diff --git a/setup.py b/setup.py index 04b69fb..ed9e1a9 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,6 @@ setup( "watson.management", "watson.management.commands", "watson.migrations", - "watson.south_migrations", "watson.templatetags", ], package_data={ diff --git a/tests/runtests.py b/tests/runtests.py index 3204b33..55d746d 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -91,6 +91,12 @@ def main(): "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", ), + MIDDLEWARE=( + "django.middleware.common.CommonMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + ), USE_TZ=True, STATIC_URL="/static/", TEST_RUNNER="django.test.runner.DiscoverRunner", diff --git a/tests/test_watson/urls.py b/tests/test_watson/urls.py index ad09f1f..c43a616 100644 --- a/tests/test_watson/urls.py +++ b/tests/test_watson/urls.py @@ -16,5 +16,5 @@ urlpatterns = [ "paginate_by": 10, }), - url("^admin/", include(admin.site.urls)), + url("^admin/", admin.site.urls), ] diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 5bb0d5a..0000000 --- a/tox.ini +++ /dev/null @@ -1,44 +0,0 @@ -[tox] -envlist = - begin - py33-django18-{sqlite,postgres,mysql} - {py27,py34,py35}-django{18,19,110,111}-{sqlite,postgres,mysql} - py36-django111-{sqlite,postgres,mysql} - end - flake8 - -[testenv] -usedevelop = True -deps = - django18: Django>=1.8,<1.9 - django19: Django>=1.9,<1.10 - django110: Django>=1.10,<1.11 - django111: Django>=1.11,<1.12 - coverage>=4.1 - postgres: psycopg2 - mysql: mysqlclient -commands = - begin: coverage erase - sqlite: coverage run -a tests/runtests.py - postgres: coverage run -a tests/runtests.py -d psql - mysql: coverage run -a tests/runtests.py -d mysql - end: coverage report - -[travis] -python = - 2.7: begin, py27, end - 3.3: begin, py33, end - 3.4: begin, py34, end - 3.5: begin, py35, end, flake8 - 3.6: begin, py36, end - -[flake8] -max-line-length=120 -exclude=build,venv,migrations,south_migrations,.tox - -[testenv:flake8] -basepython = python3.5 -deps = - flake8>=2.5.4 -commands = - flake8 diff --git a/watson/backends.py b/watson/backends.py index 3cd3a65..12374a7 100644 --- a/watson/backends.py +++ b/watson/backends.py @@ -334,36 +334,6 @@ class PostgresSearchBackend(SearchBackend): ) -class PostgresLegacySearchBackend(PostgresSearchBackend): - - """ - A search backend that uses native PostgreSQL full text indices. - - This backend doesn't support prefix matching, and works with PostgreSQL 8.3 and below. - """ - - supports_prefix_matching = False - - def escape_postgres_query(self, text): - """Escapes the given text to become a valid ts_query.""" - return " & ".join( - "$${0}$$".format(word) - for word - in escape_query(text, RE_POSTGRES_ESCAPE_CHARS).split() - ) - - -class PostgresPrefixLegacySearchBackend(RegexSearchMixin, PostgresLegacySearchBackend): - - """ - A legacy search backend that uses a regexp to perform matches, but still allows - relevance rankings. - - Use if your postgres vesion is less than 8.3, and you absolutely can't live without - prefix matching. Beware, this backend can get slow with large datasets! - """ - - def escape_mysql_boolean_query(search_text): return " ".join( '+{word}*'.format( @@ -495,12 +465,6 @@ class MySQLSearchBackend(SearchBackend): ) -def get_postgresql_version(connection): - """Returns the version number of the PostgreSQL connection.""" - from django.db.backends.postgresql_psycopg2.version import get_version - return get_version(connection) - - class AdaptiveSearchBackend(SearchBackend): """ @@ -512,11 +476,7 @@ class AdaptiveSearchBackend(SearchBackend): """Guess the correct search backend and initialize it.""" connection = connections[router.db_for_read(SearchEntry)] if connection.vendor == "postgresql": - version = get_postgresql_version(connection) - if version > 80400: - return PostgresSearchBackend() - if version > 80300: - return PostgresLegacySearchBackend() + return PostgresSearchBackend() if connection.vendor == "mysql": return MySQLSearchBackend() return RegexSearchBackend() diff --git a/watson/south_migrations/0001_initial.py b/watson/south_migrations/0001_initial.py deleted file mode 100644 index 730ebfa..0000000 --- a/watson/south_migrations/0001_initial.py +++ /dev/null @@ -1,56 +0,0 @@ -# encoding: utf-8 -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - -class Migration(SchemaMigration): - - def forwards(self, orm): - - # Adding model 'SearchEntry' - db.create_table('watson_searchentry', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('engine_slug', self.gf('django.db.models.fields.CharField')(max_length=200, db_index=True)), - ('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])), - ('object_id', self.gf('django.db.models.fields.TextField')()), - ('object_id_int', self.gf('django.db.models.fields.IntegerField')(db_index=True, null=True, blank=True)), - ('title', self.gf('django.db.models.fields.CharField')(max_length=1000)), - ('description', self.gf('django.db.models.fields.TextField')(blank=True)), - ('content', self.gf('django.db.models.fields.TextField')(blank=True)), - ('url', self.gf('django.db.models.fields.CharField')(max_length=1000, blank=True)), - ('meta_encoded', self.gf('django.db.models.fields.TextField')()), - )) - db.send_create_signal('watson', ['SearchEntry']) - - - def backwards(self, orm): - - # Deleting model 'SearchEntry' - db.delete_table('watson_searchentry') - - - models = { - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'watson.searchentry': { - 'Meta': {'object_name': 'SearchEntry'}, - 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), - 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), - 'engine_slug': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_index': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'meta_encoded': ('django.db.models.fields.TextField', [], {}), - 'object_id': ('django.db.models.fields.TextField', [], {}), - 'object_id_int': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}), - 'url': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'blank': 'True'}) - } - } - - complete_apps = ['watson'] diff --git a/watson/south_migrations/0002_installwatson.py b/watson/south_migrations/0002_installwatson.py deleted file mode 100644 index a60efed..0000000 --- a/watson/south_migrations/0002_installwatson.py +++ /dev/null @@ -1,46 +0,0 @@ -# encoding: utf-8 -import datetime -from south.db import db -from south.v2 import DataMigration -from django.db import models -from django.core.management import call_command - -class Migration(DataMigration): - - def forwards(self, orm): - "Write your forwards methods here." - - # Needs to be run in a separate migration to avoid borking MySQL. - call_command("installwatson", verbosity=0) - - - def backwards(self, orm): - "Write your backwards methods here." - - call_command("uninstallwatson", verbosity=0) - - - models = { - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'watson.searchentry': { - 'Meta': {'object_name': 'SearchEntry'}, - 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), - 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), - 'engine_slug': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_index': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'meta_encoded': ('django.db.models.fields.TextField', [], {}), - 'object_id': ('django.db.models.fields.TextField', [], {}), - 'object_id_int': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}), - 'url': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'blank': 'True'}) - } - } - - complete_apps = ['watson'] diff --git a/watson/south_migrations/__init__.py b/watson/south_migrations/__init__.py deleted file mode 100644 index e69de29..0000000