attrs/setup.py

108 lines
3.1 KiB
Python
Raw Normal View History

2015-01-27 16:53:17 +00:00
import codecs
import os
import re
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
2015-02-21 13:08:36 +00:00
NAME = "attrs"
META_PATH = os.path.join("attr", "__init__.py")
###############################################################################
HERE = os.path.abspath(os.path.dirname(__file__))
2015-01-27 16:53:17 +00:00
def read(*parts):
"""
Build an absolute path from *parts* and and return the contents of the
resulting file. Assume UTF-8 encoding.
"""
2015-02-21 13:08:36 +00:00
with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f:
2015-01-27 16:53:17 +00:00
return f.read()
2015-02-21 13:08:36 +00:00
META_FILE = read(META_PATH)
def find_meta(meta):
2015-01-27 16:53:17 +00:00
"""
2015-02-21 13:08:36 +00:00
Extract __*meta*__ from META_FILE.
2015-01-27 16:53:17 +00:00
"""
2015-02-21 13:08:36 +00:00
meta_match = re.search(
r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta),
META_FILE, re.M
)
if meta_match:
return meta_match.group(1)
raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta))
2015-01-27 16:53:17 +00:00
class PyTest(TestCommand):
2015-02-21 13:14:47 +00:00
user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]
2015-01-27 16:53:17 +00:00
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = None
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args or [] +
2015-01-29 18:04:23 +00:00
["tests"])
2015-01-27 16:53:17 +00:00
sys.exit(errno)
if __name__ == "__main__":
setup(
2015-02-21 13:08:36 +00:00
name=NAME,
description=find_meta("description"),
license=find_meta("license"),
url=find_meta("uri"),
version=find_meta("version"),
author=find_meta("author"),
author_email=find_meta("email"),
maintainer=find_meta("author"),
maintainer_email=find_meta("email"),
keywords=find_meta("keywords"),
long_description=(
read("README.rst") + "\n\n" +
read("AUTHORS.rst")
),
2015-02-21 13:14:47 +00:00
packages=find_packages(exclude=["tests*"]),
2015-02-21 13:08:36 +00:00
zip_safe=False,
2015-01-27 16:53:17 +00:00
classifiers=[
2015-01-28 15:05:13 +00:00
"Development Status :: 3 - Alpha",
2015-01-27 16:53:17 +00:00
"Intended Audience :: Developers",
"Natural Language :: English",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
],
install_requires=[
],
tests_require=[
2015-01-29 18:04:23 +00:00
"pytest",
"zope.interface",
2015-01-27 16:53:17 +00:00
],
cmdclass={
"test": PyTest,
},
)