Refs #98 - Starting refresh of development environment. Work in progress.

This commit is contained in:
Benoît Bryon 2015-06-12 11:15:39 +02:00
parent b2fa7754cc
commit f04a4b4cd4
9 changed files with 179 additions and 280 deletions

View file

@ -9,39 +9,30 @@ PIP = pip
TOX = tox
.PHONY: all help develop clean distclean maintainer-clean test documentation sphinx readme demo runserver release
# Default target. Does nothing.
all:
@echo "Reference card for usual actions in development environment."
@echo "Nothing to do by default."
@echo "Try 'make help'."
#: help - Display callable targets.
.PHONY: help
help:
@echo "Reference card for usual actions in development environment."
@echo "Here are available targets:"
@egrep -o "^#: (.+)" [Mm]akefile | sed 's/#: /* /'
#: develop - Install minimal development utilities such as tox.
#: develop - Install minimal development utilities.
.PHONY: develop
develop:
mkdir -p var
$(PIP) install tox
$(PIP) install -e ./
$(PIP) install -e ./demo/
$(PIP) install -e .
#: clean - Basic cleanup, mostly temporary files.
.PHONY: clean
clean:
find . -name "*.pyc" -delete
find . -name '*.pyo' -delete
find . -name "__pycache__" -delete
find . -name ".noseids" -delete
#: distclean - Remove local builds, such as *.egg-info.
.PHONY: distclean
distclean: clean
rm -rf *.egg
rm -rf *.egg-info
@ -49,35 +40,42 @@ distclean: clean
#: maintainer-clean - Remove almost everything that can be re-generated.
.PHONY: maintainer-clean
maintainer-clean: distclean
rm -rf bin/
rm -rf lib/
rm -rf build/
rm -rf dist/
rm -rf .tox/
#: test - Run full test suite.
#: test - Run test suites.
.PHONY: test
test:
mkdir -p var
$(PIP) install -e .[test]
$(TOX)
#: sphinx - Build Sphinx documentation.
#: documentation - Build documentation (Sphinx, README, ...)
.PHONY: documentation
documentation: sphinx readme
#: sphinx - Build Sphinx documentation (docs).
.PHONY: sphinx
sphinx:
$(TOX) -e sphinx
#: readme - Build standalone documentation files (README, CONTRIBUTING...).
.PHONY: readme
readme:
$(TOX) -e readme
#: documentation - Build full documentation.
documentation: sphinx readme
demo: develop
demo syncdb --noinput
#: demo - Setup demo project.
.PHONY: demo
demo:
demo migrate --noinput
# Install fixtures.
mkdir -p var/media
cp -r demo/demoproject/fixtures var/media/object
@ -86,10 +84,13 @@ demo: develop
demo loaddata demo.json
#: runserver - Run demo server.
.PHONY: runserver
runserver: demo
demo runserver
#: release - Tag and push to PyPI.
.PHONY: release
release:
$(TOX) -e release

View file

