author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 13 Apr 2010 19:43:51 +0200 | |
changeset 5238 | 31c12863fd9d |
parent 5184 | 955ee1b24756 |
child 5331 | f7ee75da6102 |
permissions | -rw-r--r-- |
0 | 1 |
#!/usr/bin/env python |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
2 |
"""Generic Setup script, takes package info from __pkginfo__.py file |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
3 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
4 |
:organization: Logilab |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
5 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
8 |
""" |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
9 |
# pylint: disable-msg=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611 |
0 | 10 |
# |
11 |
# This program is free software; you can redistribute it and/or modify it under |
|
12 |
# the terms of the GNU General Public License as published by the Free Software |
|
13 |
# Foundation; either version 2 of the License, or (at your option) any later |
|
14 |
# version. |
|
15 |
# |
|
16 |
# This program is distributed in the hope that it will be useful, but WITHOUT |
|
17 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
18 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|
19 |
# |
|
20 |
# You should have received a copy of the GNU General Public License along with |
|
21 |
# this program; if not, write to the Free Software Foundation, Inc., |
|
22 |
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
23 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
24 |
import os |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
25 |
import sys |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
26 |
import shutil |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
27 |
from os.path import isdir, exists, join, walk |
0 | 28 |
|
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
29 |
try: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
30 |
if os.environ.get('NO_SETUPTOOLS'): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
31 |
raise ImportError() # do as there is no setuptools |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
32 |
from setuptools import setup |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
33 |
from setuptools.command import install_lib |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
34 |
USE_SETUPTOOLS = True |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
35 |
except ImportError: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
36 |
from distutils.core import setup |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
37 |
from distutils.command import install_lib |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
38 |
USE_SETUPTOOLS = False |
0 | 39 |
|
40 |
# import required features |
|
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
41 |
from __pkginfo__ import modname, version, license, description, web, \ |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
42 |
author, author_email |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
43 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
44 |
if exists('README'): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
45 |
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
|
46 |
else: |
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5024
diff
changeset
|
47 |
long_description = '' |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
48 |
|
232
f1f26070117d
cleanup skel packaging
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
139
diff
changeset
|
49 |
# import optional features |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
50 |
import __pkginfo__ |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
51 |
if USE_SETUPTOOLS: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
52 |
requires = {} |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
53 |
for entry in ("__depends__", "__recommends__"): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
54 |
requires.update(getattr(__pkginfo__, entry, {})) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
55 |
install_requires = [("%s %s" % (d, v and v or "")).strip() |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
56 |
for d, v in requires.iteritems()] |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
57 |
else: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
58 |
install_requires = [] |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
59 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
60 |
distname = getattr(__pkginfo__, 'distname', modname) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
61 |
scripts = getattr(__pkginfo__, 'scripts', ()) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
62 |
include_dirs = getattr(__pkginfo__, 'include_dirs', ()) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
63 |
data_files = getattr(__pkginfo__, 'data_files', None) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
64 |
subpackage_of = getattr(__pkginfo__, 'subpackage_of', None) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
65 |
ext_modules = getattr(__pkginfo__, 'ext_modules', None) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
66 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
67 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
68 |
BASE_BLACKLIST = ('CVS', 'debian', 'dist', 'build', '__buildlog') |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
69 |
IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc') |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
70 |
|
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 |
def ensure_scripts(linux_scripts): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
73 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
74 |
Creates the proper script names required for each platform |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
75 |
(taken from 4Suite) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
76 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
77 |
from distutils import util |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
78 |
if util.get_platform()[:3] == 'win': |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
79 |
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
|
80 |
else: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
81 |
scripts_ = linux_scripts |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
82 |
return scripts_ |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
83 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
84 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
85 |
def get_packages(directory, prefix): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
86 |
"""return a list of subpackages for the given directory |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
87 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
88 |
result = [] |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
89 |
for package in os.listdir(directory): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
90 |
absfile = join(directory, package) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
91 |
if isdir(absfile): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
92 |
if exists(join(absfile, '__init__.py')) or \ |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
93 |
package in ('test', 'tests'): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
94 |
if prefix: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
95 |
result.append('%s.%s' % (prefix, package)) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
96 |
else: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
97 |
result.append(package) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
98 |
result += get_packages(absfile, result[-1]) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
99 |
return result |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
100 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
101 |
def export(from_dir, to_dir, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
102 |
blacklist=BASE_BLACKLIST, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
103 |
ignore_ext=IGNORED_EXTENSIONS, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
104 |
verbose=True): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
105 |
"""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
|
106 |
listed in the black list |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
107 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
108 |
def make_mirror(arg, directory, fnames): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
109 |
"""walk handler""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
110 |
for norecurs in blacklist: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
111 |
try: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
112 |
fnames.remove(norecurs) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
113 |
except ValueError: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
114 |
pass |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
115 |
for filename in fnames: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
116 |
# don't include binary files |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
117 |
if filename[-4:] in ignore_ext: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
118 |
continue |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
119 |
if filename[-1] == '~': |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
120 |
continue |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
121 |
src = '%s/%s' % (directory, filename) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
122 |
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
|
123 |
if verbose: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
124 |
print >> sys.stderr, src, '->', dest |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
125 |
if os.path.isdir(src): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
126 |
if not exists(dest): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
127 |
os.mkdir(dest) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
128 |
else: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
129 |
if exists(dest): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
130 |
os.remove(dest) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
131 |
shutil.copy2(src, dest) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
132 |
try: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
133 |
os.mkdir(to_dir) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
134 |
except OSError, ex: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
135 |
# file exists ? |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
136 |
import errno |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
137 |
if ex.errno != errno.EEXIST: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
138 |
raise |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
139 |
walk(from_dir, make_mirror, None) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
140 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
141 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
142 |
EMPTY_FILE = '"""generated file, don\'t modify or your data will be lost"""\n' |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
143 |
|
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
144 |
class MyInstallLib(install_lib.install_lib): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
145 |
"""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
|
146 |
include_dirs variable if necessary |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
147 |
""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
148 |
def run(self): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
149 |
"""overridden from install_lib class""" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
150 |
install_lib.install_lib.run(self) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
151 |
# create Products.__init__.py if needed |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
152 |
if subpackage_of: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
153 |
product_init = join(self.install_dir, subpackage_of, '__init__.py') |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
154 |
if not exists(product_init): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
155 |
self.announce('creating %s' % product_init) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
156 |
stream = open(product_init, 'w') |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
157 |
stream.write(EMPTY_FILE) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
158 |
stream.close() |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
159 |
# manually install included directories if any |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
160 |
if include_dirs: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
161 |
if subpackage_of: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
162 |
base = join(subpackage_of, modname) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
163 |
else: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
164 |
base = modname |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
165 |
for directory in include_dirs: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
166 |
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
|
167 |
export(directory, dest, verbose=False) |
0 | 168 |
|
169 |
def install(**kwargs): |
|
170 |
"""setup entry point""" |
|
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
171 |
if not USE_SETUPTOOLS and '--install-layout=deb' in sys.argv and \ |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
172 |
sys.versioninfo < (2, 5, 4): |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
173 |
sys.argv.remove('--install-layout=deb') |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
174 |
print "W: remove '--install-layout=deb' option" |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
175 |
if subpackage_of: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
176 |
package = subpackage_of + '.' + modname |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
177 |
kwargs['package_dir'] = {package : '.'} |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
178 |
packages = [package] + get_packages(os.getcwd(), package) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
179 |
if USE_SETUPTOOLS: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
180 |
kwargs['namespace_packages'] = [subpackage_of] |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
181 |
else: |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
182 |
kwargs['package_dir'] = {modname : '.'} |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
183 |
packages = [modname] + get_packages(os.getcwd(), modname) |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
184 |
kwargs['packages'] = packages |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
185 |
return setup(name=distname, version=version, license=license, url=web, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
186 |
description=description, long_description=long_description, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
187 |
author=author, author_email=author_email, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
188 |
scripts=ensure_scripts(scripts), data_files=data_files, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
189 |
ext_modules=ext_modules, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
190 |
install_requires=install_requires, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
191 |
#dependency_links=["http://alain:alain@intranet.logilab.fr/~alain/"], |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
192 |
cmdclass={'install_lib': MyInstallLib}, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
193 |
**kwargs |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4212
diff
changeset
|
194 |
) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
232
diff
changeset
|
195 |
|
0 | 196 |
if __name__ == '__main__' : |
197 |
install() |