setup.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Fri, 24 Mar 2017 17:21:37 +0100
branch3.25
changeset 12105 566075b02ce5
parent 12073 339b26bf17d2
child 12193 e4ee04d442be
permissions -rw-r--r--
Refer to cubicweb.readthedocs.io in README docs.cubicweb.org contains outdated documentation at the moment (and for quite some time); until it gets update, refer to the up-to-date documentation on readthedocs.
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
6491
ee9a10b6620e pylint option update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6327
diff changeset
     2
# pylint: disable=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     3
#
7879
9aae456abab5 [pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6836
diff changeset
     4
# copyright 2003-2011 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: 4721
diff changeset
     5
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
     6
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
     7
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
     8
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
     9
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
    10
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
    11
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
    12
# any later version.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    13
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    14
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    15
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
    16
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
    17
# details.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    18
#
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
    19
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
    20
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
    21
"""Generic Setup script, takes package info from __pkginfo__.py file
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4721
diff changeset
    22
"""
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
11276
6eeb7abda47a [pkg] Use io.open with utf-8 encoding to read long description from README
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    24
import io
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
import os
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    26
import sys
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
import shutil
11057
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    28
from os.path import dirname, exists, isdir, join
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
11424
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
    30
from setuptools import setup
11737
47e516587460 [pkg] Warn about "develop" command not installing legacy cubes directory
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11685
diff changeset
    31
from setuptools.command import develop, install_lib
6508
38c2ff52cfca [pkg] fix install_data import not present in setuptools
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 6506
diff changeset
    32
from distutils.command import install_data
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4721
diff changeset
    33
11057
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    34
here = dirname(__file__)
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    35
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
# import required features
11057
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    37
pkginfo = join(here, 'cubicweb', '__pkginfo__.py')
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    38
__pkginfo__ = {}
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    39
with open(pkginfo) as f:
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    40
    exec(f.read(), __pkginfo__)
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    41
modname = __pkginfo__['modname']
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    42
version = __pkginfo__['version']
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    43
license = __pkginfo__['license']
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    44
description = __pkginfo__['description']
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    45
web = __pkginfo__['web']
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    46
author = __pkginfo__['author']
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
    47
author_email = __pkginfo__['author_email']
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4721
diff changeset
    48
11276
6eeb7abda47a [pkg] Use io.open with utf-8 encoding to read long description from README
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    49
with io.open('README', encoding='utf-8') as f:
6eeb7abda47a [pkg] Use io.open with utf-8 encoding to read long description from README
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    50
    long_description = f.read()
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4721
diff changeset
    51
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    52
# import optional features
11449
ea5299828d68 [pkg] Make it clearer which entries of __pkginfo__ are actually used
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11426
diff changeset
    53
distname = __pkginfo__['distname']
ea5299828d68 [pkg] Make it clearer which entries of __pkginfo__ are actually used
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11426
diff changeset
    54
scripts = __pkginfo__['scripts']
ea5299828d68 [pkg] Make it clearer which entries of __pkginfo__ are actually used
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11426
diff changeset
    55
include_dirs = __pkginfo__['include_dirs']
ea5299828d68 [pkg] Make it clearer which entries of __pkginfo__ are actually used
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11426
diff changeset
    56
data_files = __pkginfo__['data_files']
ea5299828d68 [pkg] Make it clearer which entries of __pkginfo__ are actually used
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11426
diff changeset
    57
package_data = __pkginfo__['package_data']
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    58
9276
ae3fd6f8da76 [packaging] setup.py: don't exclude skeleton/debian/* from being installed
Julien Cristau <julien.cristau@logilab.fr>
parents: 8695
diff changeset
    59
BASE_BLACKLIST = ('CVS', 'dist', 'build', '__buildlog')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    60
IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc')
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    61
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    62
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    63
def ensure_scripts(linux_scripts):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
    Creates the proper script names required for each platform
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    66
    (taken from 4Suite)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    67
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
    from distutils import util
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    69
    if util.get_platform()[:3] == 'win':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
        scripts_ = [script + '.bat' for script in linux_scripts]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    71
    else:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
        scripts_ = linux_scripts
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    73
    return scripts_
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    74
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    75
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    76
def get_packages(directory, prefix):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    77
    """return a list of subpackages for the given directory
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    78
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    79
    result = []
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    80
    for package in os.listdir(directory):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    81
        absfile = join(directory, package)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    82
        if isdir(absfile):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    83
            if exists(join(absfile, '__init__.py')) or \
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    84
                   package in ('test', 'tests'):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    85
                if prefix:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    86
                    result.append('%s.%s' % (prefix, package))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    87
                else:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    88
                    result.append(package)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    89
                result += get_packages(absfile, result[-1])
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    90
    return result
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    91
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    92
def export(from_dir, to_dir,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    93
           blacklist=BASE_BLACKLIST,
5024
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4721
diff changeset
    94
           ignore_ext=IGNORED_EXTENSIONS,
9e718abe3fde add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 4721
diff changeset
    95
           verbose=True):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
    try:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    97
        os.mkdir(to_dir)
8695
358d8bed9626 [toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 7896
diff changeset
    98
    except OSError as ex:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    99
        # file exists ?
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   100
        import errno
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   101
        if ex.errno != errno.EEXIST:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
            raise
11421
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   103
    else:
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   104
        if verbose:
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   105
            print('created %s directory' % to_dir)
11057
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   106
    for dirpath, dirnames, filenames in os.walk(from_dir):
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   107
        for norecurs in blacklist:
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   108
            try:
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   109
                dirnames.remove(norecurs)
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   110
            except ValueError:
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   111
                pass
11421
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   112
            else:
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   113
                if verbose:
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   114
                    print('not recursing in %s' % join(dirpath, norecurs))
11057
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   115
        for dirname in dirnames:
11422
63ac20ef558e [pkg] Properly export data files in setup.py and adjust "newcube" test
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11421
diff changeset
   116
            src = join(dirpath, dirname)
63ac20ef558e [pkg] Properly export data files in setup.py and adjust "newcube" test
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11421
diff changeset
   117
            dest = to_dir + src[len(from_dir):]
11057
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   118
            if not exists(dest):
11421
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   119
                if verbose:
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   120
                    print('creating %s directory' % dest)
11057
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   121
                os.mkdir(dest)
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   122
        for filename in filenames:
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   123
            # don't include binary files
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   124
            src = join(dirpath, filename)
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   125
            dest = to_dir + src[len(from_dir):]
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   126
            if filename[-4:] in ignore_ext:
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   127
                continue
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   128
            if filename[-1] == '~':
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   129
                continue
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   130
            if exists(dest):
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   131
                os.remove(dest)
11421
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   132
            if verbose:
06bcb7e7a69c [pkg] Handle verbose option in setup.py's export function
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11420
diff changeset
   133
                print('copying %s to %s' % (src, dest))
11057
0b59724cb3f2 Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10662
diff changeset
   134
            shutil.copy2(src, dest)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   135
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   136
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   137
class MyInstallLib(install_lib.install_lib):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   138
    """extend install_lib command to handle  package __init__.py and
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   139
    include_dirs variable if necessary
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   140
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   141
    def run(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   142
        """overridden from install_lib class"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   143
        install_lib.install_lib.run(self)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   144
        # create Products.__init__.py if needed
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   145
        # manually install included directories if any
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   146
        if include_dirs:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   147
            for directory in include_dirs:
11422
63ac20ef558e [pkg] Properly export data files in setup.py and adjust "newcube" test
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11421
diff changeset
   148
                src = join(modname, directory)
63ac20ef558e [pkg] Properly export data files in setup.py and adjust "newcube" test
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11421
diff changeset
   149
                dest = join(self.install_dir, src)
63ac20ef558e [pkg] Properly export data files in setup.py and adjust "newcube" test
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11421
diff changeset
   150
                export(src, dest, verbose=self.verbose)
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
   151
11737
47e516587460 [pkg] Warn about "develop" command not installing legacy cubes directory
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11685
diff changeset
   152
6517
c991ad161d8f [pkg] force copying data files in sys.path
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 6516
diff changeset
   153
# re-enable copying data files in sys.prefix
11920
f13799fbcfea [cwconfig] create a virtual "cubes" package
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents: 11884
diff changeset
   154
# overwrite install_data to use sys.prefix instead of the egg directory
f13799fbcfea [cwconfig] create a virtual "cubes" package
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents: 11884
diff changeset
   155
class MyInstallData(install_data.install_data):
11424
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   156
    """A class that manages data files installation"""
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   157
    def run(self):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   158
        _old_install_dir = self.install_dir
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   159
        if self.install_dir.endswith('egg'):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   160
            self.install_dir = sys.prefix
11920
f13799fbcfea [cwconfig] create a virtual "cubes" package
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents: 11884
diff changeset
   161
        install_data.install_data.run(self)
11424
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   162
        self.install_dir = _old_install_dir
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   163
try:
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   164
    import setuptools.command.easy_install # only if easy_install available
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   165
    # monkey patch: Crack SandboxViolation verification
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   166
    from setuptools.sandbox import DirectorySandbox as DS
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   167
    old_ok = DS._ok
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   168
    def _ok(self, path):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   169
        """Return True if ``path`` can be written during installation."""
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   170
        out = old_ok(self, path) # here for side effect from setuptools
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   171
        realpath = os.path.normcase(os.path.realpath(path))
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   172
        allowed_path = os.path.normcase(sys.prefix)
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   173
        if realpath.startswith(allowed_path):
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   174
            out = True
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   175
        return out
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   176
    DS._ok = _ok
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   177
except ImportError:
1451f040555f [pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11282
diff changeset
   178
    pass
6506
c1661ea815dc [packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 6327
diff changeset
   179
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
   180
11467
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   181
setup(
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   182
    name=distname,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   183
    version=version,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   184
    license=license,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   185
    url=web,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   186
    description=description,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   187
    long_description=long_description,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   188
    author=author,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   189
    author_email=author_email,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   190
    packages=[modname] + get_packages(join(here, modname), modname),
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   191
    package_data=package_data,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   192
    scripts=ensure_scripts(scripts),
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   193
    data_files=data_files,
11685
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   194
    install_requires=[
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   195
        'six >= 1.4.0',
12069
82f7d583e5a3 [pkg] Depends on logilab-common >= 1.4.0
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11987
diff changeset
   196
        'logilab-common >= 1.4.0',
11685
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   197
        'logilab-mtconverter >= 0.8.0',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   198
        'rql >= 0.34.0',
12070
a44f67dd0474 [pkg] Depends on yams >= 0.45.0
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12069
diff changeset
   199
        'yams >= 0.45.0',
11685
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   200
        'lxml',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   201
        'logilab-database >= 1.15.0',
11884
6186cd15a46d [pkg] Require passlib >= 1.7.0
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11805
diff changeset
   202
        'passlib >= 1.7.0',
11685
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   203
        'pytz',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   204
        'Markdown',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   205
        'unittest2 >= 0.7.0',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   206
    ],
11968
bb0dfc7d2d0e [skeleton,pyramid] Move pyramid app definition in cubicweb.pyramid module
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11929
diff changeset
   207
    entry_points={
bb0dfc7d2d0e [skeleton,pyramid] Move pyramid app definition in cubicweb.pyramid module
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11929
diff changeset
   208
        'paste.app_factory': [
12073
339b26bf17d2 [pyramid] Rename paste app factory to pyramid_main
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12070
diff changeset
   209
            'pyramid_main=cubicweb.pyramid:pyramid_app',
11968
bb0dfc7d2d0e [skeleton,pyramid] Move pyramid app definition in cubicweb.pyramid module
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11929
diff changeset
   210
        ],
bb0dfc7d2d0e [skeleton,pyramid] Move pyramid app definition in cubicweb.pyramid module
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11929
diff changeset
   211
    },
11805
7436b65a44bc [pkg] Fix extra packages not installable
Florent Cayré <florent.cayre@gmail.com>
parents: 11752
diff changeset
   212
    extras_require={
11685
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   213
        'captcha': [
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   214
            'Pillow',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   215
        ],
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   216
        'crypto': [
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   217
            'pycrypto',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   218
        ],
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   219
        'etwist': [
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   220
            'Twisted < 16.0.0',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   221
        ],
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   222
        'ext': [
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   223
            'docutils >= 0.6',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   224
        ],
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   225
        'ical': [
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   226
            'vobject >= 0.6.0',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   227
        ],
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   228
        'pyramid': [
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   229
            'pyramid >= 1.5.0',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   230
            'waitress >= 0.8.9',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   231
            'wsgicors >= 0.3',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   232
            'pyramid_multiauth',
11987
d432911e3c26 [pyramid] Drop module-level cache and cleanup looping tasks in tools
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11968
diff changeset
   233
            'repoze.lru',
11685
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   234
        ],
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   235
        'rdf': [
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   236
            'rdflib',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   237
        ],
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   238
        'sparql': [
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   239
            'fyzz >= 0.1.0',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   240
        ],
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   241
        'zmq': [
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   242
            'pyzmq',
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   243
        ],
6c263b8091d3 [pkg] Declare extras (optional) dependencies
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11467
diff changeset
   244
    },
11737
47e516587460 [pkg] Warn about "develop" command not installing legacy cubes directory
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11685
diff changeset
   245
    cmdclass={
47e516587460 [pkg] Warn about "develop" command not installing legacy cubes directory
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11685
diff changeset
   246
        'install_lib': MyInstallLib,
47e516587460 [pkg] Warn about "develop" command not installing legacy cubes directory
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11685
diff changeset
   247
        'install_data': MyInstallData,
47e516587460 [pkg] Warn about "develop" command not installing legacy cubes directory
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11685
diff changeset
   248
    },
11467
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   249
    zip_safe=False,
629d9e35ce28 [pkg] Inline call to setup() in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11466
diff changeset
   250
)