| 1 | = Django on Windows = |
| 2 | |
| 3 | (work in progress) |
| 4 | |
| 5 | == Test suite failures == |
| 6 | |
| 7 | As of r7787 the test suite is failing in two places when run under Windows: |
| 8 | |
| 9 | * If setuptools is installed, on a test from {{{tests/regressiontests/templates/loaders.py}}} related to trying to load a template from an egg (from a report on #django-dev, this is a test that is also failing under OS X). |
| 10 | * On a date-related query from ({{{tests/regressiontests/queries/models.py}}}) when using the sqlite3 Django DB backend under Pyhton 2.5.2 |
| 11 | |
| 12 | === tests/regressiontests/templates/loaders.py === |
| 13 | |
| 14 | TBD |
| 15 | |
| 16 | === tests/regressiontests/queries/models.py === |
| 17 | |
| 18 | This test: |
| 19 | |
| 20 | {{{ |
| 21 | #!python |
| 22 | Bug #7087 -- dates with extra select columns |
| 23 | >>> Item.objects.dates('created', 'day').extra(select={'a': 1}) |
| 24 | [datetime.datetime(2007, 12, 19, 0, 0), datetime.datetime(2007, 12, 20, 0, 0)] |
| 25 | }}} |
| 26 | |
| 27 | from {{{tests/regressiontests/queries/models.py}}} fails. |
| 28 | |
| 29 | This is a minimal models.py that shows the problem (extracted from the above regression test): |
| 30 | |
| 31 | {{{ |
| 32 | #!python |
| 33 | """ |
| 34 | >>> time1 = datetime.datetime(2007, 12, 19, 22, 25, 0) |
| 35 | >>> time2 = datetime.datetime(2007, 12, 19, 21, 0, 0) |
| 36 | >>> time3 = datetime.datetime(2007, 12, 20, 22, 25, 0) |
| 37 | >>> time4 = datetime.datetime(2007, 12, 20, 21, 0, 0) |
| 38 | >>> i1 = Item(name='one', created=time1, modified=time1) |
| 39 | >>> i1.save() |
| 40 | >>> i2 = Item(name='two', created=time2) |
| 41 | >>> i2.save() |
| 42 | >>> i3 = Item(name='three', created=time3) |
| 43 | >>> i3.save() |
| 44 | >>> i4 = Item(name='four', created=time4) |
| 45 | >>> i4.save() |
| 46 | |
| 47 | >>> Item.objects.dates('created', 'day').extra(select={'a': 1}) |
| 48 | [datetime.datetime(2007, 12, 19, 0, 0), datetime.datetime(2007, 12, 20, 0, 0)] |
| 49 | |
| 50 | """ |
| 51 | |
| 52 | from django.db import models |
| 53 | import datetime |
| 54 | |
| 55 | class Item(models.Model): |
| 56 | name = models.CharField(max_length=10) |
| 57 | created = models.DateTimeField() |
| 58 | modified = models.DateTimeField(blank=True, null=True) |
| 59 | |
| 60 | class Meta: |
| 61 | ordering = ['name'] |
| 62 | |
| 63 | def __unicode__(self): |
| 64 | return self.name |
| 65 | }}} |
| 66 | |
| 67 | |
| 68 | |
| 69 | The SQL being generated by Django is correct: |
| 70 | |
| 71 | {{{ |
| 72 | #!python |
| 73 | >>> Item.objects.dates('created', 'day').extra(select={'a': 1}).query.as_sql() |
| 74 | ('SELECT DISTINCT (1) AS "a", django_date_trunc("day", "sqlite3_dates_item"."created") FROM "sqlite3_dates_item" ORDER BY 1 ASC', ()) |
| 75 | }}} |
| 76 | |
| 77 | Problems seems to be related to some bug in the version of pysqlite2 or sqlite3 (most likely suspect) included with the official Python 2.5.2 win32 installer (2.3.2 and 3.3.4 respectively): |
| 78 | |
| 79 | {{{ |
| 80 | #!python |
| 81 | Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 |
| 82 | Type "help", "copyright", "credits" or "license" for more information. |
| 83 | >>> from sqlite3 import dbapi2 |
| 84 | >>> print dbapi2.version_info |
| 85 | (2, 3, 2) |
| 86 | >>> print dbapi2.sqlite_version_info |
| 87 | (3, 3, 4) |
| 88 | }}} |
| 89 | |
| 90 | The same test works flawlessly under the following platforms: |
| 91 | * GNU/Debian Linux 4.0 (Python 2.4.4 + pysqlite2 2.3.2 + sqlite3 3.3.8) |
| 92 | * GNU/Debian Linux Sid as of Jun 29, 2008 (Python 2.5.2 + builtin pysqlite2 aka sqlite3 2.3.2 + sqlite 3.5.9) |
| 93 | this may be thanks to the fact that on these platforms the shared sqlite3 library being used by the Python pysqlite2 (Python 2.4) or sqlite3 (Python 2.5) modules is the system wide one and so it hasn't been frozen on 3.3.4. |
| 94 | |
| 95 | ==== Possible solution ==== |
| 96 | |
| 97 | The pysqlite project keeps publishing win32 binary installer for Python 2.5. |
| 98 | |
| 99 | TBD |
| 100 | |
| 101 | == See also == |
| 102 | |
| 103 | * WindowsInstall |