@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
"""Django settings for Django-DownloadView demo project."""
from os.path import abspath, dirname, join
"""Django settings for django-downloadview demo project."""
import os
# Configure some relative directories.
demoproject_dir = dirname(abspath(__file__))
demo_dir = dirname(demoproject_dir)
root_dir = dirname(demo_dir)
data_dir = join(root_dir, 'var')
cfg_dir = join(root_dir, 'etc')
demoproject_dir = os.path.dirname(os.path.abspath(__file__))
demo_dir = os.path.dirname(demoproject_dir)
root_dir = os.path.dirname(demo_dir)
data_dir = os.path.join(root_dir, 'var')
cfg_dir = os.path.join(root_dir, 'etc')
# Mandatory settings.
@ -20,7 +20,7 @@ WSGI_APPLICATION = 'demoproject.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': join(data_dir, 'db.sqlite'),
'NAME': os.path.join(data_dir, 'db.sqlite'),
}
}
@ -29,21 +29,14 @@ DATABASES = {
SECRET_KEY = "This is a secret made public on project's repository."
# Media and static files.
MEDIA_ROOT = join(data_dir, 'media')
MEDIA_ROOT = os.path.join(data_dir, 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = join(data_dir, 'static')
STATIC_ROOT = os.path.join(data_dir, 'static')
STATIC_URL = '/static/'
# Applications.
INSTALLED_APPS = (
# Standard Django applications.
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# The actual django-downloadview demo.
'demoproject',
'demoproject.object', # Demo around ObjectDownloadView
@ -54,8 +47,14 @@ INSTALLED_APPS = (
'demoproject.nginx', # Sample optimizations for Nginx X-Accel.
'demoproject.apache', # Sample optimizations for Apache X-Sendfile.
'demoproject.lighttpd', # Sample optimizations for Lighttpd X-Sendfile.
# For test purposes. The demo project is part of django-downloadview
# test suite.
# Standard Django applications.
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Stuff that must be at the end.
'django_nose',
)
@ -107,7 +106,10 @@ DOWNLOADVIEW_RULES = [
DEBUG = True
TEMPLATE_DEBUG = DEBUG
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
nose_cfg_dir = join(cfg_dir, 'nose')
NOSE_ARGS = ['--config={etc}/base.cfg'.format(etc=nose_cfg_dir),
'--config={etc}/{package}.cfg'.format(etc=nose_cfg_dir,
package=__package__)]
NOSE_ARGS = [
'--verbosity=2',
'--no-path-adjustment',
'--nocapture',
'--all-modules',
'--with-coverage',
]

View file

@ -22,7 +22,9 @@ CLASSIFIERS = ['Development Status :: 4 - Beta',
'Framework :: Django']
KEYWORDS = []
PACKAGES = ['demoproject']
REQUIREMENTS = ['django-downloadview', 'django-nose']
REQUIREMENTS = [
'django-downloadview',
'django-nose']
ENTRY_POINTS = {
'console_scripts': ['demo = demoproject.manage:main']
}

View file

@ -1,16 +1,7 @@
# -*- coding: utf-8 -*-
#
# django-downloadview documentation build configuration file, created by
# sphinx-quickstart on Mon Aug 27 11:37:23 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
"""django-downloadview documentation build configuration file."""
import os
import re
# Minimal Django settings. Required to use sphinx.ext.autodoc, because
@ -23,28 +14,16 @@ settings.configure(
)
doc_dir = os.path.dirname(os.path.abspath(__file__))
project_dir = os.path.dirname(doc_dir)
version_filename = os.path.join(project_dir, 'VERSION')
# -- General configuration ----------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinx.ext.intersphinx']
# Extensions.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinx.ext.intersphinx',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@ -53,102 +32,55 @@ templates_path = ['_templates']
source_suffix = '.txt'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'django-downloadview'
copyright = u'2012, Benoît Bryon'
project_slug = re.sub(r'([\w_.-]+)', u'-', project)
copyright = u'2012-2015, Benoît Bryon'
author = u'Benoît Bryon'
author_slug = re.sub(r'([\w_.-]+)', u'-', author)
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = open(version_filename).read().strip()
configuration_dir = os.path.dirname(__file__)
documentation_dir = configuration_dir
version_file = os.path.normpath(os.path.join(
documentation_dir,
'../VERSION'))
# The full version, including alpha/beta/rc tags.
release = version
release = open(version_file).read().strip()
# The short X.Y version.
version = '.'.join(release.split('.')[0:1])
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
language = 'en'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# -- Options for HTML output --------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
html_theme = 'alabaster'
# 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 = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
html_sidebars = {
'**': ['globaltoc.html',
@ -157,119 +89,60 @@ html_sidebars = {
'searchbox.html'],
}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'django-downloadviewdoc'
htmlhelp_basename = u'{project}doc'.format(project=project_slug)
# -- Options for sphinx.ext.intersphinx ---------------------------------------
intersphinx_mapping = {
'python': ('http://docs.python.org/2.7', None),
'django': ('http://docs.djangoproject.com/en/1.5/',
'http://docs.djangoproject.com/en/1.5/_objects/'),
'django': ('http://docs.djangoproject.com/en/1.8/',
'http://docs.djangoproject.com/en/1.8/_objects/'),
'requests': ('http://docs.python-requests.org/en/latest/', None),
}
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# -- Options for LaTeX output -------------------------------------------------
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
latex_elements = {}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
('index', 'django-downloadview.tex', u'django-downloadview Documentation',
u'Benoît Bryon', 'manual'),
('index',
u'{project}.tex'.format(project=project_slug),
u'{project} Documentation'.format(project=project),
author,
'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# -- Options for manual page output -------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'django-downloadview', u'django-downloadview Documentation',
[u'Benoît Bryon'], 1)
('index',
project,
u'{project} Documentation'.format(project=project),
[author],
1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# -- Options for Texinfo output -----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'django-downloadview', u'django-downloadview Documentation',
u'Benoît Bryon', 'django-downloadview', 'One line description of project.',
'Miscellaneous'),
('index',
project_slug,
u'{project} Documentation'.format(project=project),
author,
project,
'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

View file

@ -1,9 +0,0 @@
[nosetests]
verbosity = 2
nocapture = True
with-doctest = True
rednose = True
no-path-adjustment = True
all-modules = True
cover-inclusive = True
cover-tests = True

View file

@ -1,4 +0,0 @@
[nosetests]
with-coverage = True
cover-package = demoproject
tests = demoproject

View file

@ -1,4 +0,0 @@
[nosetests]
with-coverage = True
cover-package = django_downloadview
tests = django_downloadview,tests

View file

@ -1,9 +1,24 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Python packaging."""
import os
import sys
from setuptools import setup
from setuptools.command.test import test as TestCommand
class Tox(TestCommand):
"""Test command that runs tox."""
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import tox # import here, cause outside the eggs aren't loaded.
errno = tox.cmdline(self.test_args)
sys.exit(errno)
#: Absolute path to directory containing setup.py file.
@ -18,8 +33,9 @@ README = open(os.path.join(here, 'README.rst')).read()
VERSION = open(os.path.join(here, 'VERSION')).read().strip()
AUTHOR = u'Benoît Bryon'
EMAIL = 'benoit@marmelune.net'
LICENSE = 'BSD'
URL = 'https://{name}.readthedocs.org/'.format(name=NAME)
CLASSIFIERS = ['Development Status :: 4 - Beta',
CLASSIFIERS = ['Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
@ -36,25 +52,42 @@ KEYWORDS = ['file',
'mod_xsendfile',
'offload']
PACKAGES = [NAME.replace('-', '_')]
REQUIREMENTS = ['setuptools', 'Django>=1.5', 'requests', 'six']
REQUIREMENTS = [
'Django>=1.5',
'requests',
'setuptools',
'six',
]
if IS_PYTHON2:
REQUIREMENTS.append('mock')
ENTRY_POINTS = {}
SETUP_REQUIREMENTS = ['setuptools']
TEST_REQUIREMENTS = ['tox']
CMDCLASS = {'test': Tox}
EXTRA_REQUIREMENTS = {
'test': TEST_REQUIREMENTS,
}
if __name__ == '__main__': # Don't run setup() when we import this module.
setup(name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=README,
classifiers=CLASSIFIERS,
keywords=' '.join(KEYWORDS),
author=AUTHOR,
author_email=EMAIL,
url=URL,
license='BSD',
packages=PACKAGES,
include_package_data=True,
zip_safe=False,
install_requires=REQUIREMENTS,
entry_points=ENTRY_POINTS)
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=README,
classifiers=CLASSIFIERS,
keywords=' '.join(KEYWORDS),
author=AUTHOR,
author_email=EMAIL,
url=URL,
license=LICENSE,
packages=PACKAGES,
include_package_data=True,
zip_safe=False,
install_requires=REQUIREMENTS,
entry_points=ENTRY_POINTS,
tests_require=TEST_REQUIREMENTS,
cmdclass=CMDCLASS,
setup_requires=SETUP_REQUIREMENTS,
extras_require=EXTRA_REQUIREMENTS,
)

37
tox.ini
View file

@ -1,40 +1,44 @@
[tox]
envlist = py27,py33,flake8,sphinx,readme
envlist = py{27,33,34}-django{15,16,17,18}, flake8, sphinx, readme
[testenv]
basepython =
py27: python2.7
py33: python3.3
py34: python3.4
deps =
nose
rednose
coverage
nose
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
django18: Django>=1.8,<1.9
commands =
pip install ./
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 install -e .
pip install -e demo
demo test --cover-package=django_downloadview {posargs: django_downloadview demoproject}
cover erase
pip freeze
whitelist_externals =
rm
[testenv:flake8]
basepython = python2.7
deps =
flake8
commands =
flake8 django_downloadview/
flake8 demo/demoproject/
flake8 demo django_downloadview
[testenv:sphinx]
basepython = python2.7
deps =
nose
rednose
Sphinx
commands =
pip install ./
make --directory=docs SPHINXBUILD="sphinx-build -W" clean html doctest
pip install -e .
make --directory=docs SPHINXOPTS='-W' clean {posargs:html doctest}
whitelist_externals =
make
[testenv:readme]
basepython = python2.7
deps =
docutils
pygments
@ -47,6 +51,7 @@ whitelist_externals =
[testenv:release]
deps =
wheel
zest.releaser
commands =
fullrelease