cubicweb/skeleton/setup.py
author Julien Cristau <julien.cristau@logilab.fr>
Mon, 08 Feb 2016 15:37:52 +0100
changeset 11157 42fa15632493
parent 11152 fccc6ddd975c
child 11424 1451f040555f
permissions -rw-r--r--
[web/test] return the hash of uploaded files in FileUploadTC instead of their contents json must be unicode, which doesn't go well with arbitrary file contents. Compute the file hash instead, as we know the hexdigest is (ascii) text.
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
#
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
     4
# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
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
     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
#
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
     7
# This file is part of a CubicWeb cube.
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
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    28
from os.path import exists, join, dirname
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
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    42
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    43
# load metadata from the __pkginfo__.py file so there is no risk of conflict
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    44
# see https://packaging.python.org/en/latest/single_source_version.html
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    45
base_dir = dirname(__file__)
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    46
pkginfo = {}
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    47
with open(join(base_dir, "__pkginfo__.py")) as f:
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    48
    exec(f.read(), pkginfo)
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    49
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    50
# get required metadatas
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    51
modname = pkginfo['modname']
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    52
version = pkginfo['version']
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    53
license = pkginfo['license']
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    54
description = pkginfo['description']
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    55
web = pkginfo['web']
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    56
author = pkginfo['author']
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    57
author_email = pkginfo['author_email']
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    58
classifiers = pkginfo['classifiers']
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    59
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    60
with open(join(base_dir, 'README')) as f:
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    61
    long_description = f.read()
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    62
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    63
# get optional metadatas
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    64
distname = pkginfo.get('distname', modname)
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    65
scripts = pkginfo.get('scripts', ())
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    66
include_dirs = pkginfo.get('include_dirs', ())
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    67
data_files = pkginfo.get('data_files', None)
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    68
ext_modules = pkginfo.get('ext_modules', None)
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    69
dependency_links = pkginfo.get('dependency_links', ())
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    70
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    71
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
    72
    requires = {}
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
    73
    for entry in ("__depends__",):  # "__recommends__"):
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    74
        requires.update(pkginfo.get(entry, {}))
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    75
    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
    76
                        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
    77
else:
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    78
    install_requires = []
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    79
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
    80
BASE_BLACKLIST = ('CVS', '.svn', '.hg', '.git', 'debian', 'dist', 'build')
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    81
IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    82
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    83
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    84
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
    85
    """
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    86
    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
    87
    (taken from 4Suite)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    88
    """
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    89
    from distutils import util
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    90
    if util.get_platform()[:3] == 'win':
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    91
        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
    92
    else:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    93
        scripts_ = linux_scripts
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    94
    return scripts_
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    95
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
    96
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    97
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
    98
           blacklist=BASE_BLACKLIST,
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
    99
           ignore_ext=IGNORED_EXTENSIONS,
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   100
           verbose=True):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   101
    try:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   102
        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
   103
    except OSError as ex:
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   104
        # file exists ?
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   105
        import errno
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   106
        if ex.errno != errno.EEXIST:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   107
            raise
11071
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   108
    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
   109
        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
   110
            try:
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   111
                dirnames.remove(norecurs)
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   112
            except ValueError:
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   113
                pass
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
   114
        for dir_name in dirnames:
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
   115
            dest = join(to_dir, dir_name)
11071
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   116
            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
   117
                os.mkdir(dest)
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   118
        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
   119
            # 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
   120
            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
   121
            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
   122
            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
   123
                continue
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   124
            if filename[-1] == '~':
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   125
                continue
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   126
            if exists(dest):
fdadf59be612 [skeleton] Use os.walk in setup.py for Python3 compatibility
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   127
                os.remove(dest)
11085
2c0541b6803f [skeleton] Restore verbose output in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11071
diff changeset
   128
            if verbose:
2c0541b6803f [skeleton] Restore verbose output in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11071
diff changeset
   129
                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
   130
            shutil.copy2(src, dest)
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   131
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   132
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   133
class MyInstallLib(install_lib.install_lib):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   134
    """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
   135
    include_dirs variable if necessary
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   136
    """
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   137
    def run(self):
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   138
        """overridden from install_lib class"""
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   139
        install_lib.install_lib.run(self)
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   140
        # manually install included directories if any
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   141
        if include_dirs:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   142
            base = modname
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   143
            for directory in include_dirs:
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   144
                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
   145
                export(directory, dest, verbose=False)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   146
11152
fccc6ddd975c [skeleton] do not import the __pkginfo__.py module to make cubes installable via setuptools
David Douard <david.douard@logilab.fr>
parents: 11085
diff changeset
   147
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   148
# 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
   149
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
   150
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
   151
    # 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
   152
    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
   153
        """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
   154
        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
   155
            _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
   156
            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
   157
                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
   158
            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
   159
            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
   160
    try:
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   161
        # only if easy_install available
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   162
        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
   163
        # 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
   164
        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
   165
        old_ok = DS._ok
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   166
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   167
        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
   168
            """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
   169
            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
   170
            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
   171
            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
   172
            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
   173
                out = True
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   174
            return out
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   175
        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
   176
    except ImportError:
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   177
        pass
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   178
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   179
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   180
def install(**kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   181
    """setup entry point"""
5360
96893296772f [skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5334
diff changeset
   182
    if USE_SETUPTOOLS:
96893296772f [skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5334
diff changeset
   183
        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
   184
            sys.argv.remove('--force-manifest')
5360
96893296772f [skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5334
diff changeset
   185
    # 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
   186
    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
   187
        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
   188
    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
   189
    if USE_SETUPTOOLS:
5331
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   190
        kwargs['install_requires'] = install_requires
f7ee75da6102 [skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5184
diff changeset
   191
        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
   192
        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
   193
        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
   194
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   195
    return setup(name=distname,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   196
                 version=version,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   197
                 license=license,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   198
                 description=description,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   199
                 long_description=long_description,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   200
                 author=author,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   201
                 author_email=author_email,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   202
                 url=web,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   203
                 scripts=ensure_scripts(scripts),
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   204
                 data_files=data_files,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   205
                 ext_modules=ext_modules,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   206
                 cmdclass=cmdclass,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   207
                 classifiers=classifiers,
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   208
                 **kwargs
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   209
                 )
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 232
diff changeset
   210
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   211
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   212
if __name__ == '__main__':
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   213
    install()