Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update setup.py

  • Loading branch information...
commit 789432b84f71335a92ae25d99e8db6458511512f 1 parent c88924b
Patrick Altman authored July 12, 2012
21  privileges/__init__.py
... ...
@@ -1,23 +1,4 @@
1  
-VERSION = (0, 1, 0, "a", 1) # following PEP 386
2  
-DEV_N = 3
3  
-POST_N = 0
4  
-
5  
-
6  
-def build_version():
7  
-    version = "%s.%s" % (VERSION[0], VERSION[1])
8  
-    if VERSION[2]:
9  
-        version = "%s.%s" % (version, VERSION[2])
10  
-    if VERSION[3] != "f":
11  
-        version = "%s%s%s" % (version, VERSION[3], VERSION[4])
12  
-        if DEV_N:
13  
-            version = "%s.dev%s" % (version, DEV_N)
14  
-    elif POST_N > 0:
15  
-        version = "%s.post%s" % (version, POST_N)
16  
-    return version
17  
-
18  
-
19  
-__version__ = build_version()
20  
-
  1
+__version__ = "0.1"
21 2
 
22 3
 
23 4
 handlers = set()
139  setup.py
... ...
@@ -1,23 +1,129 @@
1  
-from distutils.core import setup
  1
+import codecs
  2
+import os
  3
+import sys
2 4
 
  5
+from distutils.util import convert_path
  6
+from fnmatch import fnmatchcase
  7
+from setuptools import setup, find_packages
3 8
 
4  
-VERSION = __import__("privileges").__version__
  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 = "privileges"
  107
+NAME = "privileges"
  108
+DESCRIPTION = "a privileges app for Django"
  109
+AUTHOR = "Patrick Altman"
  110
+AUTHOR_EMAIL = "paltman@eldarion.com"
  111
+URL = "https://github.com/eldarion/privileges"
  112
+VERSION = __import__(PACKAGE).__version__
5 113
 
6 114
 
7 115
 setup(
8  
-    name = "privileges",
9  
-    version = VERSION,
10  
-    author = "Eldarion",
11  
-    author_email = "development@eldarion.com",
12  
-    description = "an extensible privileges app",
13  
-    long_description = open("README.rst").read(),
14  
-    license = "BSD",
15  
-    url = "http://github.com/eldarion/privileges",
16  
-    packages = [
17  
-        "privileges",
18  
-        "privileges.templatetags",
19  
-    ],
20  
-    classifiers = [
  116
+    name=NAME,
  117
+    version=VERSION,
  118
+    description=DESCRIPTION,
  119
+    long_description=read("README.rst"),
  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=[
21 127
         "Development Status :: 3 - Alpha",
22 128
         "Environment :: Web Environment",
23 129
         "Intended Audience :: Developers",
@@ -25,5 +131,6 @@
25 131
         "Operating System :: OS Independent",
26 132
         "Programming Language :: Python",
27 133
         "Framework :: Django",
28  
-    ]
  134
+    ],
  135
+    zip_safe=False,
29 136
 )

0 notes on commit 789432b

Please sign in to comment.
Something went wrong with that request. Please try again.