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).

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

Update Debian packaging to only build on binary package.

Closes #15599451.

authorDenis Laxalde <denis.laxalde@logilab.fr>
changesetb18e13dfe4fb
branchdefault
phasedraft
hiddenyes
parent revision#31967b695715 [test] Use stdlib unittest's main
child revision<not specified>
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 b18e13dfe4fbb23cda2cb5ae51114b140d9a3267
# 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).

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

Update Debian packaging to only build on binary package.

Closes #15599451.

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