author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 23 Sep 2011 09:10:58 +0200 | |
branch | stable |
changeset 7840 | d6733436b0dd |
parent 6840 | fe5162da6e70 |
child 7896 | 4c954e1e73ef |
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 |
# |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
19 |
# You should have received a copy of the GNU Lesser General Public License along |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
20 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
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 |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
28 |
from os.path import isdir, 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'): |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
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, \ |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
44 |
author, author_email |
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'): |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
47 |
long_description = file('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 = {} |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
55 |
for entry in ("__depends__",): # "__recommends__"): |
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() |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
58 |
for d, v in requires.iteritems()] |
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 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
85 |
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
|
86 |
blacklist=BASE_BLACKLIST, |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
87 |
ignore_ext=IGNORED_EXTENSIONS, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
88 |
verbose=True): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
89 |
"""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
|
90 |
listed in the black list |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
91 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
92 |
def make_mirror(arg, directory, fnames): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
93 |
"""walk handler""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
94 |
for norecurs in blacklist: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
95 |
try: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
96 |
fnames.remove(norecurs) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
97 |
except ValueError: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
98 |
pass |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
99 |
for filename in fnames: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
100 |
# don't include binary files |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
101 |
if filename[-4:] in ignore_ext: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
102 |
continue |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
103 |
if filename[-1] == '~': |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
104 |
continue |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
105 |
src = join(directory, filename) |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
106 |
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
|
107 |
if verbose: |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
108 |
print >> sys.stderr, src, '->', dest |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
109 |
if os.path.isdir(src): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
110 |
if not exists(dest): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
111 |
os.mkdir(dest) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
112 |
else: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
113 |
if exists(dest): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
114 |
os.remove(dest) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
115 |
shutil.copy2(src, dest) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
116 |
try: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
117 |
os.mkdir(to_dir) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
118 |
except OSError, ex: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
119 |
# file exists ? |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
120 |
import errno |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
121 |
if ex.errno != errno.EEXIST: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
122 |
raise |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
123 |
walk(from_dir, make_mirror, None) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
124 |
|
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 |
class MyInstallLib(install_lib.install_lib): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
127 |
"""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
|
128 |
include_dirs variable if necessary |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
129 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
130 |
def run(self): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
131 |
"""overridden from install_lib class""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
132 |
install_lib.install_lib.run(self) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
133 |
# manually install included directories if any |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
134 |
if include_dirs: |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
135 |
base = modname |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
136 |
for directory in include_dirs: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
137 |
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
|
138 |
export(directory, dest, verbose=False) |
0 | 139 |
|
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
140 |
# 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
|
141 |
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
|
142 |
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
|
143 |
# 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
|
144 |
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
|
145 |
"""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
|
146 |
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
|
147 |
_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
|
148 |
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
|
149 |
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
|
150 |
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
|
151 |
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
|
152 |
try: |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
153 |
import setuptools.command.easy_install # only if easy_install avaible |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
154 |
# 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
|
155 |
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
|
156 |
old_ok = DS._ok |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
157 |
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
|
158 |
"""Return True if ``path`` can be written during installation.""" |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
159 |
out = old_ok(self, path) # here for side effect from setuptools |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
160 |
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
|
161 |
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
|
162 |
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
|
163 |
out = True |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
164 |
return out |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
165 |
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
|
166 |
except ImportError: |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
167 |
pass |
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
168 |
|
0 | 169 |
def install(**kwargs): |
170 |
"""setup entry point""" |
|
5360
96893296772f
[skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5334
diff
changeset
|
171 |
if USE_SETUPTOOLS: |
96893296772f
[skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5334
diff
changeset
|
172 |
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
|
173 |
sys.argv.remove('--force-manifest') |
5360
96893296772f
[skel] fix setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5334
diff
changeset
|
174 |
# 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
|
175 |
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
|
176 |
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
|
177 |
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
|
178 |
if USE_SETUPTOOLS: |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
179 |
kwargs['install_requires'] = install_requires |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
|
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
184 |
return setup(name = distname, |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
185 |
version = version, |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
186 |
license = license, |
5382
cb5dfea92285
[skeleton] short_desc is now description in pkginfo
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5360
diff
changeset
|
187 |
description = description, |
5331
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
188 |
long_description = long_description, |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
189 |
author = author, |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
190 |
author_email = author_email, |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
191 |
url = web, |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
192 |
scripts = ensure_scripts(scripts), |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
193 |
data_files = data_files, |
f7ee75da6102
[skel] cleanup default cube setup.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5184
diff
changeset
|
194 |
ext_modules = ext_modules, |
6840
fe5162da6e70
[skel] setup.py patched to get easy_install to work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6326
diff
changeset
|
195 |
cmdclass = cmdclass, |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
196 |
**kwargs |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
197 |
) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
232
diff
changeset
|
198 |
|
0 | 199 |
if __name__ == '__main__' : |
200 |
install() |