Refs #74 - Switched to tox as test-environment manager. Added flake8 to the test suite. Dropped python 2.6 tests. Makefile no longer creates a virtualenv.

This commit is contained in:
Benoît Bryon 2014-02-10 01:27:14 +01:00
parent 2962b84135
commit d587c515f0
23 changed files with 129 additions and 125 deletions

7
.gitignore vendored
View file

@ -12,6 +12,13 @@
*.pyo *.pyo
*.egg-info *.egg-info
# Tox files.
/.tox/
# Virtualenv files (created by tox).
/build/
/dist/
# Editors' temporary buffers. # Editors' temporary buffers.
.*.swp .*.swp
*~ *~

View file

@ -1,5 +1,10 @@
language: python language: python
python: env:
- "2.7" - TOXENV=py27
install: make configure develop - TOXENV=flake8
script: make test - TOXENV=sphinx
- TOXENV=readme
install:
- pip install tox
script:
- tox

View file

@ -8,7 +8,9 @@ future releases, check `milestones`_ and :doc:`/about/vision`.
1.6 (unreleased) 1.6 (unreleased)
---------------- ----------------
- Nothing changed yet. - Feature #74: the Makefile in project's repository no longer creates a
virtualenv. Developers setup the environment as they like, i.e. using
virtualenv, virtualenvwrapper or whatever. Tests are run with tox.
1.5 (2013-11-29) 1.5 (2013-11-29)

View file

@ -1,9 +1,9 @@
########################### ############
Contributing to the project Contributing
########################### ############
This document provides guidelines for people who want to contribute to the This document provides guidelines for people who want to contribute to
project. `django-downloadview`.
************** **************
@ -42,13 +42,8 @@ Fork and branch
Setup a development environment Setup a development environment
******************************* *******************************
System requirements: System requirements: `Python`_ version 2.7 and `tox`_ (you may use a
`Virtualenv`_).
* `Python`_ version 2.7, available as ``python`` command
* `Virtualenv`_ version >= 1.9.1, available as ``virtualenv`` command
* make and wget to use the provided :file:`Makefile`.
Execute: Execute:
@ -68,8 +63,7 @@ The Makefile
A :file:`Makefile` is provided to ease development. Use it to: A :file:`Makefile` is provided to ease development. Use it to:
* setup the development environment: ``make develop`` * setup a minimal development environment: ``make develop``
* update it, as an example, after a pull: ``make update``
* run tests: ``make test`` * run tests: ``make test``
* build documentation: ``make documentation`` * build documentation: ``make documentation``
@ -85,9 +79,7 @@ The :doc:`/demo` is part of the tests. Maintain it along with code and
documentation. documentation.
********** .. rubric:: Notes & references
References
**********
.. target-notes:: .. target-notes::
@ -96,6 +88,7 @@ References
.. _`rebase`: http://git-scm.com/book/en/Git-Branching-Rebasing .. _`rebase`: http://git-scm.com/book/en/Git-Branching-Rebasing
.. _`merge-based rebase`: http://tech.novapost.fr/psycho-rebasing-en.html .. _`merge-based rebase`: http://tech.novapost.fr/psycho-rebasing-en.html
.. _`Python`: http://python.org .. _`Python`: http://python.org
.. _`tox`: http://tox.testrun.org
.. _`Virtualenv`: http://virtualenv.org .. _`Virtualenv`: http://virtualenv.org
.. _`style guide for Sphinx-based documentations`: .. _`style guide for Sphinx-based documentations`:
http://documentation-style-guide-sphinx.readthedocs.org/ http://documentation-style-guide-sphinx.readthedocs.org/

20
INSTALL
View file

@ -4,11 +4,12 @@ Install
.. note:: .. note::
If you want to install a development environment, please see :doc:`/dev`. If you want to install a development environment, please see
:doc:`/contributing`.
System requirements: System requirements:
* Python 2.7 * Python version 2.7
Install the package with your favorite Python installer. As an example, with Install the package with your favorite Python installer. As an example, with
pip: pip:
@ -22,7 +23,7 @@ the following requirements:
.. literalinclude:: /../setup.py .. literalinclude:: /../setup.py
:language: python :language: python
:lines: 35 :lines: 39
.. note:: .. note::
@ -30,19 +31,6 @@ the following requirements:
:py:class:`~django.http.StreamingHttpResponse`. :py:class:`~django.http.StreamingHttpResponse`.
**************************
Known good set of versions
**************************
`django-downloadview` has been tested in an environment with the following set
of versions. If something is going wrong with other versions, please report it
in `django-downloadview's bugtracker`_.
.. literalinclude:: /../etc/buildout.cfg
:language: ini
:lines: 67-
.. rubric:: Notes & references .. rubric:: Notes & references
.. seealso:: .. seealso::

