[pkg] Use setuptools

  • inside setup.py
  • update repository layout
  • update debian and centos/rhel packaging accordingly

Closes #2083027.

authorRémi Cardona <remi.cardona@logilab.fr>
changeset57580edb5e76
branchdefault
phasepublic
hiddenno
parent revision#7e4af3dce0a9 [py3k] Don't decode SQL queries
child revision#c8cc18731d61 Add tox config
files modified by this revision
MANIFEST.in
__init__.py
__pkginfo__.py
debian/compat
debian/control
debian/rules
fti.py
ftiparser.g
ftiparser.py
ftiquery.py
logilab/__init__.py
logilab/database/__init__.py
logilab/database/fti.py
logilab/database/ftiparser.g
logilab/database/ftiparser.py
logilab/database/ftiquery.py
logilab/database/mysql.py
logilab/database/postgres.py
logilab/database/sqlgen.py
logilab/database/sqlite.py
logilab/database/sqlserver.py
logilab/database/sqlserver2000.py
logilab/database/sqlserver2005.py
logilab/database/sqlserver2008.py
mysql.py
postgres.py
python-logilab-database.spec
setup.py
sqlgen.py
sqlite.py
sqlserver.py
sqlserver2000.py
sqlserver2005.py
sqlserver2008.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@logilab.fr>
# Date 1444653316 -7200
# Mon Oct 12 14:35:16 2015 +0200
# Node ID 57580edb5e7619bc0ca2cca314af5a90d23b22a7
# Parent 7e4af3dce0a9dd299c34217fa024a6dc62a517aa
[pkg] Use setuptools

* inside setup.py
* update repository layout
* update debian and centos/rhel packaging accordingly

Closes #2083027.

