1from pkg_resources import parse_version 2from configparser import ConfigParser 3import setuptools 4assert parse_version(setuptools.__version__)>=parse_version('36.2') 5 6# note: all settings are in settings.ini; edit there, not here 7config = ConfigParser(delimiters=['=']) 8config.read('settings.ini') 9cfg = config['DEFAULT'] 10 11cfg_keys = 'version description keywords author author_email'.split() 12expected = cfg_keys + "lib_name user branch license status min_python audience language".split() 13for o in expected: assert o in cfg, "missing expected setting: {}".format(o) 14setup_cfg = {o:cfg[o] for o in cfg_keys} 15 16licenses = { 17 'apache2': ('Apache Software License 2.0','OSI Approved :: Apache Software License'), 18} 19statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha', 20 '4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ] 21py_versions = '2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8'.split() 22 23requirements = cfg.get('requirements','').split() 24lic = licenses[cfg['license']] 25min_python = cfg['min_python'] 26 27setuptools.setup( 28 name = cfg['lib_name'], 29 license = lic[0], 30 classifiers = [ 31 'Development Status :: ' + statuses[int(cfg['status'])], 32 'Intended Audience :: ' + cfg['audience'].title(), 33 'License :: ' + lic[1], 34 'Natural Language :: ' + cfg['language'].title(), 35 ] + ['Programming Language :: Python :: '+o for o in py_versions[py_versions.index(min_python):]], 36 url = 'https://github.com/{}/{}'.format(cfg['user'],cfg['lib_name']), 37 packages = setuptools.find_packages(), 38 include_package_data = True, 39 install_requires = requirements, 40 python_requires = '>=' + cfg['min_python'], 41 long_description = open('README.md').read(), 42 long_description_content_type = 'text/markdown', 43 zip_safe = False, 44 entry_points = { 'console_scripts': cfg.get('console_scripts','').split() }, 45 **setup_cfg) 46 47