author | Denis Laxalde <denis.laxalde@logilab.fr> |
Wed, 29 Jun 2016 10:35:22 +0200 | |
changeset 11424 | 1451f040555f |
parent 11282 | 386fff3fa2ff |
child 11426 | f666f484e5f4 |
permissions | -rw-r--r-- |
0 | 1 |
#!/usr/bin/env python |
6491
ee9a10b6620e
pylint option update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6327
diff
changeset
|
2 |
# pylint: disable=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611 |
0 | 3 |
# |
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6836
diff
changeset
|
4 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
5 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
7 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
8 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
9 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
10 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
11 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
12 |
# any later version. |
0 | 13 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
14 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
0 | 15 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
16 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
17 |
# details. |
0 | 18 |
# |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
19 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
20 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
21 |
"""Generic Setup script, takes package info from __pkginfo__.py file |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
22 |
""" |
0 | 23 |
|
11276
6eeb7abda47a
[pkg] Use io.open with utf-8 encoding to read long description from README
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11057
diff
changeset
|
24 |
import io |
0 | 25 |
import os |
26 |
import sys |
|
27 |
import shutil |
|
11057
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
28 |
from os.path import dirname, exists, isdir, join |
0 | 29 |
|
11424
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
30 |
from setuptools import setup |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
31 |
from setuptools.command import install_lib |
6508
38c2ff52cfca
[pkg] fix install_data import not present in setuptools
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6506
diff
changeset
|
32 |
from distutils.command import install_data |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
33 |
|
11057
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
34 |
here = dirname(__file__) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
35 |
|
0 | 36 |
# import required features |
11057
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
37 |
pkginfo = join(here, 'cubicweb', '__pkginfo__.py') |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
38 |
__pkginfo__ = {} |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
39 |
with open(pkginfo) as f: |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
40 |
exec(f.read(), __pkginfo__) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
41 |
modname = __pkginfo__['modname'] |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
42 |
version = __pkginfo__['version'] |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
43 |
license = __pkginfo__['license'] |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
44 |
description = __pkginfo__['description'] |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
45 |
web = __pkginfo__['web'] |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
46 |
author = __pkginfo__['author'] |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
47 |
author_email = __pkginfo__['author_email'] |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
48 |
|
11276
6eeb7abda47a
[pkg] Use io.open with utf-8 encoding to read long description from README
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11057
diff
changeset
|
49 |
with io.open('README', encoding='utf-8') as f: |
6eeb7abda47a
[pkg] Use io.open with utf-8 encoding to read long description from README
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11057
diff
changeset
|
50 |
long_description = f.read() |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
51 |
|
0 | 52 |
# import optional features |
11424
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
53 |
requires = {} |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
54 |
for entry in ("__depends__",): # "__recommends__"): |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
55 |
requires.update(__pkginfo__.get(entry, {})) |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
56 |
install_requires = [("%s %s" % (d, v and v or "")).strip() |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
57 |
for d, v in requires.items()] |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
58 |
|
11057
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
59 |
distname = __pkginfo__.get('distname', modname) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
60 |
scripts = __pkginfo__.get('scripts', ()) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
61 |
include_dirs = __pkginfo__.get('include_dirs', ()) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
62 |
data_files = __pkginfo__.get('data_files', None) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
63 |
ext_modules = __pkginfo__.get('ext_modules', None) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
64 |
package_data = __pkginfo__.get('package_data', {}) |
0 | 65 |
|
9276
ae3fd6f8da76
[packaging] setup.py: don't exclude skeleton/debian/* from being installed
Julien Cristau <julien.cristau@logilab.fr>
parents:
8695
diff
changeset
|
66 |
BASE_BLACKLIST = ('CVS', 'dist', 'build', '__buildlog') |
0 | 67 |
IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
68 |
|
0 | 69 |
|
70 |
def ensure_scripts(linux_scripts): |
|
71 |
""" |
|
72 |
Creates the proper script names required for each platform |
|
73 |
(taken from 4Suite) |
|
74 |
""" |
|
75 |
from distutils import util |
|
76 |
if util.get_platform()[:3] == 'win': |
|
77 |
scripts_ = [script + '.bat' for script in linux_scripts] |
|
78 |
else: |
|
79 |
scripts_ = linux_scripts |
|
80 |
return scripts_ |
|
81 |
||
82 |
||
83 |
def get_packages(directory, prefix): |
|
84 |
"""return a list of subpackages for the given directory |
|
85 |
""" |
|
86 |
result = [] |
|
87 |
for package in os.listdir(directory): |
|
88 |
absfile = join(directory, package) |
|
89 |
if isdir(absfile): |
|
90 |
if exists(join(absfile, '__init__.py')) or \ |
|
91 |
package in ('test', 'tests'): |
|
92 |
if prefix: |
|
93 |
result.append('%s.%s' % (prefix, package)) |
|
94 |
else: |
|
95 |
result.append(package) |
|
96 |
result += get_packages(absfile, result[-1]) |
|
97 |
return result |
|
98 |
||
99 |
def export(from_dir, to_dir, |
|
100 |
blacklist=BASE_BLACKLIST, |
|
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
101 |
ignore_ext=IGNORED_EXTENSIONS, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
102 |
verbose=True): |
0 | 103 |
try: |
104 |
os.mkdir(to_dir) |
|
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7896
diff
changeset
|
105 |
except OSError as ex: |
0 | 106 |
# file exists ? |
107 |
import errno |
|
108 |
if ex.errno != errno.EEXIST: |
|
109 |
raise |
|
11057
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
110 |
for dirpath, dirnames, filenames in os.walk(from_dir): |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
111 |
for norecurs in blacklist: |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
112 |
try: |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
113 |
dirnames.remove(norecurs) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
114 |
except ValueError: |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
115 |
pass |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
116 |
for dirname in dirnames: |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
117 |
dest = join(to_dir, dirname) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
118 |
if not exists(dest): |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
119 |
os.mkdir(dest) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
120 |
for filename in filenames: |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
121 |
# don't include binary files |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
122 |
src = join(dirpath, filename) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
123 |
dest = to_dir + src[len(from_dir):] |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
124 |
if filename[-4:] in ignore_ext: |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
125 |
continue |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
126 |
if filename[-1] == '~': |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
127 |
continue |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
128 |
if exists(dest): |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
129 |
os.remove(dest) |
0b59724cb3f2
Reorganize source tree to have a "cubicweb" top-level package
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10662
diff
changeset
|
130 |
shutil.copy2(src, dest) |
0 | 131 |
|
132 |
||
133 |
EMPTY_FILE = '"""generated file, don\'t modify or your data will be lost"""\n' |
|
134 |
||
135 |
class MyInstallLib(install_lib.install_lib): |
|
136 |
"""extend install_lib command to handle package __init__.py and |
|
137 |
include_dirs variable if necessary |
|
138 |
""" |
|
139 |
def run(self): |
|
140 |
"""overridden from install_lib class""" |
|
141 |
install_lib.install_lib.run(self) |
|
142 |
# create Products.__init__.py if needed |
|
143 |
# manually install included directories if any |
|
144 |
if include_dirs: |
|
145 |
for directory in include_dirs: |
|
11282
386fff3fa2ff
[pkg] Drop "support" of unused subpackage_of option in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11276
diff
changeset
|
146 |
dest = join(self.install_dir, modname, directory) |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
147 |
export(directory, dest, verbose=False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
148 |
|
6517
c991ad161d8f
[pkg] force copying data files in sys.path
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
6516
diff
changeset
|
149 |
# write required share/cubicweb/cubes/__init__.py |
6506
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
150 |
class MyInstallData(install_data.install_data): |
6517
c991ad161d8f
[pkg] force copying data files in sys.path
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
6516
diff
changeset
|
151 |
"""A class That manages data files installation""" |
6506
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
152 |
def run(self): |
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
153 |
"""overridden from install_data class""" |
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
154 |
install_data.install_data.run(self) |
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
155 |
path = join(self.install_dir, 'share', 'cubicweb', 'cubes', '__init__.py') |
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
156 |
ini = open(path, 'w') |
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
157 |
ini.write('# Cubicweb cubes directory\n') |
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
158 |
ini.close() |
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
159 |
|
6517
c991ad161d8f
[pkg] force copying data files in sys.path
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
6516
diff
changeset
|
160 |
# re-enable copying data files in sys.prefix |
11424
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
161 |
# overwrite MyInstallData to use sys.prefix instead of the egg directory |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
162 |
MyInstallMoreData = MyInstallData |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
163 |
class MyInstallData(MyInstallMoreData): # pylint: disable=E0102 |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
164 |
"""A class that manages data files installation""" |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
165 |
def run(self): |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
166 |
_old_install_dir = self.install_dir |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
167 |
if self.install_dir.endswith('egg'): |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
168 |
self.install_dir = sys.prefix |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
169 |
MyInstallMoreData.run(self) |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
170 |
self.install_dir = _old_install_dir |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
171 |
try: |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
172 |
import setuptools.command.easy_install # only if easy_install available |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
173 |
# monkey patch: Crack SandboxViolation verification |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
174 |
from setuptools.sandbox import DirectorySandbox as DS |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
175 |
old_ok = DS._ok |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
176 |
def _ok(self, path): |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
177 |
"""Return True if ``path`` can be written during installation.""" |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
178 |
out = old_ok(self, path) # here for side effect from setuptools |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
179 |
realpath = os.path.normcase(os.path.realpath(path)) |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
180 |
allowed_path = os.path.normcase(sys.prefix) |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
181 |
if realpath.startswith(allowed_path): |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
182 |
out = True |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
183 |
return out |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
184 |
DS._ok = _ok |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
185 |
except ImportError: |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
186 |
pass |
6506
c1661ea815dc
[packaging] add a __init__.py to cubes directory when installing data
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6327
diff
changeset
|
187 |
|
0 | 188 |
def install(**kwargs): |
189 |
"""setup entry point""" |
|
11424
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
190 |
if '--force-manifest' in sys.argv: |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
191 |
sys.argv.remove('--force-manifest') |
5353
cb8ac7263f8a
[packaging] fix setup.py for use w/ lgp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5329
diff
changeset
|
192 |
# install-layout option was introduced in 2.5.3-1~exp1 |
cb8ac7263f8a
[packaging] fix setup.py for use w/ lgp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5329
diff
changeset
|
193 |
elif sys.version_info < (2, 5, 4) and '--install-layout=deb' in sys.argv: |
cb8ac7263f8a
[packaging] fix setup.py for use w/ lgp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5329
diff
changeset
|
194 |
sys.argv.remove('--install-layout=deb') |
11282
386fff3fa2ff
[pkg] Drop "support" of unused subpackage_of option in setup.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11276
diff
changeset
|
195 |
packages = [modname] + get_packages(join(here, modname), modname) |
11424
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
196 |
kwargs['install_requires'] = install_requires |
1451f040555f
[pkg] Drop NO_SETUPTOOLS option
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11282
diff
changeset
|
197 |
kwargs['zip_safe'] = False |
0 | 198 |
kwargs['packages'] = packages |
6516
6b2e1e8d3a22
[pkg] use argument *package_data*
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
6508
diff
changeset
|
199 |
kwargs['package_data'] = package_data |
5024
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
200 |
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:
4721
diff
changeset
|
201 |
description=description, long_description=long_description, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
202 |
author=author, author_email=author_email, |
9e718abe3fde
add egg support with dependencies auto-installation
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4721
diff
changeset
|
203 |
scripts=ensure_scripts(scripts), data_files=data_files, |
0 | 204 |
ext_modules=ext_modules, |
6517
c991ad161d8f
[pkg] force copying data files in sys.path
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
6516
diff
changeset
|
205 |
cmdclass={'install_lib': MyInstallLib, |
c991ad161d8f
[pkg] force copying data files in sys.path
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
6516
diff
changeset
|
206 |
'install_data': MyInstallData}, |
0 | 207 |
**kwargs |
208 |
) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
209 |
|
0 | 210 |
if __name__ == '__main__' : |
211 |
install() |