bcrypt/setup.py
2014-12-05 20:54:56 -05:00

112 lines
2.4 KiB
Python

#!/usr/bin/env python
import os
import sys
from setuptools import setup
from setuptools.command.test import test
SIX_DEPENDENCY = "six>=1.4.1"
class _AttrDict(dict):
def __getattr__(self, key):
try:
return self[key]
except KeyError:
# to conform with __getattr__ spec
raise AttributeError(key)
def __setattr__(self, key, value):
self[key] = value
# This is really hacky, but it ensures that if setup_requires are being used
# setup.py can import them. No idea why this is required.
sys.path += [x for x in os.listdir(".") if x.endswith(".egg")]
try:
from bcrypt import __about__, _ffi
except ImportError:
# installing - there is no cffi yet
ext_modules = []
# Manually extract the __about__
__about__ = _AttrDict()
with open("bcrypt/__about__.py") as fp:
exec(fp.read(), __about__)
else:
# building bdist - cffi is here!
ext_modules = [_ffi.verifier.get_extension()]
class PyTest(test):
def finalize_options(self):
test.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
setup(
name=__about__.__title__,
version=__about__.__version__,
description=__about__.__summary__,
long_description=open("README.rst").read(),
url=__about__.__uri__,
license=__about__.__license__,
author=__about__.__author__,
author_email=__about__.__email__,
setup_requires=[
"cffi",
SIX_DEPENDENCY,
],
install_requires=[
"cffi",
SIX_DEPENDENCY,
],
extras_require={
"tests": [
"pytest",
"mock",
],
},
tests_require=[
"pytest",
"mock",
],
packages=[
"bcrypt",
],
package_data={
"bcrypt": ["crypt_blowfish-1.2/*"],
},
ext_modules=ext_modules,
zip_safe=False,
cmdclass={"test": PyTest},
classifiers=[
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
]
)