Browse Source

Pin everything to Python3 & Django 2.2 (#4952)

Anthony Monthe 6 years ago
parent
commit
783b5bd8d0

+ 3 - 26
frameworks/Python/django/benchmark_config.json

@@ -2,29 +2,6 @@
   "framework": "django",
   "framework": "django",
   "tests": [{
   "tests": [{
     "default": {
     "default": {
-      "plaintext_url" : "/plaintext",
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/dbs?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/update?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "MySQL",
-      "framework": "django",
-      "language": "Python",
-      "flavor": "Python2",
-      "orm": "Full",
-      "platform": "None",
-      "webserver": "Meinheld",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Django",
-      "notes": "CPython 2.7",
-      "versus": "wsgi"
-    },
-    "py3": {
       "plaintext_url" : "/plaintext",
       "plaintext_url" : "/plaintext",
       "json_url": "/json",
       "json_url": "/json",
       "db_url": "/db",
       "db_url": "/db",
@@ -44,7 +21,7 @@
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",
       "display_name": "Django",
       "display_name": "Django",
-      "notes": "CPython 3.4",
+      "notes": "CPython 3.6",
       "versus": "wsgi"
       "versus": "wsgi"
     },
     },
     "postgresql": {
     "postgresql": {
@@ -58,14 +35,14 @@
       "database": "Postgres",
       "database": "Postgres",
       "framework": "django",
       "framework": "django",
       "language": "Python",
       "language": "Python",
-      "flavor": "Python2",
+      "flavor": "Python3",
       "orm": "Full",
       "orm": "Full",
       "platform": "None",
       "platform": "None",
       "webserver": "Meinheld",
       "webserver": "Meinheld",
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",
       "display_name": "Django",
       "display_name": "Django",
-      "notes": "CPython 2.7",
+      "notes": "CPython 3.6",
       "versus": "wsgi"
       "versus": "wsgi"
     }
     }
   }]
   }]

+ 1 - 1
frameworks/Python/django/django-postgresql.dockerfile

@@ -1,4 +1,4 @@
-FROM python:2.7.15-stretch
+FROM python:3.6.9-stretch
 
 
 ADD ./ /django
 ADD ./ /django
 
 

+ 0 - 9
frameworks/Python/django/django-py3.dockerfile

@@ -1,9 +0,0 @@
-FROM python:3.6.6-stretch
-
-ADD ./ /django
-
-WORKDIR /django
-
-RUN pip3 install -r /django/requirements_py3.txt
-
-CMD gunicorn --pid=gunicorn.pid hello.wsgi:application -c gunicorn_conf.py --env DJANGO_DB=mysql

+ 1 - 1
frameworks/Python/django/django.dockerfile

@@ -1,4 +1,4 @@
-FROM python:2.7.15-stretch
+FROM python:3.6.9-stretch
 
 
 ADD ./ /django
 ADD ./ /django
 
 

+ 3 - 8
frameworks/Python/django/hello/world/views.py

@@ -1,5 +1,4 @@
 import random
 import random
-import sys
 from operator import attrgetter
 from operator import attrgetter
 from functools import partial
 from functools import partial
 from ujson import dumps as uj_dumps
 from ujson import dumps as uj_dumps
@@ -10,10 +9,6 @@ from django.shortcuts import render
 from world.models import World, Fortune
 from world.models import World, Fortune
 
 
 
 
-if sys.version_info[0] == 3:
-    xrange = range
-
-
 def _get_queries(request):
 def _get_queries(request):
     try:
     try:
         queries = int(request.GET.get('queries', 1))
         queries = int(request.GET.get('queries', 1))
@@ -60,8 +55,8 @@ def dbs(request):
     # dictionaries on the fly instead of serializing later
     # dictionaries on the fly instead of serializing later
     # by creating dicts, we don't need to user the model serializer, which is probably slow and only appropriate
     # by creating dicts, we don't need to user the model serializer, which is probably slow and only appropriate
     # for complicated serializations of joins and crazy query sets etc
     # for complicated serializations of joins and crazy query sets etc
-    # test xrange vs range if the query number is gigantic
-    worlds = uj_dumps([{'id' : r, 'randomNumber' : g(id=r).randomnumber} for r in [rp() for q in xrange(queries)]])
+    # test range vs range if the query number is gigantic
+    worlds = uj_dumps([{'id' : r, 'randomNumber' : g(id=r).randomnumber} for r in [rp() for q in range(queries)]])
     return HttpResponse(worlds, content_type="application/json")
     return HttpResponse(worlds, content_type="application/json")
 
 
 
 
@@ -81,7 +76,7 @@ def update(request):
     rp = partial(random.randint, 1, 10000)
     rp = partial(random.randint, 1, 10000)
 
 
     worlds = []
     worlds = []
-    for r in [rp() for q in xrange(queries)]:
+    for r in [rp() for q in range(queries)]:
         w = g(id=r)
         w = g(id=r)
         w.randomnumber = rp()
         w.randomnumber = rp()
         w.save()
         w.save()

+ 2 - 2
frameworks/Python/django/requirements.txt

@@ -1,8 +1,8 @@
-Django==1.11.21
+Django==2.2.3
 greenlet==0.4.14
 greenlet==0.4.14
 gunicorn==19.9.0
 gunicorn==19.9.0
 meinheld==0.6.1
 meinheld==0.6.1
-mysqlclient==1.3.12
+mysqlclient==1.3.13
 psycopg2==2.7.5
 psycopg2==2.7.5
 pytz==2017.3
 pytz==2017.3
 ujson==1.35
 ujson==1.35

+ 0 - 8
frameworks/Python/django/requirements_py3.txt

@@ -1,8 +0,0 @@
-Django==2.0.10
-greenlet==0.4.14
-gunicorn==19.9.0
-meinheld==0.6.1
-mysqlclient==1.3.12
-psycopg2==2.7.5
-pytz==2017.3
-ujson==1.35