From 50ac90d1e4af4b1e6ff2472a84bacc2f45414414 Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Thu, 27 Aug 2015 17:19:18 +0200 Subject: - add license - flake8 in tox --- setup.py | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 669006e..81b3fb8 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -## header +# # header # coding: utf-8 from __future__ import print_function @@ -6,10 +6,11 @@ from __future__ import print_function if __name__ != '__main__': raise NotImplementedError('should never include setup.py') -## definitions +# # definitions full_package_name = None + def _package_data(fn): data = {} with open(fn) as fp: @@ -22,6 +23,8 @@ def _package_data(fn): continue if line.startswith(')'): break + if '# NOQA' in line: + line = line.split('# NOQA', 1)[0].rstrip() k, v = [x.strip() for x in line.split('=', 1)] if v[-1] == ',': v = v[:-1] @@ -34,10 +37,10 @@ def _package_data(fn): elif v == 'False': data[k] = False elif v[0] == '(' and v[-1] == ')': - data[k] = tuple([x.strip()[1:-1] if x[0] in '\'"' else int(x) \ - for x in v[1:-1].split(', ')]) + data[k] = tuple([x.strip()[1:-1] if x[0] in '\'"' else int(x) + for x in v[1:-1].split(', ')]) elif v[0] == '[' and v[-1] == ']': - data[k] = [x.strip()[1:-1] if x[0] in '\'"' else int(x) \ + data[k] = [x.strip()[1:-1] if x[0] in '\'"' else int(x) for x in v[1:-1].split(', ')] else: print('Unknown: >>>>> {0!r} {1!r}'.format(k, v)) @@ -49,16 +52,15 @@ exclude_files = [ 'setup.py', ] -## imports +# # imports import os import sys from setuptools import setup from setuptools.command import install_lib -## helper - +# # helper def _check_convert_version(tup): """Create a PEP 386 pseudo-format conformant string from tuple tup.""" ret_val = str(tup[0]) # first is always digit @@ -93,6 +95,7 @@ def _check_convert_version(tup): version_info = pkg_data['version_info'] version_str = _check_convert_version(version_info) + class MyInstallLib(install_lib.install_lib): def install(self): fpp = pkg_data['full_package_name'].split('.') # full package path @@ -119,7 +122,7 @@ class NameSpacePackager(object): self.depth = self.full_package_name.count('.') self.command = None if sys.argv[0] == 'setup.py' and sys.argv[1] == 'install' and \ - not '--single-version-externally-managed' in sys.argv: + '--single-version-externally-managed' not in sys.argv: print('error: have to install with "pip install ."') sys.exit(1) for x in sys.argv: @@ -191,7 +194,7 @@ class NameSpacePackager(object): for p in sys.path: if not p: continue # directory with setup.py - if os.path.exists(os.path.join(p, 'setup.py')) : + if os.path.exists(os.path.join(p, 'setup.py')): continue # some linked in stuff might not be hgi based if not os.path.isdir(p): continue @@ -220,7 +223,7 @@ class NameSpacePackager(object): if fn.startswith(pre): break else: - continue # hgiabc instead of hgi. + continue # hgiabc instead of hgi. if fn.endswith('-link') and self.command == 'install': raise InstallationError( 'Cannot mix non-develop with develop\n(pip install -e)' @@ -255,8 +258,8 @@ class NameSpacePackager(object): @property def license(self): - lic = self._pkg_data.get('license') - #if lic is None: + # lic = self._pkg_data.get('license') + # if lic is None: # lic_file_name = os.path.join(os.path.dirname(__file__), 'LICENSE') # assert os.path.exists(lic_file_name) return "MIT license" @@ -282,8 +285,8 @@ class NameSpacePackager(object): return [ 'Development Status :: {0} - {1}'.format(*self.status), 'Intended Audience :: Developers', - 'License :: ' + ('Other/Proprietary License' \ - if self._pkg_data.get('license') else \ + 'License :: ' + ('Other/Proprietary License' + if self._pkg_data.get('license') else 'OSI Approved :: MIT License'), 'Operating System :: OS Independent', 'Programming Language :: Python', @@ -300,7 +303,7 @@ class NameSpacePackager(object): df.append('LICENSE') if not df: return None - return [('.', df),] + return [('.', df), ] @property def package_data(self): @@ -314,7 +317,8 @@ class NameSpacePackager(object): return None return {self.full_package_name: df} -## call setup + +# # call setup def main(): nsp = NameSpacePackager(pkg_data) nsp.check() @@ -336,9 +340,10 @@ def main(): classifiers=nsp.classifiers, package_data=nsp.package_data, ) - for k in sorted(kw): - v = kw[k] - print(k, '->', v) + if '--version' not in sys.argv: + for k in sorted(kw): + v = kw[k] + print(k, '->', v) with open('README.rst') as fp: kw['long_description'] = fp.read() setup(**kw) -- cgit v1.2.1