cubicweb/skeleton/setup.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Wed, 29 Jun 2016 10:35:22 +0200
changeset 11424 1451f040555f
parent 11152 fccc6ddd975c
permissions -rw-r--r--
[pkg] Drop NO_SETUPTOOLS option setuptools is the defacto standard nowadays. The only place where NO_SETUPTOOLS option was used is during packaging (RPM, Debian) and even in this context, it seems that setuptools is the way to go (see https://wiki.debian.org/Python/LibraryStyleGuide).
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
11424
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
    30
from setuptools import setup
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
    31
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
    32
from distutils.command import install_data
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    33
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
    34
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
    35
# 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
    36
# 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
    37
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
    38
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
    39
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
    40
    exec(f.read(), pkginfo)
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
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
# 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
    43
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
    44
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
    45
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
    46
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
    47
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
    48
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
    49
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
    50
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
    51
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
    52
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
    53
    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
    54
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
# 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
    56
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
    57
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
    58
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
    59
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
    60
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
    61
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
    62
11424
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
    63
requires = {}
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
    64
for entry in ("__depends__",):  # "__recommends__"):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
    65
    requires.update(pkginfo.get(entry, {}))
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
    66
install_requires = [("%s %s" % (d, v and v or "")).strip()
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
    67
                    for d, v in requires.items()]
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
    68
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
    69
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
    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
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
   103
        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
   104
            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
   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
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
   136
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   137
# 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
   138
old_install_data = install_data.install_data
11424
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   139
# overwrite InstallData to use sys.prefix instead of the egg directory
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   140
class MyInstallData(old_install_data):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   141
    """A class that manages data files installation"""
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   142
    def run(self):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   143
        _old_install_dir = self.install_dir
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   144
        if self.install_dir.endswith('egg'):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   145
            self.install_dir = sys.prefix
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   146
        old_install_data.run(self)
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   147
        self.install_dir = _old_install_dir
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   148
try:
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   149
    # only if easy_install available
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   150
    import setuptools.command.easy_install  # noqa
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   151
    # monkey patch: Crack SandboxViolation verification
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   152
    from setuptools.sandbox import DirectorySandbox as DS
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
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
11424
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   155
    def _ok(self, path):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   156
        """Return True if ``path`` can be written during installation."""
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   157
        out = old_ok(self, path)  # here for side effect from setuptools
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   158
        realpath = os.path.normcase(os.path.realpath(path))
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   159
        allowed_path = os.path.normcase(sys.prefix)
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   160
        if realpath.startswith(allowed_path):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   161
            out = True
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   162
        return out
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   163
    DS._ok = _ok
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   164
except ImportError:
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   165
    pass
6840
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"""
11424
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   170
    if '--force-manifest' in sys.argv:
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   171
        sys.argv.remove('--force-manifest')
5360
96893296772f [skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5334
diff changeset
   172
    # 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
   173
    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
   174
        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
   175
    cmdclass = {'install_lib': MyInstallLib}
11424
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   176
    kwargs['install_requires'] = install_requires
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   177
    kwargs['dependency_links'] = dependency_links
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   178
    kwargs['zip_safe'] = False
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11152
diff changeset
   179
    cmdclass['install_data'] = MyInstallData
6840
fe5162da6e70 [skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6326
diff changeset
   180
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   181
    return setup(name=distname,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   182
                 version=version,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   183
                 license=license,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   184
                 description=description,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   185
                 long_description=long_description,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   186
                 author=author,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   187
                 author_email=author_email,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   188
                 url=web,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   189
                 scripts=ensure_scripts(scripts),
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   190
                 data_files=data_files,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   191
                 ext_modules=ext_modules,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   192
                 cmdclass=cmdclass,
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   193
                 classifiers=classifiers,
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   194
                 **kwargs
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4212
diff changeset
   195
                 )
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 232
diff changeset
   196
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   197
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 9516
diff changeset
   198
if __name__ == '__main__':
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   199
    install()