View file

@ -2,7 +2,7 @@
License License
####### #######
Copyright (c) 2012-2013, Benoît Bryon. Copyright (c) 2012-2014, Benoît Bryon.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
recursive-include django_downloadview * recursive-include django_downloadview *
global-exclude *.pyc .*.swp global-exclude *.pyc .*.swp
include *.txt include *.txt
include AUTHORS CHANGELOG INSTALL LICENSE README VERSION include AUTHORS CHANGELOG CONTRIBUTING.rst INSTALL LICENSE README.rst VERSION

View file

@ -1,92 +1,65 @@
# Makefile for development. # Reference card for usual actions in development environment.
# See INSTALL and docs/dev.txt for details. #
SHELL = /bin/bash # For standard installation of hospital as a library, see INSTALL.
ROOT_DIR = $(shell pwd) # For details about hospital's development environment, see CONTRIBUTING.rst.
DATA_DIR = $(ROOT_DIR)/var
VIRTUALENV_DIR = $(ROOT_DIR)/lib/virtualenv
BIN_DIR = $(VIRTUALENV_DIR)/bin
PIP = $(BIN_DIR)/pip
WGET = wget
PYTHON = $(BIN_DIR)/python
PROJECT = $(shell $(PYTHON) -c "import setup; print setup.NAME")
PACKAGE = $(shell $(PYTHON) -c "import setup; print setup.PACKAGES[0]")
NOSE = $(BIN_DIR)/nosetests
configure: develop:
# Configuration is stored in etc/ folder. Not generated yet. pip install tox zest.releaser
pip install -e ./
pip install -e ./demo/
develop: directories pip
virtualenv:
if [ ! -d $(VIRTUALENV_DIR)/bin/ ]; then virtualenv --no-site-packages $(VIRTUALENV_DIR); fi
$(PIP) install -r $(ROOT_DIR)/etc/virtualenv.cfg
pip: virtualenv
$(PIP) install -r etc/ci-requirements.txt
directories:
mkdir -p var/docs
mkdir -p docs/_static
mkdir -p var/test
clean: clean:
find $(ROOT_DIR)/ -name "*.pyc" -delete find . -name "*.pyc" -delete
find $(ROOT_DIR)/ -name ".noseids" -delete find . -name ".noseids" -delete
distclean: clean distclean: clean
rm -rf $(ROOT_DIR)/*.egg-info rm -rf *.egg-info
rm -rf $(ROOT_DIR)/demo/*.egg-info rm -rf demo/*.egg-info
maintainer-clean: distclean maintainer-clean: distclean
rm -rf $(BIN_DIR)/ rm -rf bin/
rm -rf $(ROOT_DIR)/lib/ rm -rf lib/
rm -rf build/
rm -rf dist/
rm -rf .tox/
test: test-app test-demo test-documentation test:
tox
test-app: test-app:
$(BIN_DIR)/demo test --nose-verbosity=2 -c $(ROOT_DIR)/etc/nose/base.cfg -c $(ROOT_DIR)/etc/nose/$(PACKAGE).cfg django_downloadview tox -e py27
mv $(ROOT_DIR)/.coverage $(ROOT_DIR)/var/test/app.coverage
test-demo: test-demo:
$(BIN_DIR)/demo test --nose-verbosity=2 tox -e demo
mv $(ROOT_DIR)/.coverage $(ROOT_DIR)/var/test/demo.coverage
test-documentation:
$(NOSE) -c $(ROOT_DIR)/etc/nose/base.cfg sphinxcontrib.testbuild.tests
sphinx: sphinx:
make --directory=docs clean html doctest tox -e sphinx
documentation: sphinx documentation: sphinx
demo: develop demo: develop
$(BIN_DIR)/demo syncdb --noinput demo syncdb --noinput
# Install fixtures. # Install fixtures.
mkdir -p var/media mkdir -p var/media
cp -r $(ROOT_DIR)/demo/demoproject/fixtures var/media/object cp -r demo/demoproject/fixtures var/media/object
cp -r $(ROOT_DIR)/demo/demoproject/fixtures var/media/object-other cp -r demo/demoproject/fixtures var/media/object-other
cp -r $(ROOT_DIR)/demo/demoproject/fixtures var/media/nginx cp -r demo/demoproject/fixtures var/media/nginx
$(BIN_DIR)/demo loaddata demo.json demo loaddata demo.json
runserver: demo runserver: demo
$(BIN_DIR)/demo runserver demo runserver
release: release:
$(BIN_DIR)/fullrelease fullrelease

View file

@ -8,8 +8,9 @@ from django_downloadview.lighttpd import x_sendfile
storage_dir = os.path.join(settings.MEDIA_ROOT, 'lighttpd') storage_dir = os.path.join(settings.MEDIA_ROOT, 'lighttpd')
storage = FileSystemStorage(location=storage_dir, storage = FileSystemStorage(
base_url=''.join([settings.MEDIA_URL, 'lighttpd/'])) location=storage_dir,
base_url=''.join([settings.MEDIA_URL, 'lighttpd/']))
optimized_by_middleware = StorageDownloadView.as_view(storage=storage, optimized_by_middleware = StorageDownloadView.as_view(storage=storage,

View file

@ -19,7 +19,6 @@ URL = 'https://{name}.readthedocs.org/'.format(name=NAME)
CLASSIFIERS = ['Development Status :: 4 - Beta', CLASSIFIERS = ['Development Status :: 4 - Beta',
'License :: OSI Approved :: BSD License', 'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 2.6',
'Framework :: Django'] 'Framework :: Django']
KEYWORDS = [] KEYWORDS = []
PACKAGES = ['demoproject'] PACKAGES = ['demoproject']

View file

@ -203,7 +203,6 @@ class VirtualFile(File):
yield buffer_ yield buffer_
class HTTPFile(File): class HTTPFile(File):
"""Wrapper for files that live on remote HTTP servers. """Wrapper for files that live on remote HTTP servers.

View file

@ -9,7 +9,7 @@ class StringIteratorIO(io.TextIOBase):
Original code by Matt Joiner <anacrolix@gmail.com> from: Original code by Matt Joiner <anacrolix@gmail.com> from:
* http://stackoverflow.com/questions/12593576/adapt-an-iterator-to-behave-like-a-file-like-object-in-python * http://stackoverflow.com/questions/12593576/
* https://gist.github.com/anacrolix/3788413 * https://gist.github.com/anacrolix/3788413
""" """

View file

@ -136,8 +136,8 @@ class DownloadResponse(StreamingHttpResponse):
generator-iterator) that produces the output in a block-by-block generator-iterator) that produces the output in a block-by-block
fashion. fashion.
* `Django WSGI handler (application implementation) return response object * Django WSGI handler (application implementation) returns response object
<https://github.com/django/django/blob/fd1279a44df3b9a837453cd79fd0fbcf81bae39d/django/core/handlers/wsgi.py#L268>`_. (see :mod:`django.core.handlers.wsgi`).
* :class:`django.http.HttpResponse` and subclasses are iterators. * :class:`django.http.HttpResponse` and subclasses are iterators.
@ -179,7 +179,7 @@ class DownloadResponse(StreamingHttpResponse):
``Content-Disposition`` header is encoded according to `RFC 5987 ``Content-Disposition`` header is encoded according to `RFC 5987
<http://tools.ietf.org/html/rfc5987>`_. See also <http://tools.ietf.org/html/rfc5987>`_. See also
http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http. http://stackoverflow.com/questions/93551/.
""" """
try: try:

View file

@ -46,7 +46,7 @@ class temporary_media_root(override_settings):
Use this function as a context manager: Use this function as a context manager:
>>> from django_downloadview.test import temporary_media_root >>> from django_downloadview.test import temporary_media_root
>>> from django.conf import settings >>> from django.conf import settings # NoQA
>>> global_media_root = settings.MEDIA_ROOT >>> global_media_root = settings.MEDIA_ROOT
>>> with temporary_media_root(): >>> with temporary_media_root():
... global_media_root == settings.MEDIA_ROOT ... global_media_root == settings.MEDIA_ROOT

View file

@ -3,7 +3,7 @@
# You can set these variables from the command line. # You can set these variables from the command line.
SPHINXOPTS = SPHINXOPTS =
SPHINXBUILD = ../bin/sphinx-build SPHINXBUILD = sphinx-build -W # Turn warnings into errors.
PAPER = PAPER =
BUILDDIR = ../var/docs BUILDDIR = ../var/docs

View file

@ -139,7 +139,7 @@ html_theme = 'default'
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.

1
docs/contributing.txt Normal file
View file

@ -0,0 +1 @@
.. include:: ../CONTRIBUTING.rst

View file

@ -21,4 +21,4 @@ Contents
django-sendfile django-sendfile
demo demo
about/index about/index
dev contributing

View file

@ -33,7 +33,7 @@ Let's consider the following view:
.. literalinclude:: /../demo/demoproject/lighttpd/views.py .. literalinclude:: /../demo/demoproject/lighttpd/views.py
:language: python :language: python
:lines: 1-6, 8-16 :lines: 1-6, 8-17
What is important here is that the files will have an ``url`` property What is important here is that the files will have an ``url`` property
implemented by storage. Let's setup an optimization rule based on that URL. implemented by storage. Let's setup an optimization rule based on that URL.
@ -97,7 +97,7 @@ As an example:
.. literalinclude:: /../demo/demoproject/lighttpd/views.py .. literalinclude:: /../demo/demoproject/lighttpd/views.py
:language: python :language: python
:lines: 1-7, 17- :lines: 1-7, 18-
************************************* *************************************

View file

@ -1,10 +0,0 @@
coverage
docutils
-e ./
-e ./demo/
mock
nose
rednose
Sphinx
sphinxcontrib-testbuild
zest.releaser

View file

@ -1,3 +0,0 @@
--index-url https://simple.crate.io
pip==1.4.1
setuptools==1.4.1

View file

@ -1,11 +1,15 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Python packaging.""" """Python packaging."""
import os import os
import sys
from setuptools import setup from setuptools import setup
#: Absolute path to directory containing setup.py file.
here = os.path.abspath(os.path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
#: Boolean, ``True`` if environment is running Python version 2.
IS_PYTHON2 = sys.version_info[0] == 2
NAME = 'django-downloadview' NAME = 'django-downloadview'
@ -13,12 +17,11 @@ DESCRIPTION = 'Serve files with Django and reverse-proxies.'
README = open(os.path.join(here, 'README.rst')).read() README = open(os.path.join(here, 'README.rst')).read()
VERSION = open(os.path.join(here, 'VERSION')).read().strip() VERSION = open(os.path.join(here, 'VERSION')).read().strip()
AUTHOR = u'Benoît Bryon' AUTHOR = u'Benoît Bryon'
EMAIL = u'benoit@marmelune.net' EMAIL = 'benoit@marmelune.net'
URL = 'https://{name}.readthedocs.org/'.format(name=NAME) URL = 'https://{name}.readthedocs.org/'.format(name=NAME)
CLASSIFIERS = ['Development Status :: 4 - Beta', CLASSIFIERS = ['Development Status :: 4 - Beta',
'License :: OSI Approved :: BSD License', 'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 2.6',
'Framework :: Django'] 'Framework :: Django']
KEYWORDS = ['file', KEYWORDS = ['file',
'stream', 'stream',
@ -33,6 +36,8 @@ KEYWORDS = ['file',
'offload'] 'offload']
PACKAGES = [NAME.replace('-', '_')] PACKAGES = [NAME.replace('-', '_')]
REQUIREMENTS = ['setuptools', 'Django>=1.5', 'requests'] REQUIREMENTS = ['setuptools', 'Django>=1.5', 'requests']
if IS_PYTHON2:
REQUIREMENTS.append('mock')
ENTRY_POINTS = {} ENTRY_POINTS = {}

44
tox.ini Normal file
View file

@ -0,0 +1,44 @@
[tox]
envlist = py27,flake8,sphinx,readme
[testenv]
deps =
nose
rednose
coverage
commands =
pip install -e ./
pip install -e demo/
demo test --nose-verbosity=2 -c etc/nose/base.cfg -c etc/nose/django_downloadview.cfg django_downloadview
demo test --nose-verbosity=2 demoproject
rm .coverage
pip freeze
whitelist_externals =
rm
[testenv:flake8]
deps =
flake8
commands =
flake8 django_downloadview/
flake8 demo/demoproject/
[testenv:sphinx]
deps =
nose
rednose
Sphinx
commands =
make --directory=docs clean html doctest
whitelist_externals =
make
[testenv:readme]
deps =
docutils
pygments
commands =
mkdir -p var/docs
rst2html.py --exit-status=2 README.rst var/docs/README.html
whitelist_externals =
mkdir