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>
changeset6fdf7024e241
branchdefault
phasedraft
hiddenyes
parent revision#c491af72dace Add .tox to .hgignore
child revision#b40adecf9f9b [test] Use stdlib unittest's main
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
test/test_celery.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 6fdf7024e241ab2cccdb5db6ba47b238b000d7fc
# Parent c491af72dace198b1fa6351fc360cd73b54a053e
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/cubicweb-celery.spec b/cubicweb-celery.spec
@@ -0,0 +1,47 @@
8 +# for el5, force use of python2.6
9 +%if 0%{?el5}
10 +%define python python26
11 +%define __python /usr/bin/python2.6
12 +%else
13 +%define python python
14 +%define __python /usr/bin/python
15 +%endif
16 +%{!?_python_sitelib: %define _python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
17 +
18 +Name:           cubicweb-celery
19 +Version:        0.1.0
20 +Release:        logilab.1%{?dist}
21 +Summary:        Celery integration with CubicWeb
22 +Group:          Applications/Internet
23 +License:        LGPL
24 +Source0:        cubicweb-celery-%{version}.tar.gz
25 +
26 +BuildArch:      noarch
27 +BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
28 +
29 +BuildRequires:  %{python} %{python}-setuptools
30 +Requires:       cubicweb >= 3.24.0.dev0
31 +Requires:       %{python}-six >= 1.4.0
32 +
33 +%description
34 +Celery integration with CubicWeb
35 +
36 +%prep
37 +%setup -q -n cubicweb-celery-%{version}
38 +%if 0%{?el5}
39 +# change the python version in shebangs
40 +find . -name '*.py' -type f -print0 |  xargs -0 sed -i '1,3s;^#!.*python.*$;#! /usr/bin/python2.6;'
41 +%endif
42 +
43 +%install
44 +%{__python} setup.py --quiet install --no-compile --prefix=%{_prefix} --root="$RPM_BUILD_ROOT"
45 +# remove generated .egg-info file
46 +rm -rf $RPM_BUILD_ROOT/usr/lib/python*
47 +
48 +
49 +%clean
50 +rm -rf $RPM_BUILD_ROOT
51 +
52 +%files
53 +%defattr(-, root, root)
54 +%{_prefix}/share/cubicweb/cubes/*
diff --git a/cubicweb_celery/__init__.py b/cubicweb_celery/__init__.py
@@ -1,5 +1,10 @@
55 +"""cubicweb-celery application package
56 +
57 +Celery integration with CubicWeb
58 +"""
59 +
60  import contextlib
61  import logging
62  import os.path as osp
63 
64  from optparse import make_option
diff --git a/cubes/celery/__pkginfo__.py b/cubicweb_celery/__pkginfo__.py
@@ -1,21 +1,25 @@
65  # pylint: disable=W0622
66 -"""cubicweb-celerytest application packaging information"""
67 +"""cubicweb-celery application packaging information"""
68 
69 -modname = 'celery'
70 +
71 +modname = 'cubicweb_celery'
72  distname = 'cubicweb-celery'
73 
74  numversion = (0, 1, 0)
75  version = '.'.join(str(num) for num in numversion)
76 
77  license = 'LGPL'
78 -author = 'Unlish'
79 -author_email = 'contact@unlish.com'
80 +author = 'Christophe de Vienne'
81 +author_email = 'christophe@unlish.com'
82  description = 'Celery cube'
83  web = 'http://www.cubicweb.org/project/%s' % distname
84 
85 -__depends__ = {'cubicweb': '>= 3.19.6'}
86 +__depends__ = {
87 +    'cubicweb': '>= 3.24.0.dev0',
88 +    'six': '>= 1.4.0',
89 +}
90  __recommends__ = {}
91 
92  classifiers = [
93      'Environment :: Web Environment',
94      '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 @@
95  Build-Depends:
96   debhelper (>= 9),
97   dh-python,
98   python (>= 2.6.5),
99   python-setuptools,
100 - cubicweb-common (>= 3.20),
101 + cubicweb-common (>= 3.24.0.dev0),
102  Standards-Version: 3.9.6
103  X-Python-Version: >= 2.6
104  Homepage: https://www.cubicweb.org/project/cubicweb-celery
105 
106  Package: cubicweb-celery
107  Architecture: all
108  Depends:
109 - cubicweb-common (>= 3.20),
110 + cubicweb-common (>= 3.24.0.dev0),
111   python-six (>= 1.4.0),
112   python-celery,
113   ${python:Depends},
114   ${misc:Depends},
115  Description: Celery integration with CubicWeb
@@ -25,23 +25,7 @@
116   .
117   Allows a CubicWeb application to use Celery to run distributed CubicWeb
118   (or not) tasks from a CubicWeb application.
119   .
120   This package will install the Celery cube allowing to declare Celery
121 - tasks running in a CubicWeb application.
122 - 
123 -Package: python-cubicweb-celery
124 -Architecture: all
125 -Section: python
126 -Depends:
127 - cubicweb-common (>= 3.20),
128 - python-celery,
129 - ${python:Depends},
130 - ${misc:Depends},
131 -Description: Celery worker module for cubicweb-celery
132 - CubicWeb is a semantic web application framework.
133 - .
134 - Allows a CubicWeb application to use Celery to run distributed CubicWeb
135 - (or not) tasks from a CubicWeb application.
136 - .
137 - This package will install the Celery worker module allowing to start Celery
138 - workers running tasks for a CubicWeb application.
139 + tasks running in a CubicWeb application along with the Celery worker module
140 + 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 @@
141 -usr/share/cubicweb/cubes/celery
142 \ No newline at end of file
diff --git a/debian/python-cubicweb-celery.install b/debian/python-cubicweb-celery.install
@@ -1,1 +0,0 @@
143 -usr/lib/python*
144 \ No newline at end of file
diff --git a/debian/rules b/debian/rules
@@ -1,10 +1,4 @@
145  #!/usr/bin/make -f
146 
147 -export NO_SETUPTOOLS=1
148 -
149  %:
150  	dh $@ --with python2
151 -
152 -override_dh_python2:
153 -	dh_python2 --no-guessing-deps
154 -	dh_python2 -i /usr/share/cubicweb
diff --git a/setup.py b/setup.py
@@ -1,19 +1,81 @@
155 -import os
156 -from glob import glob
157 +#!/usr/bin/env python
158 +# pylint: disable=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611
159 +#
160 +# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
161 +# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
162 +#
163 +# This file is part of a cubicweb-celery.
164 +#
165 +# CubicWeb is free software: you can redistribute it and/or modify it under the
166 +# terms of the GNU Lesser General Public License as published by the Free
167 +# Software Foundation, either version 2.1 of the License, or (at your option)
168 +# any later version.
169 +#
170 +# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
171 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
172 +# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
173 +# details.
174 +#
175 +# You should have received a copy of the GNU Lesser General Public License
176 +# along with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
177 +"""cubicweb_celery setup module using data from
178 +cubicweb_celery/__pkginfo__.py file
179 +"""
180 +
181 +from os.path import join, dirname
182 +
183 +from setuptools import find_packages, setup
184 +
185 +
186 +here = dirname(__file__)
187 
188 -from setuptools import setup
189 +# load metadata from the __pkginfo__.py file so there is no risk of conflict
190 +# see https://packaging.python.org/en/latest/single_source_version.html
191 +pkginfo = join(here, 'cubicweb_celery', '__pkginfo__.py')
192 +__pkginfo__ = {}
193 +with open(pkginfo) as f:
194 +    exec(f.read(), __pkginfo__)
195 +
196 +# get required metadatas
197 +distname = __pkginfo__['distname']
198 +version = __pkginfo__['version']
199 +license = __pkginfo__['license']
200 +description = __pkginfo__['description']
201 +web = __pkginfo__['web']
202 +author = __pkginfo__['author']
203 +author_email = __pkginfo__['author_email']
204 +classifiers = __pkginfo__['classifiers']
205 +
206 +with open(join(here, 'README.rst')) as f:
207 +    long_description = f.read()
208 +
209 +# get optional metadatas
210 +data_files = __pkginfo__.get('data_files', None)
211 +dependency_links = __pkginfo__.get('dependency_links', ())
212 +
213 +requires = {}
214 +for entry in ("__depends__",):  # "__recommends__"):
215 +    requires.update(__pkginfo__.get(entry, {}))
216 +install_requires = ["{0} {1}".format(d, v and v or "").strip()
217 +                    for d, v in requires.items()]
218 +
219 
220  setup(
221 -    name='cubicweb-celery',
222 -    version='0.1.0',
223 -    description='Celery integration with CubicWeb',
224 -    author='Christophe de Vienne',
225 -    author_email='christophe@unlish.com',
226 -    packages=['cubicweb_celery'],
227 -    install_requires=[
228 -        'celery', 'cubicweb'
229 -    ],
230 -    data_files=[
231 -        (os.path.join('share', 'cubicweb', 'cubes', 'celery'),
232 -         glob('cubes/celery/*.py'))
233 -    ])
234 +    name=distname,
235 +    version=version,
236 +    license=license,
237 +    description=description,
238 +    long_description=long_description,
239 +    author=author,
240 +    author_email=author_email,
241 +    url=web,
242 +    classifiers=classifiers,
243 +    packages=find_packages(exclude=['test']),
244 +    install_requires=install_requires,
245 +    entry_points={
246 +        'cubicweb.cubes': [
247 +            'celery=cubicweb_celery',
248 +        ],
249 +    },
250 +    zip_safe=False,
251 +)
diff --git a/test/data/bootstrap_cubes b/test/data/bootstrap_cubes
@@ -0,0 +1,1 @@
252 +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/cubes/celery/test/test_celery.py b/test/test_celery.py
diff --git a/tox.ini b/tox.ini
@@ -1,22 +1,21 @@
253  [tox]
254 -envlist = py27,flake8
255 +envlist = py27,py34,flake8
256 
257  [testenv]
258 +sitepackages = true
259  deps =
260 -    pytest
261 +  http://hg.logilab.org/master/cubicweb/archive/4e3ae4bd3fd5.tar.bz2#egg=cubicweb
262 +  pytest
263  commands =
264 -    {envpython} -m pytest {posargs:{toxinidir}/cubes/celery/test}
265 +  {envpython} -m pytest {posargs:test}
266 
267  [testenv:flake8]
268  skip_install = true
269  whitelist_externals =
270    flake8
271  deps =
272    flake8
273 -commands = flake8 {posargs}
274 -
275 -[pytest]
276 -python_files = *test_*.py
277 +commands = flake8
278 
279  [flake8]
280 -exclude = cubes/celery/migration/*,cubes/celery/test/data/*,.tox/*
281 +exclude = cubicweb_celery/migration/*,test/data/*,.tox/*
diff --git a/tweak-venv.sh b/tweak-venv.sh
@@ -1,11 +0,0 @@
282 -#!/bin/bash
283 -
284 -MYPATH=$(pwd)
285 -MODNAME=celery
286 -
287 -if [ -z "$VIRTUAL_ENV" ]; then
288 -    exit 1
289 -fi
290 -
291 -rm -rf $VIRTUAL_ENV/share/cubicweb/cubes/$MODNAME
292 -ln -s $MYPATH/cubes/celery $VIRTUAL_ENV/share/cubicweb/cubes/$MODNAME