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
*.egg-info
# Tox files.
/.tox/
# Virtualenv files (created by tox).
/build/
/dist/
# Editors' temporary buffers.
.*.swp
*~

View file

@ -1,5 +1,10 @@
language: python
python:
- "2.7"
install: make configure develop
script: make test
env:
- TOXENV=py27
- TOXENV=flake8
- 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)
----------------
- 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)

View file

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

20
INSTALL
View file

@ -4,11 +4,12 @@ Install
.. 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:
* Python 2.7
* Python version 2.7
Install the package with your favorite Python installer. As an example, with
pip:
@ -22,7 +23,7 @@ the following requirements:
.. literalinclude:: /../setup.py
:language: python
:lines: 35
:lines: 39
.. note::
@ -30,19 +31,6 @@ the following requirements:
: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
.. seealso::

View file

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

View file

@ -1,4 +1,4 @@
recursive-include django_downloadview *
global-exclude *.pyc .*.swp
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.
# See INSTALL and docs/dev.txt for details.
SHELL = /bin/bash
ROOT_DIR = $(shell pwd)
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
# Reference card for usual actions in development environment.
#
# For standard installation of hospital as a library, see INSTALL.
# For details about hospital's development environment, see CONTRIBUTING.rst.
configure:
# Configuration is stored in etc/ folder. Not generated yet.
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
develop:
pip install tox zest.releaser
pip install -e ./
pip install -e ./demo/
clean:
find $(ROOT_DIR)/ -name "*.pyc" -delete
find $(ROOT_DIR)/ -name ".noseids" -delete
find . -name "*.pyc" -delete
find . -name ".noseids" -delete
distclean: clean
rm -rf $(ROOT_DIR)/*.egg-info
rm -rf $(ROOT_DIR)/demo/*.egg-info
rm -rf *.egg-info
rm -rf demo/*.egg-info
maintainer-clean: distclean
rm -rf $(BIN_DIR)/
rm -rf $(ROOT_DIR)/lib/
rm -rf bin/
rm -rf lib/
rm -rf build/
rm -rf dist/
rm -rf .tox/
test: test-app test-demo test-documentation
test:
tox
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
mv $(ROOT_DIR)/.coverage $(ROOT_DIR)/var/test/app.coverage
tox -e py27
test-demo:
$(BIN_DIR)/demo test --nose-verbosity=2
mv $(ROOT_DIR)/.coverage $(ROOT_DIR)/var/test/demo.coverage
test-documentation:
$(NOSE) -c $(ROOT_DIR)/etc/nose/base.cfg sphinxcontrib.testbuild.tests
tox -e demo
sphinx:
make --directory=docs clean html doctest
tox -e sphinx
documentation: sphinx
demo: develop
$(BIN_DIR)/demo syncdb --noinput
demo syncdb --noinput
# Install fixtures.
mkdir -p var/media
cp -r $(ROOT_DIR)/demo/demoproject/fixtures var/media/object
cp -r $(ROOT_DIR)/demo/demoproject/fixtures var/media/object-other
cp -r $(ROOT_DIR)/demo/demoproject/fixtures var/media/nginx
$(BIN_DIR)/demo loaddata demo.json
cp -r demo/demoproject/fixtures var/media/object
cp -r demo/demoproject/fixtures var/media/object-other
cp -r demo/demoproject/fixtures var/media/nginx
demo loaddata demo.json
runserver: demo
$(BIN_DIR)/demo runserver
demo runserver
release:
$(BIN_DIR)/fullrelease
fullrelease

View file

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

View file

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

View file

@ -203,7 +203,6 @@ class VirtualFile(File):
yield buffer_
class HTTPFile(File):
"""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:
* 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
"""

View file

@ -136,8 +136,8 @@ class DownloadResponse(StreamingHttpResponse):
generator-iterator) that produces the output in a block-by-block
fashion.
* `Django WSGI handler (application implementation) return response object
<https://github.com/django/django/blob/fd1279a44df3b9a837453cd79fd0fbcf81bae39d/django/core/handlers/wsgi.py#L268>`_.
* Django WSGI handler (application implementation) returns response object
(see :mod:`django.core.handlers.wsgi`).
* :class:`django.http.HttpResponse` and subclasses are iterators.
@ -179,7 +179,7 @@ class DownloadResponse(StreamingHttpResponse):
``Content-Disposition`` header is encoded according to `RFC 5987
<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:

View file

@ -46,7 +46,7 @@ class temporary_media_root(override_settings):
Use this function as a context manager:
>>> 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
>>> with temporary_media_root():
... global_media_root == settings.MEDIA_ROOT

View file

@ -3,7 +3,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = ../bin/sphinx-build
SPHINXBUILD = sphinx-build -W # Turn warnings into errors.
PAPER =
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,
# relative to this directory. They are copied after the builtin static files,
# 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,
# 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
demo
about/index
dev
contributing

View file

@ -33,7 +33,7 @@ Let's consider the following view:
.. literalinclude:: /../demo/demoproject/lighttpd/views.py
: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
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
: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 -*-
"""Python packaging."""
import os
import sys
from setuptools import setup
#: Absolute path to directory containing setup.py 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'
@ -13,12 +17,11 @@ DESCRIPTION = 'Serve files with Django and reverse-proxies.'
README = open(os.path.join(here, 'README.rst')).read()
VERSION = open(os.path.join(here, 'VERSION')).read().strip()
AUTHOR = u'Benoît Bryon'
EMAIL = u'benoit@marmelune.net'
EMAIL = 'benoit@marmelune.net'
URL = 'https://{name}.readthedocs.org/'.format(name=NAME)
CLASSIFIERS = ['Development Status :: 4 - Beta',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 2.6',
'Framework :: Django']
KEYWORDS = ['file',
'stream',
@ -33,6 +36,8 @@ KEYWORDS = ['file',
'offload']
PACKAGES = [NAME.replace('-', '_')]
REQUIREMENTS = ['setuptools', 'Django>=1.5', 'requests']
if IS_PYTHON2:
REQUIREMENTS.append('mock')
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