setup.py
changeset 11653 18939907a115
parent 11642 3defbb0f147a
equal deleted inserted replaced
11652:e95725d7ce90 11653:18939907a115
     1 #!/usr/bin/env python
     1 #!/usr/bin/env python
     2 # pylint: disable=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611
     2 # pylint: disable=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611
       
     3 #
       
     4 # copyright 2003-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     5 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     6 #
     4 # This file is part of CubicWeb pyramid cube.
     7 # This file is part of CubicWeb pyramid cube.
     5 #
     8 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     9 # CubicWeb is free software: you can redistribute it and/or modify it under the
     7 # terms of the GNU Lesser General Public License as published by the Free
    10 # terms of the GNU Lesser General Public License as published by the Free
    20 __docformat__ = "restructuredtext en"
    23 __docformat__ = "restructuredtext en"
    21 
    24 
    22 import os
    25 import os
    23 import sys
    26 import sys
    24 import shutil
    27 import shutil
    25 from os.path import isdir, exists, join, walk
    28 from os.path import isdir, exists, join, walk, dirname
    26 
    29 
    27 try:
    30 try:
    28     if os.environ.get('NO_SETUPTOOLS'):
    31     if os.environ.get('NO_SETUPTOOLS'):
    29         raise ImportError() # do as there is no setuptools
    32         raise ImportError() # do as there is no setuptools
    30     from setuptools import setup
    33     from setuptools import setup
    34     from distutils.core import setup
    37     from distutils.core import setup
    35     from distutils.command import install_lib
    38     from distutils.command import install_lib
    36     USE_SETUPTOOLS = False
    39     USE_SETUPTOOLS = False
    37 from distutils.command import install_data
    40 from distutils.command import install_data
    38 
    41 
    39 # import required features
    42 # load metadata from the __pkginfo__.py file so there is no risk of conflict
    40 from __pkginfo__ import modname, version, license, description, web, \
    43 # see https://packaging.python.org/en/latest/single_source_version.html
    41      author, author_email, classifiers
    44 base_dir = dirname(__file__)
    42 
    45 
    43 if exists('README'):
    46 pkginfo = {}
    44     long_description = file('README').read()
    47 with open(join(base_dir, "__pkginfo__.py")) as f:
    45 else:
    48     exec(f.read(), pkginfo)
    46     long_description = ''
    49 
    47 
    50     
    48 # import optional features
    51 # get required metadatas
    49 import __pkginfo__
    52 modname = pkginfo['modname']
       
    53 version = pkginfo['version']
       
    54 license = pkginfo['license']
       
    55 description = pkginfo['description']
       
    56 web = pkginfo['web']
       
    57 author = pkginfo['author']
       
    58 author_email = pkginfo['author_email']
       
    59 classifiers = pkginfo['classifiers']
       
    60 
       
    61 with open(join(base_dir, 'README')) as f:
       
    62     long_description = f.read()
       
    63 
       
    64 # get optional metadatas
       
    65 distname = pkginfo.get('distname', modname)
       
    66 scripts = pkginfo.get('scripts', ())
       
    67 include_dirs = pkginfo.get('include_dirs', ())
       
    68 data_files = pkginfo.get('data_files', None)
       
    69 ext_modules = pkginfo.get('ext_modules', None)
       
    70 dependency_links = pkginfo.get('dependency_links', ())
       
    71 
    50 if USE_SETUPTOOLS:
    72 if USE_SETUPTOOLS:
    51     requires = {}
    73     requires = {}
    52     for entry in ("__depends__",): # "__recommends__"):
    74     for entry in ("__depends__",): # "__recommends__"):
    53         requires.update(getattr(__pkginfo__, entry, {}))
    75         requires.update(pkginfo.get(entry, {}))
    54     install_requires = [("%s %s" % (d, v and v or "")).strip()
    76     install_requires = [("%s %s" % (d, v and v or "")).strip()
    55                        for d, v in requires.iteritems()]
    77                        for d, v in requires.iteritems()]
    56 else:
    78 else:
    57     install_requires = []
    79     install_requires = []
    58 
    80 
    59 distname = getattr(__pkginfo__, 'distname', modname)
    81 BASE_BLACKLIST = ('CVS', '.svn', '.hg', '.git', 'debian', 'dist', 'build')
    60 scripts = getattr(__pkginfo__, 'scripts', ())
       
    61 include_dirs = getattr(__pkginfo__, 'include_dirs', ())
       
    62 data_files = getattr(__pkginfo__, 'data_files', None)
       
    63 ext_modules = getattr(__pkginfo__, 'ext_modules', None)
       
    64 dependency_links = getattr(__pkginfo__, 'dependency_links', ())
       
    65 
       
    66 BASE_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build')
       
    67 IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
    82 IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
    68 
       
    69 
    83 
    70 def ensure_scripts(linux_scripts):
    84 def ensure_scripts(linux_scripts):
    71     """
    85     """
    72     Creates the proper script names required for each platform
    86     Creates the proper script names required for each platform
    73     (taken from 4Suite)
    87     (taken from 4Suite)