Move to package layout

Pull files from 3.24 skeleton and move existing files to the package layout (i.e. cubes/celery/* -> cubicweb_celery except __init__.py which is empty). Update MANIFEST.in accordingly.

Added an RPM spec file (from skeleton) along the way.

Update Debian packaging to only build one binary package.

Closes #15599451.

authorDenis Laxalde <denis.laxalde@logilab.fr>
changeset649f423bd947
branchdefault
phasedraft
hiddenyes
parent revision#31967b695715 [test] Use stdlib unittest's main
child revision#bff5d8c1122f [pkg] Bump to a development version
files modified by this revision
MANIFEST.in
cubes/celery/__init__.py
cubes/celery/__pkginfo__.py
cubes/celery/migration/ddl.sql
cubes/celery/migration/postcreate.py
cubes/celery/migration/table.sql
cubes/celery/sobjects.py
cubes/celery/test/data/bootstrap_cubes
cubes/celery/test/data/celeryconfig.py
cubes/celery/test/data/sobjects.py
cubes/celery/test/test_celery.py
cubicweb-celery.spec
cubicweb_celery/__init__.py
cubicweb_celery/__pkginfo__.py
cubicweb_celery/migration/ddl.sql
cubicweb_celery/migration/postcreate.py
cubicweb_celery/migration/table.sql
cubicweb_celery/sobjects.py
debian/control
debian/cubicweb-celery.install
debian/python-cubicweb-celery.install
debian/rules
setup.py
test/data/bootstrap_cubes
test/data/celeryconfig.py
test/data/sobjects.py
tox.ini
tweak-venv.sh
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1475649742 -7200
# Wed Oct 05 08:42:22 2016 +0200
# Node ID 649f423bd947600a3a38ff38f10d96e6af28e1bc
# Parent 31967b6957159ab6ad79d6cd3b29a6b06a29554f
Move to package layout

Pull files from 3.24 skeleton and move existing files to the package layout
(i.e. cubes/celery/* -> cubicweb_celery except __init__.py which is empty).
Update MANIFEST.in accordingly.

Added an RPM spec file (from skeleton) along the way.

Update Debian packaging to only build one binary package.

Closes #15599451.

diff --git a/MANIFEST.in b/MANIFEST.in
@@ -1,1 +1,11 @@
1 -recursive-include cubes/celery *.py
2 +include *.py
3 +include */*.py
4 +recursive-include cubicweb_celery *.py
5 +recursive-include cubicweb_celery/data *.gif *.png *.ico *.css *.js
6 +recursive-include cubicweb_celery/i18n *.po
7 +recursive-include cubicweb_celery/wdoc *
8 +recursive-include cubicweb_celery/migration *.sql
9 +recursive-include test/data bootstrap_cubes *.py
10 +include tox.ini
11 +recursive-include debian changelog compat control copyright rules
12 +include cubicweb-celery.spec
diff --git a/cubes/celery/__init__.py b/cubes/celery/__init__.py
diff --git a/cubes/celery/test/data/bootstrap_cubes b/cubes/celery/test/data/bootstrap_cubes
@@ -1,1 +0,0 @@
13 -celery
diff --git a/cubes/celery/test/test_celery.py b/cubes/celery/test/test_celery.py
@@ -1,87 +0,0 @@
14 -# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
15 -# contact http://www.logilab.fr -- mailto:contact@logilab.fr
16 -#
17 -# This program is free software: you can redistribute it and/or modify it under
18 -# the terms of the GNU Lesser General Public License as published by the Free
19 -# Software Foundation, either version 2.1 of the License, or (at your option)
20 -# any later version.
21 -#
22 -# This program is distributed in the hope that it will be useful, but WITHOUT
23 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24 -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
25 -# details.
26 -#
27 -# You should have received a copy of the GNU Lesser General Public License
28 -# along with this program. If not, see <http://www.gnu.org/licenses/>.
29 -
30 -
31 -from cubicweb.devtools import testlib
32 -from cubicweb_celery import app, init_repo, CWTask
33 -
34 -
35 -class DefaultTC(testlib.CubicWebTC):
36 -    def setUp(self):
37 -        super(DefaultTC, self).setUp()
38 -        app.cwrepo = init_repo(app.cwconfig)
39 -
40 -    def test_cwtask(self):
41 -        eid = app.tasks['newgroup'](u'test')
42 -        with self.admin_access.cnx() as cnx:
43 -            self.assertEqual(cnx.entity_from_eid(eid).name, u'test')
44 -
45 -    def test_cw_user_cnx(self):
46 -        with self.admin_access.cnx() as cnx:
47 -            user_eid = self.create_user(cnx, u'testuser',
48 -                                        groups=('managers',)).eid
49 -            admin_eid = cnx.find('CWUser', login=u'admin').one().eid
50 -            cnx.commit()
51 -
52 -        groups = {app.tasks['newgroup'](name, eid): name for name, eid in (
53 -            (u'test_group_user', user_eid),
54 -            (u'test_group_admin', admin_eid),
55 -            (u'test_group_internal', -1),
56 -        )}
57 -
58 -        with self.admin_access.cnx() as cnx:
59 -            for group_eid, expected_name in groups.items():
60 -                self.assertEqual(cnx.entity_from_eid(group_eid).name,
61 -                                 expected_name)
62 -
63 -    def test_missing_need_cnx(self):
64 -
65 -        class MissingNeedCnxTask(CWTask):
66 -            name = 'missing-need-cnx'
67 -
68 -            def run(me):
69 -                self.assertFalse(hasattr(me, 'cw_cnx'))
70 -                with self.assertRaises(ValueError) as exc:
71 -                    with me.cw_user_cnx(None):
72 -                        pass
73 -                self.assertEqual(str(exc.exception),
74 -                                 'use of cw_user_cnx() requires need_cnx')
75 -                return 42
76 -
77 -        self.assertEqual(MissingNeedCnxTask()(), 42)
78 -
79 -    def test_default_config(self):
80 -        self.assertTrue(app.conf.CELERY_ENABLE_UTC)
81 -        self.assertEqual('Indian/Maldives',
82 -                         app.conf.CELERY_TIMEZONE)
83 -
84 -    def test_propagate_exception_in_test_mode(self):
85 -        # by default propagate exception
86 -        with self.assertRaises(ValueError) as excinfo:
87 -            app.tasks['newgroup'].delay(u'magic')
88 -        self.assertEqual(str(excinfo.exception), 'Cannot add a magic group')
89 -
90 -        app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = False
91 -        try:
92 -            # should not raise
93 -            app.tasks['newgroup'].delay(u'magic')
94 -        finally:
95 -            app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
96 -
97 -
98 -if __name__ == '__main__':
99 -    from logilab.common.testlib import unittest_main
100 -    unittest_main()
diff --git a/cubicweb-celery.spec b/cubicweb-celery.spec
@@ -0,0 +1,47 @@
101 +# for el5, force use of python2.6
102 +%if 0%{?el5}
103 +%define python python26
104 +%define __python /usr/bin/python2.6
105 +%else
106 +%define python python
107 +%define __python /usr/bin/python
108 +%endif
109 +%{!?_python_sitelib: %define _python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
110 +
111 +Name:           cubicweb-celery
112 +Version:        0.1.0
113 +Release:        logilab.1%{?dist}
114 +Summary:        Celery integration with CubicWeb
115 +Group:          Applications/Internet
116 +License:        LGPL
117 +Source0:        cubicweb-celery-%{version}.tar.gz
118 +
119 +BuildArch:      noarch
120 +BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
121 +
122 +BuildRequires:  %{python} %{python}-setuptools
123 +Requires:       cubicweb >= 3.24.0.dev0
124 +Requires:       %{python}-six >= 1.4.0
125 +
126 +%description
127 +Celery integration with CubicWeb
128 +
129 +%prep
130 +%setup -q -n cubicweb-celery-%{version}
131 +%if 0%{?el5}
132 +# change the python version in shebangs
133 +find . -name '*.py' -type f -print0 |  xargs -0 sed -i '1,3s;^#!.*python.*$;#! /usr/bin/python2.6;'
134 +%endif
135 +
136 +%install
137 +%{__python} setup.py --quiet install --no-compile --prefix=%{_prefix} --root="$RPM_BUILD_ROOT"
138 +# remove generated .egg-info file
139 +rm -rf $RPM_BUILD_ROOT/usr/lib/python*
140 +
141 +
142 +%clean
143 +rm -rf $RPM_BUILD_ROOT
144 +
145 +%files
146 +%defattr(-, root, root)
147 +%{_prefix}/share/cubicweb/cubes/*
diff --git a/cubicweb_celery/__init__.py b/cubicweb_celery/__init__.py
@@ -1,5 +1,10 @@
148 +"""cubicweb-celery application package
149 +
150 +Celery integration with CubicWeb
151 +"""
152 +
153  import contextlib
154  import logging
155  import os.path as osp
156 
157  from optparse import make_option
diff --git a/cubes/celery/__pkginfo__.py b/cubicweb_celery/__pkginfo__.py
@@ -1,21 +1,26 @@
158  # pylint: disable=W0622
159 -"""cubicweb-celerytest application packaging information"""
160 +"""cubicweb-celery application packaging information"""
161 
162 -modname = 'celery'
163 +
164 +modname = 'cubicweb_celery'
165  distname = 'cubicweb-celery'
166 
167  numversion = (0, 1, 0)
168  version = '.'.join(str(num) for num in numversion)
169 
170  license = 'LGPL'
171 -author = 'Unlish'
172 -author_email = 'contact@unlish.com'
173 +author = 'Christophe de Vienne'
174 +author_email = 'christophe@unlish.com'
175  description = 'Celery cube'
176  web = 'http://www.cubicweb.org/project/%s' % distname
177 
178 -__depends__ = {'cubicweb': '>= 3.19.6'}
179 +__depends__ = {
180 +    'cubicweb': '>= 3.24.0.dev0',
181 +    'six': '>= 1.4.0',
182 +    'celery': None,
183 +}
184  __recommends__ = {}
185 
186  classifiers = [
187      'Environment :: Web Environment',
188      'Framework :: CubicWeb',
diff --git a/cubes/celery/migration/ddl.sql b/cubicweb_celery/migration/ddl.sql
diff --git a/cubes/celery/migration/postcreate.py b/cubicweb_celery/migration/postcreate.py
diff --git a/cubes/celery/migration/table.sql b/cubicweb_celery/migration/table.sql
diff --git a/cubes/celery/sobjects.py b/cubicweb_celery/sobjects.py
diff --git a/debian/control b/debian/control
@@ -5,19 +5,19 @@
189  Build-Depends:
190   debhelper (>= 9),
191   dh-python,
192   python (>= 2.6.5),
193   python-setuptools,
194 - cubicweb-common (>= 3.20),
195 + cubicweb-common (>= 3.24.0.dev0),
196  Standards-Version: 3.9.6
197  X-Python-Version: >= 2.6
198  Homepage: https://www.cubicweb.org/project/cubicweb-celery
199 
200  Package: cubicweb-celery
201  Architecture: all
202  Depends:
203 - cubicweb-common (>= 3.20),
204 + cubicweb-common (>= 3.24.0.dev0),
205   python-six (>= 1.4.0),
206   python-celery,
207   ${python:Depends},
208   ${misc:Depends},
209  Description: Celery integration with CubicWeb
@@ -25,23 +25,7 @@
210   .
211   Allows a CubicWeb application to use Celery to run distributed CubicWeb
212   (or not) tasks from a CubicWeb application.
213   .
214   This package will install the Celery cube allowing to declare Celery
215 - tasks running in a CubicWeb application.
216 - 
217 -Package: python-cubicweb-celery
218 -Architecture: all
219 -Section: python
220 -Depends:
221 - cubicweb-common (>= 3.20),
222 - python-celery,
223 - ${python:Depends},
224 - ${misc:Depends},
225 -Description: Celery worker module for cubicweb-celery
226 - CubicWeb is a semantic web application framework.
227 - .
228 - Allows a CubicWeb application to use Celery to run distributed CubicWeb
229 - (or not) tasks from a CubicWeb application.
230 - .
231 - This package will install the Celery worker module allowing to start Celery
232 - workers running tasks for a CubicWeb application.
233 + tasks running in a CubicWeb application along with the Celery worker module
234 + allowing to start Celery workers running tasks for a CubicWeb application.
diff --git a/debian/cubicweb-celery.install b/debian/cubicweb-celery.install
@@ -1,1 +0,0 @@
235 -usr/share/cubicweb/cubes/celery
236 \ No newline at end of file
diff --git a/debian/python-cubicweb-celery.install b/debian/python-cubicweb-celery.install
@@ -1,1 +0,0 @@
237 -usr/lib/python*
238 \ No newline at end of file
diff --git a/debian/rules b/debian/rules
@@ -1,10 +1,4 @@
239  #!/usr/bin/make -f
240 
241 -export NO_SETUPTOOLS=1
242 -
243  %:
244  	dh $@ --with python2
245 -
246 -override_dh_python2:
247 -	dh_python2 --no-guessing-deps
248 -	dh_python2 -i /usr/share/cubicweb
diff --git a/setup.py b/setup.py
@@ -1,19 +1,82 @@
249 -import os
250 -from glob import glob
251 +#!/usr/bin/env python
252 +# pylint: disable=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611
253 +#
254 +# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
255 +# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
256 +#
257 +# This file is part of a cubicweb-celery.
258 +#
259 +# CubicWeb is free software: you can redistribute it and/or modify it under the
260 +# terms of the GNU Lesser General Public License as published by the Free
261 +# Software Foundation, either version 2.1 of the License, or (at your option)
262 +# any later version.
263 +#
264 +# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
265 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
266 +# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
267 +# details.
268 +#
269 +# You should have received a copy of the GNU Lesser General Public License
270 +# along with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
271 +"""cubicweb_celery setup module using data from
272 +cubicweb_celery/__pkginfo__.py file
273 +"""
274 +
275 +from os.path import join, dirname
276 +
277 +from setuptools import find_packages, setup
278 +
279 +
280 +here = dirname(__file__)
281 
282 -from setuptools import setup
283 +# load metadata from the __pkginfo__.py file so there is no risk of conflict
284 +# see https://packaging.python.org/en/latest/single_source_version.html
285 +pkginfo = join(here, 'cubicweb_celery', '__pkginfo__.py')
286 +__pkginfo__ = {}
287 +with open(pkginfo) as f:
288 +    exec(f.read(), __pkginfo__)
289 +
290 +# get required metadatas
291 +distname = __pkginfo__['distname']
292 +version = __pkginfo__['version']
293 +license = __pkginfo__['license']
294 +description = __pkginfo__['description']
295 +web = __pkginfo__['web']
296 +author = __pkginfo__['author']
297 +author_email = __pkginfo__['author_email']
298 +classifiers = __pkginfo__['classifiers']
299 +
300 +with open(join(here, 'README.rst')) as f:
301 +    long_description = f.read()
302 +
303 +# get optional metadatas
304 +data_files = __pkginfo__.get('data_files', None)
305 +dependency_links = __pkginfo__.get('dependency_links', ())
306 +
307 +requires = {}
308 +for entry in ("__depends__",):  # "__recommends__"):
309 +    requires.update(__pkginfo__.get(entry, {}))
310 +install_requires = ["{0} {1}".format(d, v and v or "").strip()
311 +                    for d, v in requires.items()]
312 +
313 
314  setup(
315 -    name='cubicweb-celery',
316 -    version='0.1.0',
317 -    description='Celery integration with CubicWeb',
318 -    author='Christophe de Vienne',
319 -    author_email='christophe@unlish.com',
320 -    packages=['cubicweb_celery'],
321 -    install_requires=[
322 -        'celery', 'cubicweb'
323 -    ],
324 -    data_files=[
325 -        (os.path.join('share', 'cubicweb', 'cubes', 'celery'),
326 -         glob('cubes/celery/*.py'))
327 -    ])
328 +    name=distname,
329 +    version=version,
330 +    license=license,
331 +    description=description,
332 +    long_description=long_description,
333 +    author=author,
334 +    author_email=author_email,
335 +    url=web,
336 +    classifiers=classifiers,
337 +    packages=find_packages(exclude=['test']),
338 +    install_requires=install_requires,
339 +    include_package_data=True,
340 +    entry_points={
341 +        'cubicweb.cubes': [
342 +            'celery=cubicweb_celery',
343 +        ],
344 +    },
345 +    zip_safe=False,
346 +)
diff --git a/test/data/bootstrap_cubes b/test/data/bootstrap_cubes
@@ -0,0 +1,1 @@
347 +celery
diff --git a/cubes/celery/test/data/celeryconfig.py b/test/data/celeryconfig.py
diff --git a/cubes/celery/test/data/sobjects.py b/test/data/sobjects.py
diff --git a/tox.ini b/tox.ini
@@ -1,22 +1,21 @@
348  [tox]
349 -envlist = py27,flake8
350 +envlist = py27,py34,flake8
351 
352  [testenv]
353 +sitepackages = true
354  deps =
355 -    pytest
356 +  http://hg.logilab.org/master/cubicweb/archive/4e3ae4bd3fd5.tar.bz2#egg=cubicweb
357 +  pytest
358  commands =
359 -    {envpython} -m pytest {posargs:{toxinidir}/cubes/celery/test}
360 +  {envpython} -m pytest {posargs:test}
361 
362  [testenv:flake8]
363  skip_install = true
364  whitelist_externals =
365    flake8
366  deps =
367    flake8
368 -commands = flake8 {posargs}
369 -
370 -[pytest]
371 -python_files = *test_*.py
372 +commands = flake8
373 
374  [flake8]
375 -exclude = cubes/celery/migration/*,cubes/celery/test/data/*,.tox/*
376 +exclude = cubicweb_celery/migration/*,test/data/*,.tox/*
diff --git a/tweak-venv.sh b/tweak-venv.sh
@@ -1,11 +0,0 @@
377 -#!/bin/bash
378 -
379 -MYPATH=$(pwd)
380 -MODNAME=celery
381 -
382 -if [ -z "$VIRTUAL_ENV" ]; then
383 -    exit 1
384 -fi
385 -
386 -rm -rf $VIRTUAL_ENV/share/cubicweb/cubes/$MODNAME
387 -ln -s $MYPATH/cubes/celery $VIRTUAL_ENV/share/cubicweb/cubes/$MODNAME