skeleton/setup.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 20 Apr 2010 09:11:34 +0200
changeset 5331 f7ee75da6102
parent 5184 955ee1b24756
child 5334 7da1a6ca8f65
permissions -rw-r--r--
[skel] cleanup default cube setup.py
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
#!/usr/bin/env python
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
     2
# pylint: disable-msg=W0404,W0622,W0704,W0613,W0152
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
     3
"""Generic Setup script, takes package info from __pkginfo__.py file.
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1802
diff changeset
     4
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
     5
:copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1802
diff changeset
     6
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1802
diff changeset
     7
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1802
diff changeset
     8
"""
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
     9
__docformat__ = "restructuredtext en"
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    10
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    11
import os
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    12
import sys
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    13
import shutil
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    14
from os.path import isdir, exists, join, walk
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    15
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    16
try:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    17
    if os.environ.get('NO_SETUPTOOLS'):
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    18
        raise ImportError()
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    19
    from setuptools import setup
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    20
    from setuptools.command import install_lib
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    21
    USE_SETUPTOOLS = 1
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    22
except ImportError:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    23
    from distutils.core import setup
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    24
    from distutils.command import install_lib
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    25
    USE_SETUPTOOLS = 0
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    26
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    28
sys.modules.pop('__pkginfo__', None)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
# import required features
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    30
from __pkginfo__ import modname, version, license, short_desc, \
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    31
     web, author, author_email
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    32
# import optional features
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    33
import __pkginfo__
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    34
distname = getattr(__pkginfo__, 'distname', modname)
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    35
scripts = getattr(__pkginfo__, 'scripts', [])
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    36
data_files = getattr(__pkginfo__, 'data_files', None)
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    37
include_dirs = getattr(__pkginfo__, 'include_dirs', [])
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    38
ext_modules = getattr(__pkginfo__, 'ext_modules', None)
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    39
dependency_links = getattr(__pkginfo__, 'dependency_links', None)
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    40
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    41
STD_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build')
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    42
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    43
IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    44
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    45
if exists('README'):
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    46
    long_description = file('README').read()
5184
955ee1b24756 [c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5024
diff changeset
    47
else:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    48
    long_description = ''
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    49
if USE_SETUPTOOLS:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    50
   requires = {}
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    51
   for entry in ("__depends__", "__recommends__"):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    52
      requires.update(getattr(__pkginfo__, entry, {}))
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    53
   install_requires = [("%s %s" % (d, v and v or "")).strip()
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    54
                       for d, v in requires.iteritems()]
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    55
else:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    56
   install_requires = []
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    57
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    58
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    59
def ensure_scripts(linux_scripts):
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    60
    """Creates the proper script names required for each platform
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    61
    (taken from 4Suite)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    62
    """
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    63
    from distutils import util
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    64
    if util.get_platform()[:3] == 'win':
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    65
        scripts_ = [script + '.bat' for script in linux_scripts]
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    66
    else:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    67
        scripts_ = linux_scripts
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    68
    return scripts_
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    69
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    70
def get_packages(directory, prefix):
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    71
    """return a list of subpackages for the given directory"""
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    72
    result = []
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    73
    for package in os.listdir(directory):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    74
        absfile = join(directory, package)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    75
        if isdir(absfile):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    76
            if exists(join(absfile, '__init__.py')) or \
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    77
                   package in ('test', 'tests'):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    78
                if prefix:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    79
                    result.append('%s.%s' % (prefix, package))
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    80
                else:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    81
                    result.append(package)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    82
                result += get_packages(absfile, result[-1])
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    83
    return result
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    84
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    85
def export(from_dir, to_dir,
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    86
           blacklist=STD_BLACKLIST,
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    87
           ignore_ext=IGNORED_EXTENSIONS,
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    88
           verbose=True):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    89
    """make a mirror of from_dir in to_dir, omitting directories and files
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    90
    listed in the black list
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    91
    """
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    92
    def make_mirror(arg, directory, fnames):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    93
        """walk handler"""
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    94
        for norecurs in blacklist:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    95
            try:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    96
                fnames.remove(norecurs)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    97
            except ValueError:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    98
                pass
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    99
        for filename in fnames:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   100
            # don't include binary files
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   101
            if filename[-4:] in ignore_ext:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   102
                continue
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   103
            if filename[-1] == '~':
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   104
                continue
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   105
            src = join(directory, filename)
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   106
            dest = to_dir + src[len(from_dir):]
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   107
            if verbose:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   108
                print >> sys.stderr, src, '->', dest
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   109
            if os.path.isdir(src):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   110
                if not exists(dest):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   111
                    os.mkdir(dest)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   112
            else:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   113
                if exists(dest):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   114
                    os.remove(dest)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   115
                shutil.copy2(src, dest)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   116
    try:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   117
        os.mkdir(to_dir)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   118
    except OSError, ex:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   119
        # file exists ?
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   120
        import errno
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   121
        if ex.errno != errno.EEXIST:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   122
            raise
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   123
    walk(from_dir, make_mirror, None)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   124
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   125
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   126
class MyInstallLib(install_lib.install_lib):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   127
    """extend install_lib command to handle  package __init__.py and
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   128
    include_dirs variable if necessary
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   129
    """
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   130
    def run(self):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   131
        """overridden from install_lib class"""
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   132
        install_lib.install_lib.run(self)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   133
        # manually install included directories if any
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   134
        if include_dirs:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   135
            base = modname
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   136
            for directory in include_dirs:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   137
                dest = join(self.install_dir, base, directory)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   138
                export(directory, dest, verbose=False)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   139
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   140
def install(**kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   141
    """setup entry point"""
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   142
    try:
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   143
        if USE_SETUPTOOLS:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   144
            sys.argv.remove('--force-manifest')
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   145
    except:
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   146
        pass
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   147
    try:
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   148
        if not USE_SETUPTOOLS:
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   149
            # install-layout option was introduced in 2.5.3-1~exp1
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   150
            if sys.versioninfo < (2, 5, 4):
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   151
                sys.argv.remove('--install-layout=deb')
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   152
                print "W: remove '--install-layout=deb' option"
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   153
    except:
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   154
        pass
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   155
    kwargs['package_dir'] = {modname : '.'}
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   156
    packages = [modname] + get_packages(os.getcwd(), modname)
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   157
    if USE_SETUPTOOLS and install_requires:
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   158
        kwargs['install_requires'] = install_requires
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   159
        kwargs['dependency_links'] = dependency_links
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   160
    kwargs['packages'] = packages
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   161
    return setup(name = distname,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   162
                 version = version,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   163
                 license = license,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   164
                 description = short_desc,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   165
                 long_description = long_description,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   166
                 author = author,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   167
                 author_email = author_email,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   168
                 url = web,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   169
                 scripts = ensure_scripts(scripts),
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   170
                 data_files = data_files,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   171
                 ext_modules = ext_modules,
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   172
                 cmdclass = {'install_lib': MyInstallLib},
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   173
                 **kwargs
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   174
                 )
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 232
diff changeset
   175
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   176
if __name__ == '__main__' :
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   177
    install()