cubicweb/skeleton/setup.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Tue, 22 Dec 2015 09:23:00 +0100
changeset 11144 fd8bf29ed00e
parent 11085 2c0541b6803f
child 11152 fccc6ddd975c
permissions -rw-r--r--
[tox] Generate test environments for Python 2.7 and 3.4 Test commands for each environment are written down explicitly since I could not find a way to extract the "package" name (e.g. "hooks") from the environment name (e.g. "py34-hooks"). For Python 3.4 interpreter, only environments (subpackages) that do not depend on cubes for their tests are listed since those test dependency cubes are not yet installable with Python 3.x. etwist is also not included since the Python 3 port is not complete at the moment. From local testing, py34 tests pass for the following subpackages: - dataimport - entities - ext - hooks - wsgi
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
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
     2
# pylint: disable=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
     3
#
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
     4
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
     5
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
     6
#
10948
3ffacbdf7e9c [skel] remove (what looks like) a spurious copy/paste
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents: 10662
diff changeset
     7
# This file is part of CubicWeb.
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
     8
#
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
     9
# CubicWeb is free software: you can redistribute it and/or modify it under the
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    10
# terms of the GNU Lesser General Public License as published by the Free
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    11
# Software Foundation, either version 2.1 of the License, or (at your option)
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    12
# any later version.
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    13
#
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    14
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    15
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    16
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    17
# details.
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    18
#
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
    19
# You should have received a copy of the GNU Lesser General Public License
10471
f04a77fe8418 [skeleton] remove no-break space from skeleton setup.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 10214
diff changeset
    20
