├── README.md ├── docs ├── Makefile ├── changelog.rst ├── conf.py ├── index.rst ├── installation.rst ├── signals.rst ├── templatetags.rst └── usage.rst └── setup.py /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This is what I use to package up Python (mostly Django apps) packages. 4 | 5 | ## Usage 6 | 7 | * git clone https://paltman@github.com/paltman/python-setup-template.git 8 | * cd your-project-directory 9 | * Make sure your package is not at the root of your project directory 10 | (e.g. your-project-directory/your\_package) 11 | * cp -r ../python-setup-template/\* . 12 | * Doing this you should end up with a setup.py and docs/ as peers to your 13 | your\_package directory. 14 | * Edit the docs/Makefile and change the name of the PROJECT variable 15 | to match your package name. 16 | * Edit the docs/conf.py and set the different variables to the approprate 17 | values. 18 | * Write your documentation you can use the provided stubs, but they are 19 | mostly what I use to document Django apps so I leave them in here. 20 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | PROJECT = project 15 | 16 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 17 | 18 | help: 19 | @echo "Please use \`make ' where is one of" 20 | @echo " html to make standalone HTML files" 21 | @echo " dirhtml to make HTML files named index.html in directories" 22 | @echo " singlehtml to make a single large HTML file" 23 | @echo " pickle to make pickle files" 24 | @echo " json to make JSON files" 25 | @echo " htmlhelp to make HTML files and a HTML help project" 26 | @echo " qthelp to make HTML files and a qthelp project" 27 | @echo " devhelp to make HTML files and a Devhelp project" 28 | @echo " epub to make an epub" 29 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 30 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 31 | @echo " text to make text files" 32 | @echo " man to make manual pages" 33 | @echo " changes to make an overview of all changed/added/deprecated items" 34 | @echo " linkcheck to check all external links for integrity" 35 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 36 | 37 | clean: 38 | -rm -rf $(BUILDDIR)/* 39 | 40 | html: 41 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 42 | @echo 43 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 44 | 45 | dirhtml: 46 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 47 | @echo 48 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 49 | 50 | singlehtml: 51 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 52 | @echo 53 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 54 | 55 | pickle: 56 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 57 | @echo 58 | @echo "Build finished; now you can process the pickle files." 59 | 60 | json: 61 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 62 | @echo 63 | @echo "Build finished; now you can process the JSON files." 64 | 65 | htmlhelp: 66 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 67 | @echo 68 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 69 | ".hhp project file in $(BUILDDIR)/htmlhelp." 70 | 71 | qthelp: 72 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 73 | @echo 74 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 75 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 76 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/$(PROJECT).qhcp" 77 | @echo "To view the help file:" 78 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/$(PROJECT).qhc" 79 | 80 | devhelp: 81 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 82 | @echo 83 | @echo "Build finished." 84 | @echo "To view the help file:" 85 | @echo "# mkdir -p $$HOME/.local/share/devhelp/$(PROJECT)" 86 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/$(PROJECT)" 87 | @echo "# devhelp" 88 | 89 | epub: 90 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 91 | @echo 92 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 93 | 94 | latex: 95 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 96 | @echo 97 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 98 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 99 | "(use \`make latexpdf' here to do that automatically)." 100 | 101 | latexpdf: 102 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 103 | @echo "Running LaTeX files through pdflatex..." 104 | make -C $(BUILDDIR)/latex all-pdf 105 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 106 | 107 | text: 108 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 109 | @echo 110 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 111 | 112 | man: 113 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 114 | @echo 115 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 116 | 117 | changes: 118 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 119 | @echo 120 | @echo "The overview file is in $(BUILDDIR)/changes." 121 | 122 | linkcheck: 123 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 124 | @echo 125 | @echo "Link check complete; look for any errors in the above output " \ 126 | "or in $(BUILDDIR)/linkcheck/output.txt." 127 | 128 | doctest: 129 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 130 | @echo "Testing of doctests in the sources finished, look at the " \ 131 | "results in $(BUILDDIR)/doctest/output.txt." 132 | -------------------------------------------------------------------------------- /docs/changelog.rst: -------------------------------------------------------------------------------- 1 | .. _changelog: 2 | 3 | ChangeLog 4 | ========= 5 | 6 | 7 | 0.1 8 | --- 9 | 10 | - initial release 11 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | 3 | extensions = [] 4 | templates_path = [] 5 | source_suffix = '.rst' 6 | master_doc = 'index' 7 | project = u'' 8 | copyright_holder = '' 9 | copyright = u'2012, %s' % copyright_holder 10 | exclude_patterns = ['_build'] 11 | pygments_style = 'sphinx' 12 | html_theme = 'default' 13 | htmlhelp_basename = '%sdoc' % project 14 | latex_documents = [ 15 | ('index', '%s.tex' % project, u'%s Documentation' % project, 16 | copyright_holder, 'manual'), 17 | ] 18 | man_pages = [ 19 | ('index', project, u'%s Documentation' % project, 20 | [copyright_holder], 1) 21 | ] 22 | 23 | sys.path.insert(0, os.pardir) 24 | m = __import__(project) 25 | 26 | version = m.__version__ 27 | release = version 28 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | 3 | ====== 4 | 5 | 6 | 7 | Development 8 | ----------- 9 | 10 | The source repository can be found at https://github.com/ 11 | 12 | 13 | Contents 14 | ======== 15 | 16 | .. toctree:: 17 | :maxdepth: 1 18 | 19 | changelog 20 | installation 21 | templatetags 22 | signals 23 | usage 24 | 25 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | .. _installation: 2 | 3 | Installation 4 | ============ 5 | 6 | * To install :: 7 | 8 | pip install 9 | 10 | * Add ``''`` to your ``INSTALLED_APPS`` setting:: 11 | 12 | INSTALLED_APPS = ( 13 | # other apps 14 | "", 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /docs/signals.rst: -------------------------------------------------------------------------------- 1 | .. _signals: 2 | 3 | Signals 4 | ======= 5 | 6 | -------------------------------------------------------------------------------- /docs/templatetags.rst: -------------------------------------------------------------------------------- 1 | .. _templatetags: 2 | 3 | Filters 4 | ======= 5 | 6 | 7 | 8 | Template Tags 9 | ============= 10 | 11 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | .. _usage: 2 | 3 | Usage 4 | ===== 5 | 6 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import codecs 2 | import os 3 | import sys 4 | 5 | from distutils.util import convert_path 6 | from fnmatch import fnmatchcase 7 | from setuptools import setup, find_packages 8 | 9 | 10 | def read(fname): 11 | return codecs.open(os.path.join(os.path.dirname(__file__), fname)).read() 12 | 13 | 14 | # Provided as an attribute, so you can append to these instead 15 | # of replicating them: 16 | standard_exclude = ["*.py", "*.pyc", "*$py.class", "*~", ".*", "*.bak"] 17 | standard_exclude_directories = [ 18 | ".*", "CVS", "_darcs", "./build", "./dist", "EGG-INFO", "*.egg-info" 19 | ] 20 | 21 | 22 | # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) 23 | # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php 24 | # Note: you may want to copy this into your setup.py file verbatim, as 25 | # you can't import this from another package, when you don't know if 26 | # that package is installed yet. 27 | def find_package_data( 28 | where=".", 29 | package="", 30 | exclude=standard_exclude, 31 | exclude_directories=standard_exclude_directories, 32 | only_in_packages=True, 33 | show_ignored=False): 34 | """ 35 | Return a dictionary suitable for use in ``package_data`` 36 | in a distutils ``setup.py`` file. 37 | 38 | The dictionary looks like:: 39 | 40 | {"package": [files]} 41 | 42 | Where ``files`` is a list of all the files in that package that 43 | don"t match anything in ``exclude``. 44 | 45 | If ``only_in_packages`` is true, then top-level directories that 46 | are not packages won"t be included (but directories under packages 47 | will). 48 | 49 | Directories matching any pattern in ``exclude_directories`` will 50 | be ignored; by default directories with leading ``.``, ``CVS``, 51 | and ``_darcs`` will be ignored. 52 | 53 | If ``show_ignored`` is true, then all the files that aren"t 54 | included in package data are shown on stderr (for debugging 55 | purposes). 56 | 57 | Note patterns use wildcards, or can be exact paths (including 58 | leading ``./``), and all searching is case-insensitive. 59 | """ 60 | out = {} 61 | stack = [(convert_path(where), "", package, only_in_packages)] 62 | while stack: 63 | where, prefix, package, only_in_packages = stack.pop(0) 64 | for name in os.listdir(where): 65 | fn = os.path.join(where, name) 66 | if os.path.isdir(fn): 67 | bad_name = False 68 | for pattern in exclude_directories: 69 | if (fnmatchcase(name, pattern) 70 | or fn.lower() == pattern.lower()): 71 | bad_name = True 72 | if show_ignored: 73 | print >> sys.stderr, ( 74 | "Directory %s ignored by pattern %s" 75 | % (fn, pattern)) 76 | break 77 | if bad_name: 78 | continue 79 | if (os.path.isfile(os.path.join(fn, "__init__.py")) 80 | and not prefix): 81 | if not package: 82 | new_package = name 83 | else: 84 | new_package = package + "." + name 85 | stack.append((fn, "", new_package, False)) 86 | else: 87 | stack.append((fn, prefix + name + "/", package, only_in_packages)) 88 | elif package or not only_in_packages: 89 | # is a file 90 | bad_name = False 91 | for pattern in exclude: 92 | if (fnmatchcase(name, pattern) 93 | or fn.lower() == pattern.lower()): 94 | bad_name = True 95 | if show_ignored: 96 | print >> sys.stderr, ( 97 | "File %s ignored by pattern %s" 98 | % (fn, pattern)) 99 | break 100 | if bad_name: 101 | continue 102 | out.setdefault(package, []).append(prefix+name) 103 | return out 104 | 105 | 106 | PACKAGE = "" 107 | NAME = "" 108 | DESCRIPTION = "" 109 | AUTHOR = "" 110 | AUTHOR_EMAIL = "" 111 | URL = "" 112 | VERSION = __import__(PACKAGE).__version__ 113 | 114 | 115 | setup( 116 | name=NAME, 117 | version=VERSION, 118 | description=DESCRIPTION, 119 | long_description=read("README.md"), 120 | author=AUTHOR, 121 | author_email=AUTHOR_EMAIL, 122 | license="BSD", 123 | url=URL, 124 | packages=find_packages(exclude=["tests.*", "tests"]), 125 | package_data=find_package_data(PACKAGE, only_in_packages=False), 126 | classifiers=[ 127 | "Development Status :: 3 - Alpha", 128 | "Environment :: Web Environment", 129 | "Intended Audience :: Developers", 130 | "License :: OSI Approved :: BSD License", 131 | "Operating System :: OS Independent", 132 | "Programming Language :: Python", 133 | "Framework :: Django", 134 | ], 135 | zip_safe=False, 136 | ) 137 | 138 | --------------------------------------------------------------------------------