1import codecs 2import os 3import re 4 5from setuptools import find_packages, setup 6 7 8############################################################################### 9 10NAME = "attrs" 11PACKAGES = find_packages(where="src") 12META_PATH = os.path.join("src", "attr", "__init__.py") 13KEYWORDS = ["class", "attribute", "boilerplate"] 14CLASSIFIERS = [ 15 "Development Status :: 5 - Production/Stable", 16 "Intended Audience :: Developers", 17 "Natural Language :: English", 18 "License :: OSI Approved :: MIT License", 19 "Operating System :: OS Independent", 20 "Programming Language :: Python", 21 "Programming Language :: Python :: 2", 22 "Programming Language :: Python :: 2.7", 23 "Programming Language :: Python :: 3", 24 "Programming Language :: Python :: 3.4", 25 "Programming Language :: Python :: 3.5", 26 "Programming Language :: Python :: 3.6", 27 "Programming Language :: Python :: 3.7", 28 "Programming Language :: Python :: Implementation :: CPython", 29 "Programming Language :: Python :: Implementation :: PyPy", 30 "Topic :: Software Development :: Libraries :: Python Modules", 31] 32INSTALL_REQUIRES = [] 33EXTRAS_REQUIRE = { 34 "docs": [ 35 "sphinx", 36 "zope.interface", 37 ], 38 "tests": [ 39 "coverage", 40 "hypothesis", 41 "pympler", 42 "pytest", 43 "six", 44 "zope.interface", 45 ], 46} 47EXTRAS_REQUIRE["dev"] = EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["docs"] 48 49############################################################################### 50 51HERE = os.path.abspath(os.path.dirname(__file__)) 52 53 54def read(*parts): 55 """ 56 Build an absolute path from *parts* and and return the contents of the 57 resulting file. Assume UTF-8 encoding. 58 """ 59 with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f: 60 return f.read() 61 62 63META_FILE = read(META_PATH) 64 65 66def find_meta(meta): 67 """ 68 Extract __*meta*__ from META_FILE. 69 """ 70 meta_match = re.search( 71 r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), 72 META_FILE, re.M 73 ) 74 if meta_match: 75 return meta_match.group(1) 76 raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta)) 77 78 79VERSION = find_meta("version") 80URI = find_meta("uri") 81LONG = ( 82 read("README.rst") + "\n\n" + 83 "Release Information\n" + 84 "===================\n\n" + 85 re.search("(\d+.\d.\d \(.*?\)\n.*?)\n\n\n----\n\n\n", 86 read("CHANGELOG.rst"), re.S).group(1) + 87 "\n\n`Full changelog " + 88 "<{uri}en/stable/changelog.html>`_.\n\n".format(uri=URI) + 89 read("AUTHORS.rst") 90) 91 92 93if __name__ == "__main__": 94 setup( 95 name=NAME, 96 description=find_meta("description"), 97 license=find_meta("license"), 98 url=URI, 99 version=VERSION, 100 author=find_meta("author"), 101 author_email=find_meta("email"), 102 maintainer=find_meta("author"), 103 maintainer_email=find_meta("email"), 104 keywords=KEYWORDS, 105 long_description=LONG, 106 packages=PACKAGES, 107 package_dir={"": "src"}, 108 zip_safe=False, 109 classifiers=CLASSIFIERS, 110 install_requires=INSTALL_REQUIRES, 111 extras_require=EXTRAS_REQUIRE, 112 ) 113