author | Julien Cristau <julien.cristau@logilab.fr> |
Mon, 19 Oct 2015 14:29:06 +0200 | |
changeset 10804 | ee113e1e03de |
parent 10662 | 10942ed172de |
child 10948 | 3ffacbdf7e9c |
permissions | -rw-r--r-- |
0 | 1 |
#!/usr/bin/env python |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
2 |
# pylint: disable=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611 |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
3 |
# |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
4 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
5 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
6 |
# |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
7 |
# This file is part of CubicWeb tag cube. |
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 |
10214
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
28 |
from os.path import exists, join, walk |
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 | 41 |
|
42 |
# import required features |
|
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
43 |
from __pkginfo__ import modname, version, license, description, web, \ |
10214
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
44 |
author, author_email, classifiers |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
45 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
46 |
if exists('README'): |
10614
57dfde80df11
[py3k] file → open
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10471
diff
changeset
|
47 |
long_description = open('README').read() |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5024
diff
changeset
|
48 |
else: |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
49 |
long_description = '' |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
50 |
|
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
51 |
# import optional features |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
52 |
import __pkginfo__ |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
53 |
if USE_SETUPTOOLS: |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
54 |
requires = {} |
10214
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
55 |
for entry in ("__depends__",): # "__recommends__"): |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
56 |
requires.update(getattr(__pkginfo__, entry, {})) |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
57 |
install_requires = [("%s %s" % (d, v and v or "")).strip() |
10662
10942ed172de
[py3k] dict.iteritems → dict.items
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10614
diff
changeset
|
58 |
for d, v in requires.items()] |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
59 |
else: |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
60 |
install_requires = [] |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
61 |
|
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
62 |
distname = getattr(__pkginfo__, 'distname', modname) |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
63 |
scripts = getattr(__pkginfo__, 'scripts', ()) |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
64 |
include_dirs = getattr(__pkginfo__, 'include_dirs', ()) |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
65 |
data_files = getattr(__pkginfo__, 'data_files', None) |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
66 |
ext_modules = getattr(__pkginfo__, 'ext_modules', None) |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
67 |
dependency_links = getattr(__pkginfo__, 'dependency_links', ()) |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
68 |
|
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
69 |
BASE_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build') |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
70 |
IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~') |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
71 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
72 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
73 |
def ensure_scripts(linux_scripts): |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
74 |
""" |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
75 |
Creates the proper script names required for each platform |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
76 |
(taken from 4Suite) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
77 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
78 |
from distutils import util |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
79 |
if util.get_platform()[:3] == 'win': |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
80 |
scripts_ = [script + '.bat' for script in linux_scripts] |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
81 |
else: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
82 |
scripts_ = linux_scripts |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
83 |
return scripts_ |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
84 |
|
10214
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
85 |
|
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
86 |
def export(from_dir, to_dir, |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
87 |
blacklist=BASE_BLACKLIST, |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
88 |
ignore_ext=IGNORED_EXTENSIONS, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
89 |
verbose=True): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
90 |
"""make a mirror of from_dir in to_dir, omitting directories and files |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
91 |
listed in the black list |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
92 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
93 |
def make_mirror(arg, directory, fnames): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
94 |
"""walk handler""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
95 |
for norecurs in blacklist: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
96 |
try: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
97 |
fnames.remove(norecurs) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
98 |
except ValueError: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
99 |
pass |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
100 |
for filename in fnames: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
101 |
# don't include binary files |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
102 |
if filename[-4:] in ignore_ext: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
103 |
continue |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
104 |
if filename[-1] == '~': |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
105 |
continue |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
106 |
src = join(directory, filename) |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
107 |
dest = to_dir + src[len(from_dir):] |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
108 |
if verbose: |
7896
4c954e1e73ef
[lint] remove uses of "print >> sys.stderr" (closes #1908571)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6840
diff
changeset
|
109 |
sys.stderr.write('%s -> %s\n' % (src, dest)) |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
110 |
if os.path.isdir(src): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
111 |
if not exists(dest): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
112 |
os.mkdir(dest) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
113 |
else: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
114 |
if exists(dest): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
115 |
os.remove(dest) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
116 |
shutil.copy2(src, dest) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
117 |
try: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
118 |
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
|
119 |
except OSError as ex: |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
120 |
# file exists ? |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
121 |
import errno |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
122 |
if ex.errno != errno.EEXIST: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
123 |
raise |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
124 |
walk(from_dir, make_mirror, None) |
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 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
127 |
class MyInstallLib(install_lib.install_lib): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
128 |
"""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
|
129 |
include_dirs variable if necessary |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
130 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
131 |
def run(self): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
132 |
"""overridden from install_lib class""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
133 |
install_lib.install_lib.run(self) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
134 |
# manually install included directories if any |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
135 |
if include_dirs: |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
136 |
base = modname |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
137 |
for directory in include_dirs: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
138 |
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
|
139 |
export(directory, dest, verbose=False) |
0 | 140 |
|
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
141 |
# 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
|
142 |
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
|
143 |
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
|
144 |
# 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
|
145 |
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
|
146 |
"""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
|
147 |
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
|
148 |
_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
|
149 |
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
|
150 |
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
|
151 |
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
|
152 |
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
|
153 |
try: |
10214
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
154 |
# only if easy_install available |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
155 |
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
|
156 |
# 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
|
157 |
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
|
158 |
old_ok = DS._ok |
10214
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
159 |
|
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
160 |
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
|
161 |
"""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
|
162 |
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
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
out = True |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
167 |
return out |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
168 |
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
|
169 |
except ImportError: |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
170 |
pass |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
171 |
|
10214
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
172 |
|
0 | 173 |
def install(**kwargs): |
174 |
"""setup entry point""" |
|
5360
96893296772f
[skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5334
diff
changeset
|
175 |
if USE_SETUPTOOLS: |
96893296772f
[skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5334
diff
changeset
|
176 |
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
|
177 |
sys.argv.remove('--force-manifest') |
5360
96893296772f
[skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5334
diff
changeset
|
178 |
# 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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
if USE_SETUPTOOLS: |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
183 |
kwargs['install_requires'] = install_requires |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
184 |
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
|
185 |
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
|
186 |
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
|
187 |
|
10214
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
188 |
return setup(name=distname, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
189 |
version=version, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
190 |
license=license, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
191 |
description=description, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
192 |
long_description=long_description, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
193 |
author=author, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
194 |
author_email=author_email, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
195 |
url=web, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
196 |
scripts=ensure_scripts(scripts), |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
197 |
data_files=data_files, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
198 |
ext_modules=ext_modules, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
199 |
cmdclass=cmdclass, |
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
200 |
classifiers=classifiers, |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
201 |
**kwargs |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
202 |
) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
232
diff
changeset
|
203 |
|
10214
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
204 |
|
88f60d4b9952
[newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents:
9516
diff
changeset
|
205 |
if __name__ == '__main__': |
0 | 206 |
install() |