Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 135 lines (116 sloc) 4.699 kB
789432b @paltman Update setup.py
paltman authored
1 import codecs
2 import os
3 import sys
b3c21de @paltman initial commit
paltman authored
4
789432b @paltman Update setup.py
paltman authored
5 from distutils.util import convert_path
6 from fnmatch import fnmatchcase
7 from setuptools import setup, find_packages
b3c21de @paltman initial commit
paltman authored
8
789432b @paltman Update setup.py
paltman authored
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,
095fbbd @jtauber doc and setup flake8 fixes
jtauber authored
33 show_ignored=False
34 ):
789432b @paltman Update setup.py
paltman authored
35 """
36 Return a dictionary suitable for use in ``package_data``
37 in a distutils ``setup.py`` file.
38
39 The dictionary looks like::
40
41 {"package": [files]}
42
43 Where ``files`` is a list of all the files in that package that
44 don"t match anything in ``exclude``.
45
46 If ``only_in_packages`` is true, then top-level directories that
47 are not packages won"t be included (but directories under packages
48 will).
49
50 Directories matching any pattern in ``exclude_directories`` will
51 be ignored; by default directories with leading ``.``, ``CVS``,
52 and ``_darcs`` will be ignored.
53
54 If ``show_ignored`` is true, then all the files that aren"t
55 included in package data are shown on stderr (for debugging
56 purposes).
57
58 Note patterns use wildcards, or can be exact paths (including
59 leading ``./``), and all searching is case-insensitive.
60 """
61 out = {}
62 stack = [(convert_path(where), "", package, only_in_packages)]
63 while stack:
64 where, prefix, package, only_in_packages = stack.pop(0)
65 for name in os.listdir(where):
66 fn = os.path.join(where, name)
67 if os.path.isdir(fn):
68 bad_name = False
69 for pattern in exclude_directories:
095fbbd @jtauber doc and setup flake8 fixes
jtauber authored
70 if fnmatchcase(name, pattern) or fn.lower() == pattern.lower():
789432b @paltman Update setup.py
paltman authored
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
095fbbd @jtauber doc and setup flake8 fixes
jtauber authored
79 if os.path.isfile(os.path.join(fn, "__init__.py")) and not prefix:
789432b @paltman Update setup.py
paltman authored
80 if not package:
81 new_package = name
82 else:
83 new_package = package + "." + name
84 stack.append((fn, "", new_package, False))
85 else:
86 stack.append((fn, prefix + name + "/", package, only_in_packages))
87 elif package or not only_in_packages:
88 # is a file
89 bad_name = False
90 for pattern in exclude:
095fbbd @jtauber doc and setup flake8 fixes
jtauber authored
91 if fnmatchcase(name, pattern) or fn.lower() == pattern.lower():
789432b @paltman Update setup.py
paltman authored
92 bad_name = True
93 if show_ignored:
94 print >> sys.stderr, (
95 "File %s ignored by pattern %s"
96 % (fn, pattern))
97 break
98 if bad_name:
99 continue
095fbbd @jtauber doc and setup flake8 fixes
jtauber authored
100 out.setdefault(package, []).append(prefix + name)
789432b @paltman Update setup.py
paltman authored
101 return out
102
103
104 PACKAGE = "privileges"
105 NAME = "privileges"
106 DESCRIPTION = "a privileges app for Django"
107 AUTHOR = "Patrick Altman"
108 AUTHOR_EMAIL = "paltman@eldarion.com"
109 URL = "https://github.com/eldarion/privileges"
110 VERSION = __import__(PACKAGE).__version__
b3c21de @paltman initial commit
paltman authored
111
112
113 setup(
789432b @paltman Update setup.py
paltman authored
114 name=NAME,
115 version=VERSION,
116 description=DESCRIPTION,
117 long_description=read("README.rst"),
118 author=AUTHOR,
119 author_email=AUTHOR_EMAIL,
120 license="BSD",
121 url=URL,
122 packages=find_packages(exclude=["tests.*", "tests"]),
123 package_data=find_package_data(PACKAGE, only_in_packages=False),
124 classifiers=[
b3c21de @paltman initial commit
paltman authored
125 "Development Status :: 3 - Alpha",
126 "Environment :: Web Environment",
127 "Intended Audience :: Developers",
128 "License :: OSI Approved :: BSD License",
129 "Operating System :: OS Independent",
130 "Programming Language :: Python",
131 "Framework :: Django",
789432b @paltman Update setup.py
paltman authored
132 ],
133 zip_safe=False,
b3c21de @paltman initial commit
paltman authored
134 )
Something went wrong with that request. Please try again.