#!/usr/bin/env python # -*- coding: utf-8 -*- """ ISO Standards Setup Standard setup.py file which is used to package and distribute a Python package with Distutils so that it can be published to a PyPI server. This file belongs in the root directory of a project repository. This is an example that uses some basic options which are available for the setup of a PyPI package. It also reads and gathers example dependencies for a package. See: https://pythonhosted.org/setuptools/setuptools.html for more details. """ import re from setuptools import find_packages from setuptools import setup def find_version(fname): """Attempts to find the version number in the file names fname. Raises RuntimeError if not found. """ version = '' with open(fname) as fp: reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]') for line in fp: m = reg.match(line) if m: version = m.group(1) break if not version: raise RuntimeError('Cannot find version information') return version def read_requirements(path): """Read requirements from file based on file path provided. Lines beginning with a dash are excluded, e.g. references to an internal PyPI server url (-i). Args: path (str): File path for requirements text file. Returns: Array of requirements libraries. """ with open(path, 'r') as fd: requirements = [ req.strip() for req in fd.readlines() if not req.startswith('-')] return requirements install_requires = list(read_requirements('requirements.txt')) tests_require = list(set( install_requires + read_requirements('requirements-dev.txt'))) setup( name='python-common-apispec', version=find_version('common_apispec/__init__.py'), description='A pluggable API specification generator', author='The Orchard', author_email='webdev@theorchard.com', url='https://github.com/theorchard/python-common-apispec', packages=find_packages(exclude=('test*', )), package_dir={'common_apispec': 'common_apispec'}, include_package_data=True, test_suite='tests', zip_safe=False, install_requires=install_requires, tests_require=tests_require )