diff --git a/MANIFEST.in b/MANIFEST.in
@@ -1,4 +1,5 @@
1  include ChangeLog
2  include COPYING
3  include COPYING.LESSER
4 -include ftiparser.g
5 +include logilab/database/ftiparser.g
6 +include __pkginfo__.py
diff --git a/__pkginfo__.py b/__pkginfo__.py
@@ -15,10 +15,12 @@
7  #
8  # You should have received a copy of the GNU Lesser General Public License along
9  # with logilab-database. If not, see <http://www.gnu.org/licenses/>.
10  """logilab.database packaging information."""
11 
12 +import sys
13 +
14  distname = 'logilab-database'
15  modname = 'database'
16  numversion = (1, 13, 4)
17  version = '.'.join([str(num) for num in numversion])
18  license = 'LGPL'
@@ -27,15 +29,28 @@
19  author_email = "contact@logilab.fr"
20 
21  description = "true unified database access"
22 
23  web = "http://www.logilab.org/project/%s" % distname
24 -ftp = "ftp://ftp.logilab.org/pub/%s" % modname
25  mailinglist = "mailto://python-projects@lists.logilab.org"
26 
27  subpackage_of = 'logilab'
28 -subpackage_master = True
29 
30  install_requires = [
31 +    'setuptools',
32      'logilab-common >= 0.63.2',
33      'six >= 1.4.0',
34 +    'Yapps2',
35      ]
36 +
37 +tests_require = [
38 +    'psycopg2',
39 +    ]
40 +
41 +if sys.version_info[0] == 2:
42 +    tests_require.append('MySQL-python')
43 +
44 +classifiers = ["Topic :: Database",
45 +               "Programming Language :: Python",
46 +               "Programming Language :: Python :: 2",
47 +               "Programming Language :: Python :: 3",
48 +               ]
diff --git a/debian/compat b/debian/compat
@@ -1,1 +1,1 @@
49 -8
50 +9
diff --git a/debian/control b/debian/control
@@ -1,19 +1,21 @@
51  Source: logilab-database
52  Section: python
53  Priority: optional
54 -Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
55 -Uploaders: Alexandre Fayolle <afayolle@debian.org>,
56 -	   Sandro Tosi <morph@debian.org>,
57 +Maintainer: Logilab SA <contact@logilab.fr>
58  Build-Depends:
59 - debhelper (>= 8),
60 + debhelper (>= 9),
61   python-all (>= 2.6.5),
62   python3-all,
63 + python-setuptools,
64 + python3-setuptools,
65 + yapps2-runtime,
66 + python3-yapps2-runtime | python3 (<< 3.3),
67  Build-Depends-Indep: python-epydoc, graphviz
68  X-Python-Version: >= 2.6
69  X-Python3-Version: >= 3.3
70 -Standards-Version: 3.8.2
71 +Standards-Version: 3.9.6
72  Homepage: http://www.logilab.org/project/logilab-database
73 
74  Package: python-logilab-database
75  Architecture: all
76  Provides: ${python:Provides}
diff --git a/debian/rules b/debian/rules
@@ -1,9 +1,7 @@
77  #!/usr/bin/make -f
78 
79 -export NO_SETUPTOOLS=1
80 -
81  include /usr/share/python/python.mk
82 
83  # don't build the python3 package if python3 is < 3.3
84  py3k = $(subst python3.,,$(shell py3versions -d))
85  build_py3k = $(shell test "$(py3k)" -gt 2 && echo 1)
diff --git a/logilab/__init__.py b/logilab/__init__.py
@@ -0,0 +1,1 @@
86 +__import__('pkg_resources').declare_namespace(__name__)
diff --git a/__init__.py b/logilab/database/__init__.py
diff --git a/fti.py b/logilab/database/fti.py
diff --git a/ftiparser.g b/logilab/database/ftiparser.g
diff --git a/ftiparser.py b/logilab/database/ftiparser.py
diff --git a/ftiquery.py b/logilab/database/ftiquery.py
diff --git a/mysql.py b/logilab/database/mysql.py
diff --git a/postgres.py b/logilab/database/postgres.py
diff --git a/sqlgen.py b/logilab/database/sqlgen.py
diff --git a/sqlite.py b/logilab/database/sqlite.py
diff --git a/sqlserver.py b/logilab/database/sqlserver.py
diff --git a/sqlserver2000.py b/logilab/database/sqlserver2000.py
diff --git a/sqlserver2005.py b/logilab/database/sqlserver2005.py
diff --git a/sqlserver2008.py b/logilab/database/sqlserver2008.py
diff --git a/python-logilab-database.spec b/python-logilab-database.spec
@@ -19,12 +19,16 @@
87  Source0:        http://download.logilab.org/pub/database/logilab-database-%{version}.tar.gz
88  BuildArch:      noarch
89  BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
90 
91  BuildRequires:  %{python}
92 -Requires:       %{python}, %{python}-logilab-common >= 0.63.2
93 +BuildRequires:  %{python}-setuptools
94 +Requires:       %{python}
95 +Requires:       %{python}-setuptools
96 +Requires:       %{python}-logilab-common >= 0.63.2
97  Requires:       %{python}-six >= 1.4.0
98 +Requires:       %{python}-yapps2 >= 2.1.1
99 
100 
101  %description
102  logilab-database provides some classes to make unified access
103  to different RDBMS possible:
@@ -46,11 +50,11 @@
104  %endif
105 
106 
107  %install
108  rm -rf $RPM_BUILD_ROOT
109 -NO_SETUPTOOLS=1 %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
110 +%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
111  rm -rf $RPM_BUILD_ROOT%{_python_sitelib}/logilab/database/test
112  rm -rf $RPM_BUILD_ROOT%{_python_sitelib}/logilab/__init__.py*
113 
114  %clean
115  rm -rf $RPM_BUILD_ROOT
diff --git a/setup.py b/setup.py
@@ -1,8 +1,8 @@
116  #!/usr/bin/env python
117 -# pylint: disable-msg=W0404,W0622,W0704,W0613,W0152
118 -# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
119 +# pylint: disable=W0404,W0622,W0704,W0613,W0152
120 +# copyright 2003-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
121  # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
122  #
123  # This file is part of logilab-database.
124  #
125  # logilab-database is free software: you can redistribute it and/or modify it
@@ -13,153 +13,41 @@
126  # logilab-database is distributed in the hope that it will be useful, but
127  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
128  # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
129  # for more details.
130  #
131 -# You should have received a copy of the GNU Lesser General Public License along
132 -# with logilab-database. If not, see <http://www.gnu.org/licenses/>.
133 +# You should have received a copy of the GNU Lesser General Public License
134 +# along with logilab-database.  If not, see <http://www.gnu.org/licenses/>.
135  """Generic Setup script, takes package info from __pkginfo__.py file.
136 -
137  """
138  __docformat__ = "restructuredtext en"
139 
140 -import os
141 -import sys
142 -import shutil
143 -from os.path import isdir, exists, join
144 -
145 -try:
146 -    if os.environ.get('NO_SETUPTOOLS'):
147 -        raise ImportError()
148 -    from setuptools import setup
149 -    from setuptools.command import install_lib
150 -    USE_SETUPTOOLS = 1
151 -except ImportError:
152 -    from distutils.core import setup
153 -    from distutils.command import install_lib
154 -    USE_SETUPTOOLS = 0
155 +from setuptools import setup, find_packages
156 +from io import open
157 +from os import path
158 
159 -from distutils.command.build_py import build_py
160 -
161 -sys.modules.pop('__pkginfo__', None)
162 -# import optional features
163 -__pkginfo__ = __import__("__pkginfo__")
164 -# import required features
165 -from __pkginfo__ import modname, version, license, description, \
166 -     web, author, author_email
167 -
168 -distname = getattr(__pkginfo__, 'distname', modname)
169 -scripts = getattr(__pkginfo__, 'scripts', [])
170 -data_files = getattr(__pkginfo__, 'data_files', None)
171 -subpackage_of = getattr(__pkginfo__, 'subpackage_of', None)
172 -include_dirs = getattr(__pkginfo__, 'include_dirs', [])
173 -ext_modules = getattr(__pkginfo__, 'ext_modules', None)
174 -install_requires = getattr(__pkginfo__, 'install_requires', None)
175 -dependency_links = getattr(__pkginfo__, 'dependency_links', [])
176 +here = path.abspath(path.dirname(__file__))
177 
178 -STD_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build')
179 -
180 -IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
181 -
182 -if exists('README'):
183 -    long_description = open('README').read()
184 -else:
185 -    long_description = ''
186 +pkginfo = {}
187 +with open(path.join(here, '__pkginfo__.py')) as f:
188 +    exec(f.read(), pkginfo)
189 
190 -def ensure_scripts(linux_scripts):
191 -    """Creates the proper script names required for each platform
192 -    (taken from 4Suite)
193 -    """
194 -    from distutils import util
195 -    if util.get_platform()[:3] == 'win':
196 -        scripts_ = [script + '.bat' for script in linux_scripts]
197 -    else:
198 -        scripts_ = linux_scripts
199 -    return scripts_
200 -
201 -def get_packages(directory, prefix):
202 -    """return a list of subpackages for the given directory"""
203 -    result = []
204 -    for package in os.listdir(directory):
205 -        absfile = join(directory, package)
206 -        if isdir(absfile):
207 -            if exists(join(absfile, '__init__.py')) or \
208 -                   package in ('test', 'tests'):
209 -                if prefix:
210 -                    result.append('%s.%s' % (prefix, package))
211 -                else:
212 -                    result.append(package)
213 -                result += get_packages(absfile, result[-1])
214 -    return result
215 +# Get the long description from the relevant file
216 +with open(path.join(here, 'README'), encoding='utf-8') as f:
217 +    long_description = f.read()
218 
219 -EMPTY_FILE = '''"""generated file, don't modify or your data will be lost"""
220 -try:
221 -    __import__('pkg_resources').declare_namespace(__name__)
222 -except ImportError:
223 -    pass
224 -'''
225 -
226 -class MyInstallLib(install_lib.install_lib):
227 -    """extend install_lib command to handle  package __init__.py and
228 -    include_dirs variable if necessary
229 -    """
230 -    def run(self):
231 -        """overridden from install_lib class"""
232 -        install_lib.install_lib.run(self)
233 -        # create Products.__init__.py if needed
234 -        if subpackage_of:
235 -            product_init = join(self.install_dir, subpackage_of, '__init__.py')
236 -            if not exists(product_init):
237 -                self.announce('creating %s' % product_init)
238 -                stream = open(product_init, 'w')
239 -                stream.write(EMPTY_FILE)
240 -                stream.close()
241 -        # manually install included directories if any
242 -        if include_dirs:
243 -            if subpackage_of:
244 -                base = join(subpackage_of, modname)
245 -            else:
246 -                base = modname
247 -            for directory in include_dirs:
248 -                dest = join(self.install_dir, base, directory)
249 -                shutil.rmtree(dest, ignore_errors=True)
250 -                shutil.copytree(directory, dest)
251 -
252 -def install(**kwargs):
253 -    """setup entry point"""
254 -    if USE_SETUPTOOLS:
255 -        if '--force-manifest' in sys.argv:
256 -            sys.argv.remove('--force-manifest')
257 -    # install-layout option was introduced in 2.5.3-1~exp1
258 -    elif sys.version_info < (2, 5, 4) and '--install-layout=deb' in sys.argv:
259 -        sys.argv.remove('--install-layout=deb')
260 -    if subpackage_of:
261 -        package = subpackage_of + '.' + modname
262 -        kwargs['package_dir'] = {package : '.'}
263 -        packages = [package] + get_packages(os.getcwd(), package)
264 -        if USE_SETUPTOOLS:
265 -            kwargs['namespace_packages'] = [subpackage_of]
266 -    else:
267 -        kwargs['package_dir'] = {modname : '.'}
268 -        packages = [modname] + get_packages(os.getcwd(), modname)
269 -    if USE_SETUPTOOLS and install_requires:
270 -        kwargs['install_requires'] = install_requires
271 -        kwargs['dependency_links'] = dependency_links
272 -    kwargs['packages'] = packages
273 -    return setup(name = distname,
274 -                 version = version,
275 -                 license = license,
276 -                 description = description,
277 -                 long_description = long_description,
278 -                 author = author,
279 -                 author_email = author_email,
280 -                 url = web,
281 -                 scripts = ensure_scripts(scripts),
282 -                 data_files = data_files,
283 -                 ext_modules = ext_modules,
284 -                 cmdclass = {'install_lib': MyInstallLib,
285 -                             'build_py':    build_py},
286 -                 **kwargs
287 -                 )
288 -
289 -if __name__ == '__main__' :
290 -    install()
291 +setup(
292 +    name=pkginfo['distname'],
293 +    version=pkginfo['version'],
294 +    description=pkginfo['description'],
295 +    long_description=long_description,
296 +    url=pkginfo['web'],
297 +    author=pkginfo['author'],
298 +    author_email=pkginfo['author_email'],
299 +    license=pkginfo['license'],
300 +    # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
301 +    classifiers=pkginfo['classifiers'],
302 +    packages=find_packages(exclude=['contrib', 'docs', 'test*']),
303 +    namespace_packages=[pkginfo['subpackage_of']],
304 +    install_requires=pkginfo['install_requires'],
305 +    tests_require=pkginfo['tests_require'],
306 +)