1#!/usr/bin/env python
2from __future__ import print_function
3import io
4import os
5import sys
6from fnmatch import fnmatchcase
7
8from setuptools import convert_path, find_packages, setup
9
10
11# Provided as an attribute, so you can append to these instead
12# of replicating them:
13standard_exclude = ["*.py", "*.pyc", "*~", ".*", "*.bak", "Makefile"]
14standard_exclude_directories = [
15    ".*", "CVS", "_darcs", "./build",
16    "./dist", "EGG-INFO", "*.egg-info",
17    "./example"
18]
19
20
21# Copied from paste/util/finddata.py
22def find_package_data(where=".", package="", exclude=standard_exclude,
23                      exclude_directories=standard_exclude_directories,
24                      only_in_packages=True, show_ignored=False):
25    """
26    Return a dictionary suitable for use in ``package_data``
27    in a distutils ``setup.py`` file.
28
29    The dictionary looks like::
30
31        {"package": [files]}
32
33    Where ``files`` is a list of all the files in that package that
34    don't match anything in ``exclude``.
35
36    If ``only_in_packages`` is true, then top-level directories that
37    are not packages won't be included (but directories under packages
38    will).
39
40    Directories matching any pattern in ``exclude_directories`` will
41    be ignored; by default directories with leading ``.``, ``CVS``,
42    and ``_darcs`` will be ignored.
43
44    If ``show_ignored`` is true, then all the files that aren't
45    included in package data are shown on stderr (for debugging
46    purposes).
47
48    Note patterns use wildcards, or can be exact paths (including
49    leading ``./``), and all searching is case-insensitive.
50    """
51
52    out = {}
53    stack = [(convert_path(where), "", package, only_in_packages)]
54    while stack:
55        where, prefix, package, only_in_packages = stack.pop(0)
56        for name in os.listdir(where):
57            fn = os.path.join(where, name)
58            if os.path.isdir(fn):
59                bad_name = False
60                for pattern in exclude_directories:
61                    if (fnmatchcase(name, pattern)
62                            or fn.lower() == pattern.lower()):
63                        bad_name = True
64                        if show_ignored:
65                            print(
66                                "Directory %s ignored by pattern %s"
67                                % (fn, pattern), file=sys.stderr)
68                        break
69                if bad_name:
70                    continue
71                if (os.path.isfile(os.path.join(fn, "__init__.py"))
72                        and not prefix):
73                    if not package:
74                        new_package = name
75                    else:
76                        new_package = package + "." + name
77                    stack.append((fn, "", new_package, False))
78                else:
79                    stack.append((fn, prefix + name + "/", package,
80                                  only_in_packages))
81            elif package or not only_in_packages:
82                # is a file
83                bad_name = False
84                for pattern in exclude:
85                    if (fnmatchcase(name, pattern)
86                            or fn.lower() == pattern.lower()):
87                        bad_name = True
88                        if show_ignored:
89                            print(
90                                "File %s ignored by pattern %s"
91                                % (fn, pattern), file=sys.stderr)
92                        break
93                if bad_name:
94                    continue
95                out.setdefault(package, []).append(prefix+name)
96    return out
97
98
99excluded_directories = standard_exclude_directories
100
101package_data = find_package_data(exclude_directories=excluded_directories)
102
103long_description = io.open('README.rst', encoding='utf-8').read()
104
105# Dynamically calculate the version based on allauth.VERSION.
106version = __import__('allauth').__version__
107
108METADATA = dict(
109    name='django-allauth',
110    version=version,
111    author='Raymond Penners',
112    author_email='raymond.penners@intenct.nl',
113    description='Integrated set of Django applications addressing'
114    ' authentication, registration, account management as well as'
115    ' 3rd party (social) account authentication.',
116    long_description=long_description,
117    url='http://github.com/pennersr/django-allauth',
118    keywords='django auth account social openid twitter facebook oauth'
119    ' registration',
120    tests_require=[],
121    install_requires=['Django >= 2.0',
122                      'python3-openid >= 3.0.8',
123                      'requests-oauthlib >= 0.3.0',
124                      "requests"],
125    include_package_data=True,
126    classifiers=[
127        'Development Status :: 4 - Beta',
128        'Intended Audience :: Developers',
129        'Topic :: Software Development :: Libraries :: Python Modules',
130        'Environment :: Web Environment',
131        'Topic :: Internet',
132        'License :: OSI Approved :: MIT License',
133        'Operating System :: OS Independent',
134        'Programming Language :: Python',
135        'Programming Language :: Python :: 3',
136        'Programming Language :: Python :: 3.5',
137        'Programming Language :: Python :: 3.6',
138        'Programming Language :: Python :: 3.7',
139        'Programming Language :: Python :: 3.8',
140        'Framework :: Django',
141        'Framework :: Django :: 2.0',
142        'Framework :: Django :: 2.1',
143        'Framework :: Django :: 2.2',
144        'Framework :: Django :: 3.0',
145    ],
146    packages=find_packages(exclude=['example']),
147    package_data=package_data,
148)
149
150if __name__ == '__main__':
151    setup(**METADATA)
152