Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Py3, django 1.7 for example app, wheel support, tox #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/lib
/build
.Python
.tox
16 changes: 0 additions & 16 deletions examples/protected_downloads/download/tests.py

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'protected_downloads.urls'
ROOT_URLCONF = 'example.urls'

TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'),
Expand Down
16 changes: 6 additions & 10 deletions examples/protected_downloads/manage.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env python
import os
import sys

from __future__ import absolute_import
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")

from django.core.management import execute_manager
try:
from . import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
from django.core.management import execute_from_command_line

if __name__ == "__main__":
execute_manager(settings)
execute_from_command_line(sys.argv)
1 change: 0 additions & 1 deletion examples/protected_downloads/sendfile

This file was deleted.

4 changes: 3 additions & 1 deletion sendfile/backends/_internalredirect.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django.conf import settings
from django.utils.http import urlquote
import os.path
Expand All @@ -12,4 +14,4 @@ def _convert_file_to_url(filename):
relpath, head = os.path.split(relpath)
url.insert(1, head)

return urlquote(u'/'.join(url))
return urlquote('/'.join(url))
2 changes: 1 addition & 1 deletion sendfile/backends/xsendfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

def sendfile(request, filename, **kwargs):
response = HttpResponse()
response['X-Sendfile'] = smart_str(unicode(filename))
response['X-Sendfile'] = smart_str(filename)

return response
6 changes: 4 additions & 2 deletions sendfile/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# coding=utf-8

from __future__ import unicode_literals

from django.conf import settings
from django.test import TestCase
from django.http import HttpResponse, Http404, HttpRequest
Expand Down Expand Up @@ -102,7 +104,7 @@ def test_correct_file_in_xsendfile_header(self):
self.assertEqual(filepath, response['X-Sendfile'])

def test_xsendfile_header_containing_unicode(self):
filepath = self.ensure_file(u'péter_là_gueule.txt')
filepath = self.ensure_file('péter_là_gueule.txt')
response = real_sendfile(HttpRequest(), filepath)
self.assertTrue(response is not None)
self.assertEqual(smart_str(filepath), response['X-Sendfile'])
Expand All @@ -124,7 +126,7 @@ def test_correct_url_in_xaccelredirect_header(self):
self.assertEqual('/private/readme.txt', response['X-Accel-Redirect'])

def test_xaccelredirect_header_containing_unicode(self):
filepath = self.ensure_file(u'péter_là_gueule.txt')
filepath = self.ensure_file('péter_là_gueule.txt')
response = real_sendfile(HttpRequest(), filepath)
self.assertTrue(response is not None)
self.assertEqual('/private/p%C3%A9ter_l%C3%A0_gueule.txt', response['X-Accel-Redirect'])
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[wheel]
# create "py2.py3-none-any.whl" package
universal = 1
18 changes: 8 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
from distutils.core import setup

try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
from distutils.command.build_py import build_py
from setuptools import setup


version = __import__('sendfile').__version__
Expand All @@ -19,8 +14,8 @@
url='https://github.com/johnsensible/django-sendfile',
license='BSD',

requires=['Django (>=1.3)', 'Unidecode'],
install_requires=['Django>=1.3', 'Unidecode'],
requires=['Django (>=1.4.2)', 'Unidecode'],
install_requires=['Django >=1.4.2', 'Unidecode'],

packages=['sendfile', 'sendfile.backends'],
package_dir={
Expand All @@ -40,8 +35,11 @@
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Topic :: Software Development :: Libraries :: Python Modules',
],

cmdclass={'build_py': build_py},
)
36 changes: 36 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Tox (http://codespeak.net/~hpk/tox/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
minversion=1.8.0
envlist =
py26-django14,
py26-django15,

py27-django14,
py27-django15,
py27-django16,
py27-django17,

py32-django15,
py32-django16,
py32-django17,

py33-django15,
py33-django16,
py33-django17,

py34-django15,
py34-django16,
py34-django17,

[testenv]
changedir = examples/protected_downloads
commands = python manage.py test sendfile
deps =
django14: django >=1.4.2,<1.5
django15: django >=1.5,<1.6
django16: django >=1.6,<1.7
django17: django >=1.7,<1.8