# along with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    21
"""Generic Setup script, takes package info from __pkginfo__.py file
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    22
"""
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    23
__docformat__ = "restructuredtext en"
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    24
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    25
import os
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    26
import sys
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    27
import shutil
11071
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    28
from os.path import exists, join
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1802
diff changeset
    29
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    30
try:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    31
    if os.environ.get('NO_SETUPTOOLS'):
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
    32
        raise ImportError()  # do as there is no setuptools
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    33
    from setuptools import setup
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    34
    from setuptools.command import install_lib
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    35
    USE_SETUPTOOLS = True
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    36
except ImportError:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    37
    from distutils.core import setup
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    38
    from distutils.command import install_lib
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    39
    USE_SETUPTOOLS = False
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    40
from distutils.command import install_data
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
# import required features
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    43
from __pkginfo__ import modname, version, license, description, web, \
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
    44
    author, author_email, classifiers
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    45
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    46
if exists('README'):
10614
57dfde80df11 [py3k] file → open
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10471
diff changeset
    47
    long_description = open('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
    48
else:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
    49
    long_description = ''
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    50
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    51
# import optional features
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    52
import __pkginfo__
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    53
if USE_SETUPTOOLS:
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    54
    requires = {}
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
    55
    for entry in ("__depends__",):  # "__recommends__"):
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    56
        requires.update(getattr(__pkginfo__, entry, {}))
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    57
    install_requires = [("%s %s" % (d, v and v or "")).strip()
10662
10942ed172de [py3k] dict.iteritems → dict.items
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10614
diff changeset
    58
                        for d, v in requires.items()]
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    59
else:
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    60
    install_requires = []
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    61
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    62
distname = getattr(__pkginfo__, 'distname', modname)
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    63
scripts = getattr(__pkginfo__, 'scripts', ())
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    64
include_dirs = getattr(__pkginfo__, 'include_dirs', ())
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    65
data_files = getattr(__pkginfo__, 'data_files', None)
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    66
ext_modules = getattr(__pkginfo__, 'ext_modules', None)
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    67
dependency_links = getattr(__pkginfo__, 'dependency_links', ())
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    68
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    69
BASE_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build')
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    70
IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    71
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    72
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    73
def ensure_scripts(linux_scripts):
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    74
    """
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    75
    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
    76
    (taken from 4Suite)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    77
    """
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    78
    from distutils import util
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    79
    if util.get_platform()[:3] == 'win':
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    80
        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
    81
    else:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    82
        scripts_ = linux_scripts
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    83
    return scripts_
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    84
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
    85
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    86
def export(from_dir, to_dir,
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    87
           blacklist=BASE_BLACKLIST,
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    88
           ignore_ext=IGNORED_EXTENSIONS,
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    89
           verbose=True):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    90
    try:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    91
        os.mkdir(to_dir)
8695
358d8bed9626 [toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8565
diff changeset
    92
    except OSError as ex:
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    93
        # file exists ?
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    94
        import errno
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    95
        if ex.errno != errno.EEXIST:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    96
            raise
11071
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    97
    for dirpath, dirnames, filenames in os.walk(from_dir):
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    98
        for norecurs in blacklist:
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    99
            try:
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   100
                dirnames.remove(norecurs)
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   101
            except ValueError:
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   102
                pass
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   103
        for dirname in dirnames:
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   104
            dest = join(to_dir, dirname)
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   105
            if not exists(dest):
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   106
                os.mkdir(dest)
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   107
        for filename in filenames:
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   108
            # don't include binary files
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   109
            src = join(dirpath, filename)
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   110
            dest = to_dir + src[len(from_dir):]
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   111
            if filename[-4:] in ignore_ext:
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   112
                continue
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   113
            if filename[-1] == '~':
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   114
                continue
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   115
            if exists(dest):
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   116
                os.remove(dest)
11085
2c0541b6803f [skeleton] Restore verbose output in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11071
diff changeset
   117
            if verbose:
2c0541b6803f [skeleton] Restore verbose output in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11071
diff changeset
   118
                sys.stderr.write('%s -> %s\n' % (src, dest))
11071
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   119
            shutil.copy2(src, dest)
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   120
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   121
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   122
class MyInstallLib(install_lib.install_lib):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   123
    """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
   124
    include_dirs variable if necessary
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
    def run(self):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   127
        """overridden from install_lib class"""
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   128
        install_lib.install_lib.run(self)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   129
        # manually install included directories if any
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   130
        if include_dirs:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   131
            base = modname
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   132
            for directory in include_dirs:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   133
                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
   134
                export(directory, dest, verbose=False)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   135
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   136
# re-enable copying data files in sys.prefix
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   137
old_install_data = install_data.install_data
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   138
if USE_SETUPTOOLS:
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   139
    # overwrite InstallData to use sys.prefix instead of the egg directory
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   140
    class MyInstallData(old_install_data):
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   141
        """A class that manages data files installation"""
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   142
        def run(self):
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   143
            _old_install_dir = self.install_dir
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   144
            if self.install_dir.endswith('egg'):
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   145
                self.install_dir = sys.prefix
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   146
            old_install_data.run(self)
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   147
            self.install_dir = _old_install_dir
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   148
    try:
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   149
        # only if easy_install available
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   150
        import setuptools.command.easy_install  # noqa
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   151
        # monkey patch: Crack SandboxViolation verification
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   152
        from setuptools.sandbox import DirectorySandbox as DS
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   153
        old_ok = DS._ok
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   154
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   155
        def _ok(self, path):
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   156
            """Return True if ``path`` can be written during installation."""
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   157
            out = old_ok(self, path)  # here for side effect from setuptools
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   158
            realpath = os.path.normcase(os.path.realpath(path))
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   159
            allowed_path = os.path.normcase(sys.prefix)
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   160
            if realpath.startswith(allowed_path):
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   161
                out = True
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   162
            return out
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   163
        DS._ok = _ok
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   164
    except ImportError:
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   165
        pass
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   166
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   167
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   168
def install(**kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   169
    """setup entry point"""
5360
96893296772f [skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5334
diff changeset
   170
    if USE_SETUPTOOLS:
96893296772f [skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5334
diff changeset
   171
        if '--force-manifest' in sys.argv:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   172
            sys.argv.remove('--force-manifest')
5360
96893296772f [skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5334
diff changeset
   173
    # install-layout option was introduced in 2.5.3-1~exp1
96893296772f [skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5334
diff changeset
   174
    elif sys.version_info < (2, 5, 4) and '--install-layout=deb' in sys.argv:
96893296772f [skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5334
diff changeset
   175
        sys.argv.remove('--install-layout=deb')
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   176
    cmdclass = {'install_lib': MyInstallLib}
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   177
    if USE_SETUPTOOLS:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   178
        kwargs['install_requires'] = install_requires
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   179
        kwargs['dependency_links'] = dependency_links
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   180
        kwargs['zip_safe'] = False
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   181
        cmdclass['install_data'] = MyInstallData
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   182
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   183
    return setup(name=distname,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   184
                 version=version,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   185
                 license=license,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   186
                 description=description,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   187
                 long_description=long_description,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   188
                 author=author,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   189
                 author_email=author_email,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   190
                 url=web,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   191
                 scripts=ensure_scripts(scripts),
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   192
                 data_files=data_files,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   193
                 ext_modules=ext_modules,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   194
                 cmdclass=cmdclass,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   195
                 classifiers=classifiers,
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   196
                 **kwargs
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   197
                 )
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 232
diff changeset
   198
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   199
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   200
if __name__ == '__main__':
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   201
    install()