|
| 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("Directory %s ignored by pattern %s" % |
| 74 | + (fn, pattern), file=sys.stderr) |
| 75 | + break |
| 76 | + if bad_name: |
| 77 | + continue |
| 78 | + if (os.path.isfile(os.path.join(fn, "__init__.py")) |
| 79 | + and not prefix): |
| 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: |
| 91 | + if (fnmatchcase(name, pattern) |
| 92 | + or fn.lower() == pattern.lower()): |
| 93 | + bad_name = True |
| 94 | + if show_ignored: |
| 95 | + print("File %s ignored by pattern %s" % |
| 96 | + (fn, pattern), file=sys.stderr) |
| 97 | + break |
| 98 | + if bad_name: |
| 99 | + continue |
| 100 | + out.setdefault(package, []).append(prefix + name) |
| 101 | + return out |
| 102 | + |
| 103 | + |
| 104 | +PACKAGE = "libpythonpro" |
| 105 | +NAME = PACKAGE |
| 106 | +DESCRIPTION = "Módulo para exemplificar construção de projetos Python no curso PyTools" |
| 107 | +AUTHOR = "Guilherme da Silva Pires" |
| 108 | +AUTHOR_EMAIL = "guilhermedasilvapires1996@gmail.com" |
| 109 | +URL = "https://github.com/GuilhermeePires/libpythonpro" |
| 110 | +VERSION = __import__(PACKAGE).__version__ |
| 111 | + |
| 112 | +setup( |
| 113 | + name=NAME, |
| 114 | + version=VERSION, |
| 115 | + description=DESCRIPTION, |
| 116 | + long_description=read('README.md'), |
| 117 | + long_description_content_type='text/markdown', |
| 118 | + author=AUTHOR, |
| 119 | + author_email=AUTHOR_EMAIL, |
| 120 | + license=read('LICENSE'), |
| 121 | + url=URL, |
| 122 | + packages=find_packages(exclude=["tests.*", "tests"]), |
| 123 | + package_data=find_package_data(PACKAGE, only_in_packages=False), |
| 124 | + classifiers=[ |
| 125 | + "Development Status :: 2 - Pre-Alpha", |
| 126 | + "Environment :: Console", |
| 127 | + "Intended Audience :: Developers", |
| 128 | + "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", |
| 129 | + "Operating System :: OS Independent", |
| 130 | + "Programming Language :: Python", |
| 131 | + "Programming Language :: Python :: 3.6", |
| 132 | + "Framework :: Pytest", |
| 133 | + ], |
| 134 | + install_requires=[ |
| 135 | + 'requests' |
| 136 | + ], |
| 137 | + zip_safe=False, |
| 138 | +) |
0 commit comments