Merge lp:~andrea.corbellini/beeseek/packaging into lp:beeseek/1.0

Proposed by Andrea Corbellini
Status: Merged
Approved by: Andrea Corbellini
Approved revision: 336
Merged at revision: not available
Proposed branch: lp:~andrea.corbellini/beeseek/packaging
Merge into: lp:beeseek/1.0
Diff against target: None lines
To merge this branch: bzr merge lp:~andrea.corbellini/beeseek/packaging
Reviewer Review Type Date Requested Status
Andrea Colangelo Approve
Review via email: mp+10844@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrea Corbellini (andrea.corbellini) wrote :

The new code in this branch helps both users and developers when creating packages. It improves the build process in different ways:

setup.py:
1. Exclude files and directories that are not needed (test files and API documentation).
2. If given, use the --root option instead of --prefix to install data.

Makefile:
1. Avoid the re-build of files already created.

The Makefile also has new commands to create four different types of archives: tar, tar.gz, tar.bz2, zip.

This branch is needed for the creation of distribution packages too.

Revision history for this message
Andrea Colangelo (warp10) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2009-08-09 16:13:30 +0000
+++ Makefile 2009-08-28 13:32:45 +0000
@@ -13,20 +13,48 @@
13# You should have received a copy of the GNU Affero General Public License13# You should have received a copy of the GNU Affero General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.14# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
16PYTHON=/usr/bin/python16NAME := beeseek-peer
1717VERSION := $(shell ./beeseek-peer version --short)
18FULLNAME := $(NAME)-$(VERSION)
19PYVERSION := $(shell python -V 2>&1 | egrep -o '([0-9]\.[0-9])')
20PLATFORM := $(shell uname -s | tr A-Z a-z)-$(shell uname -m)
21PKGFILES := build/lib.$(PLATFORM)-$(PYVERSION)/beeseek \
22 build/scripts-$(PYVERSION)/beeseek-peer \
23 beeseek-peer.init config database templates setup.py
18pyflakes_ignore := beeseek/tests/unittests/.*\.py.*(undefined name|imported but unused)24pyflakes_ignore := beeseek/tests/unittests/.*\.py.*(undefined name|imported but unused)
1925
20build: version-info26build: version-info
21 $(PYTHON) setup.py build27 python setup.py build
2228
23install: build29install: build
24 $(PYTHON) setup.py install30 python setup.py install
2531
26version-info:32version-info: beeseek/_version_info.py
33beeseek/_version_info.py:
27 bzr version-info --python > beeseek/_version_info.py34 bzr version-info --python > beeseek/_version_info.py
2835
2936
37dist: build
38 mkdir -p dist/$(FULLNAME)
39 cp -R $(PKGFILES) dist/$(FULLNAME)
40
41tar: dist/$(FULLNAME).tar
42dist/$(FULLNAME).tar: dist
43 tar -cf dist/$(FULLNAME).tar -C dist $(FULLNAME)
44
45tar.gz: dist/$(FULLNAME).tar.gz
46dist/$(FULLNAME).tar.gz: tar
47 gzip -9 dist/$(FULLNAME).tar
48
49tar.bz2: dist/$(FULLNAME).tar.bz2
50dist/$(FULLNAME).tar.bz2: tar
51 bzip2 -9 dist/$(FULLNAME).tar
52
53zip: dist/$(FULLNAME).zip
54dist/$(FULLNAME).zip: dist
55 cd dist; zip -rq $(FULLNAME).zip $(FULLNAME)
56
57
30pychecker:58pychecker:
31 find beeseek -name "*.py" | xargs pychecker --limit=10000059 find beeseek -name "*.py" | xargs pychecker --limit=100000
3260
@@ -42,12 +70,13 @@
42 pylint -f parseable -r no --enable-checker miscellaneous beeseek70 pylint -f parseable -r no --enable-checker miscellaneous beeseek
4371
4472
45docs:73docs: doc/build
74doc/build:
46 sphinx-build -b html -d doc/build/doctrees -N -c doc/ beeseek/docs doc/build/html75 sphinx-build -b html -d doc/build/doctrees -N -c doc/ beeseek/docs doc/build/html
47 epydoc --html -n"BeeSeek" --no-frames --no-source --simple-term beeseek -o doc/build/html/source76 epydoc --html -n"BeeSeek" --no-frames --no-source --simple-term beeseek -o doc/build/html/source
4877
49clean:78clean:
50 rm -rf build doc/build dist beeseek/_version_info.py79 rm -rf build dist doc/build beeseek/_version_info.py
51 find . -name "*.pyc" -o -name "*.pyo" -o -name "*~" | xargs rm -f80 find . -name "*.pyc" -o -name "*.pyo" -o -name "*~" | xargs rm -f
5281
53clean-db:82clean-db:
5483
=== modified file 'beeseek/app/directory.py'
--- beeseek/app/directory.py 2009-07-09 11:37:49 +0000
+++ beeseek/app/directory.py 2009-07-14 16:07:24 +0000
@@ -15,24 +15,37 @@
1515
16import os16import os
17import stat17import stat
18import sys
18import tempfile19import tempfile
1920
2021
21tempdirs = tempfile._candidate_tempdir_list()22lockdirs = tempfile._candidate_tempdir_list()
23if os.name != 'nt':
24 lockdirs.insert(0, '/var/lock')
2225
23class Directory(object):26class Directory(object):
2427
25 __slots__ = 'dirlist', '_mode', '_subdirs', '_directory', '_create'28 __slots__ = 'dirlist', '_mode', '_subdirs', '_directory', '_create'
2629
27 def __init__(self, dirlist, **kwargs):30 def __init__(self, dirlist, mode='rw', subdirs=(), create=False,
31 adjust=False):
28 if isinstance(dirlist, basestring):32 if isinstance(dirlist, basestring):
29 dirlist = (dirlist,)33 dirlist = (dirlist,)
34 if adjust and os.name == 'nt':
35 dirlist = self._adjust_for_win(dirlist)
30 self.dirlist = tuple(os.path.normcase(os.path.abspath(36 self.dirlist = tuple(os.path.normcase(os.path.abspath(
31 os.path.expanduser(directory)))37 os.path.expanduser(directory)))
32 for directory in dirlist)38 for directory in dirlist)
33 self._mode = kwargs.get('mode', 'rw')39 self._mode = mode
34 self._subdirs = kwargs.get('subdirs', ())40 self._subdirs = subdirs
35 self._create = kwargs.get('create', ())41 self._create = create
42
43 def _adjust_for_win(self, dirlist):
44 basepath = os.path.dirname(sys.executable)
45 for directory in dirlist:
46 yield os.path.join(basepath,
47 'BeeSeek',
48 os.path.basename(directory))
3649
37 def _check_permissions(self, directory):50 def _check_permissions(self, directory):
38 strmode = self._mode51 strmode = self._mode
@@ -41,7 +54,6 @@
41 stat_result = os.stat(directory)54 stat_result = os.stat(directory)
42 usermode = groupmode = othermode = 055 usermode = groupmode = othermode = 0
4356
44 # _issuitable() should be called rarely so we can use hasattr() here
45 if not hasattr(os, 'getuid') or stat_result.st_uid == os.getuid():57 if not hasattr(os, 'getuid') or stat_result.st_uid == os.getuid():
46 if 'r' in strmode:58 if 'r' in strmode:
47 usermode = stat.S_IXUSR59 usermode = stat.S_IXUSR
4860
=== modified file 'beeseek/app/options.py'
--- beeseek/app/options.py 2009-08-23 19:12:47 +0000
+++ beeseek/app/options.py 2009-08-24 15:10:30 +0000
@@ -15,7 +15,7 @@
1515
16import os16import os
17from beeseek.app import instance17from beeseek.app import instance
18from beeseek.app.directory import Directory, tempdirs18from beeseek.app.directory import Directory, lockdirs
19from beeseek.interface import Interface, implements19from beeseek.interface import Interface, implements
2020
2121
@@ -198,6 +198,14 @@
198 'Enable the testing mode.')198 'Enable the testing mode.')
199199
200200
201class VersionOptions(BaseOptionList):
202
203 implements(IOptionList)
204
205 short = Option(bool, None, ('-s', '--short'), None,
206 'Show just the version number.')
207
208
201class CommonServiceOptions(CommonOptions):209class CommonServiceOptions(CommonOptions):
202210
203 """Options to deal with the service."""211 """Options to deal with the service."""
@@ -212,7 +220,7 @@
212 lockdir = Option(Directory, 'LockDirectory',220 lockdir = Option(Directory, 'LockDirectory',
213 ('-L', '--lock-dir'), None,221 ('-L', '--lock-dir'), None,
214 'The directory for lock files.',222 'The directory for lock files.',
215 default=['/var/lock'] + tempdirs,223 default=lockdirs,
216 convert_default=True)224 convert_default=True)
217225
218 user = Option(str, 'User',226 user = Option(str, 'User',
@@ -235,7 +243,8 @@
235 convert_kwargs={243 convert_kwargs={
236 'subdirs': ('keywords', 'pages', 'configuration',244 'subdirs': ('keywords', 'pages', 'configuration',
237 'statistics', 'keys', 'needed-results'),245 'statistics', 'keys', 'needed-results'),
238 'create': True})246 'create': True,
247 'adjust': True})
239248
240 daemon = Option(bool, 'Daemon',249 daemon = Option(bool, 'Daemon',
241 ('-b', '--daemon'), ('-f', '--foreground'),250 ('-b', '--daemon'), ('-f', '--foreground'),
@@ -254,7 +263,9 @@
254 testing_default='templates',263 testing_default='templates',
255 convert_default=True,264 convert_default=True,
256 convert_kwargs={265 convert_kwargs={
257 'mode': 'r', 'subdirs': ('css', 'html', 'images', 'javascript')})266 'mode': 'r',
267 'subdirs': ('css', 'html', 'images', 'javascript'),
268 'adjust': True})
258269
259 server_hostname = Option(str, 'ServerHostname',270 server_hostname = Option(str, 'ServerHostname',
260 ('-s', '--server'), None,271 ('-s', '--server'), None,
261272
=== modified file 'beeseek/app/session.py'
--- beeseek/app/session.py 2009-08-24 12:38:07 +0000
+++ beeseek/app/session.py 2009-08-24 15:10:30 +0000
@@ -29,7 +29,7 @@
29from beeseek.app.command import CommandObject, command29from beeseek.app.command import CommandObject, command
30from beeseek.app.baseconfig import ConfigurationParser30from beeseek.app.baseconfig import ConfigurationParser
31from beeseek.app.options import (31from beeseek.app.options import (
32 CommonOptions, CommonServiceOptions, StartOptions)32 CommonOptions, VersionOptions, CommonServiceOptions, StartOptions)
33from beeseek.app.directory import Directory33from beeseek.app.directory import Directory
34from beeseek.app.utils import get_argcount34from beeseek.app.utils import get_argcount
3535
@@ -210,7 +210,10 @@
210 return getattr(self, '_status', 'unknown')210 return getattr(self, '_status', 'unknown')
211211
212 # Configuration212 # Configuration
213 configdir = Directory(('/etc/beeseek', '~/.beeseek', 'config'), mode='r')213 # XXX This should be set elsewhere
214 configdir = Directory(('/etc/beeseek', 'config'),
215 mode='r',
216 adjust=True)
214 logfile = open(os.devnull, 'w')217 logfile = open(os.devnull, 'w')
215 debug = False218 debug = False
216219
@@ -645,12 +648,15 @@
645 parser.populate(command_obj.optionlist)648 parser.populate(command_obj.optionlist)
646 print parser.format_option_help()649 print parser.format_option_help()
647650
648 @command(CommonOptions)651 @command(VersionOptions)
649 def version(self):652 def version(self):
650 """Show version information."""653 """Show version information."""
651 print '%s version %s' % (self.appname, version_info)654 if self.short:
652 if version_info.revno:655 print version_info
653 print 'Revision: %s' % version_info.revno656 else:
657 print '%s version %s' % (self.appname, version_info)
658 if version_info.revno:
659 print 'Revision: %s' % version_info.revno
654660
655661
656 # Operations queue and threads662 # Operations queue and threads
657663
=== modified file 'setup.py'
--- setup.py 2009-08-23 19:12:47 +0000
+++ setup.py 2009-08-26 13:11:35 +0000
@@ -23,43 +23,71 @@
23import os23import os
24from distutils.core import setup24from distutils.core import setup
25from distutils.command.install_data import install_data25from distutils.command.install_data import install_data
26import pwd26try:
27 import pwd
28except ImportError:
29 pwd = None
27import beeseek30import beeseek
2831
2932
30class configure_and_install_data(install_data):33class configure_and_install_data(install_data):
3134
35 def finalize_options(self):
36 if self.install_dir is None:
37 install_cmd = self.distribution.get_command_obj('install')
38 self.install_dir = install_cmd.root or install_cmd.prefix
39 dir_specified = self.install_dir
40 install_data.finalize_options(self)
41 if not dir_specified and os.name != 'nt':
42 self.install_dir = os.path.dirname(install_cmd.prefix)
43
32 def run(self):44 def run(self):
33 data_files = self.data_files = []45 install_dir = self.install_dir
34 dirs_map = {46 if os.name == 'nt':
35 'etc/beeseek': 'config',47 dirs_map = {
36 'var/lib/beeseek/database': 'database',48 'BeeSeek/config': 'config',
37 'usr/share/beeseek/templates': 'templates'49 'BeeSeek/database': 'database',
38 }50 'BeeSeek/webdata': 'webdata'
51 }
52 else:
53 dirs_map = {
54 'etc/beeseek': 'config',
55 'var/lib/beeseek/database': 'database',
56 'usr/share/beeseek/templates': 'templates'
57 }
3958
40 for destination, source in dirs_map.iteritems():59 for destination, source in dirs_map.iteritems():
41 sourcelen = len(source) + 160 destination = os.path.join(install_dir, destination)
61 self.mkpath(destination)
42 for directory, subdirs, subfiles in os.walk(source):62 for directory, subdirs, subfiles in os.walk(source):
43 path = os.path.join(destination, directory[sourcelen:])63 subdirectory = directory[len(source)+1:]
44 subfiles = [os.path.join(directory, filename)64 for subdir in subdirs:
45 for filename in subfiles]65 self.mkpath(
46 data_files.append((path, subfiles))66 os.path.join(destination, subdirectory, subdir))
4767 for file_name in subfiles:
48 install_data.run(self)68 self.copy_file(
49 self.mkpath(os.path.join(self.install_dir, 'etc/init.d'))69 os.path.join(directory, file_name),
50 self.copy_file('beeseek-peer.init',70 os.path.join(destination, subdirectory, file_name))
51 os.path.join(self.install_dir,71
52 'etc/init.d/beeseek-peer'))72 if os.name != 'nt':
53 self.mkpath(os.path.join(self.install_dir, 'var/log/beeseek'))73 self.mkpath(os.path.join(install_dir, 'etc/init.d'))
5474 self.copy_file('beeseek-peer.init',
55 items = pwd.getpwnam('www-data')75 os.path.join(install_dir, 'etc/init.d/beeseek-peer'))
56 uid, gid = items[2], items[3]76 self.mkpath(os.path.join(install_dir, 'var/log/beeseek'))
57 for path in ('var/log/beeseek', 'var/lib/beeseek'):77
58 path = os.path.join(self.install_dir, path)78 if not self.dry_run and pwd:
59 for directory, subdirs, subfiles in os.walk(path):79 items = pwd.getpwnam('www-data')
60 os.chown(directory, uid, gid)80 uid, gid = items[2], items[3]
61 for filename in subfiles:81 for path in ('var/log/beeseek', 'var/lib/beeseek'):
62 os.chown(os.path.join(directory, filename), uid, gid)82 path = os.path.join(install_dir, path)
83 for directory, subdirs, subfiles in os.walk(path):
84 try:
85 os.chown(directory, uid, gid)
86 for filename in subfiles:
87 os.chown(
88 os.path.join(directory, filename), uid, gid)
89 except OSError:
90 pass
6391
6492
65def add_packages(metadata):93def add_packages(metadata):
@@ -68,10 +96,13 @@
68 packages = metadata['packages'] = []96 packages = metadata['packages'] = []
69 for directory, subdirs, subfiles in os.walk(path):97 for directory, subdirs, subfiles in os.walk(path):
70 name = directory[unneeded:].replace(os.path.sep, '.')98 name = directory[unneeded:].replace(os.path.sep, '.')
71 if (name.startswith('beeseek.tests')99 skip = False
72 or name.startswith('beeseek.app.server')):100 for package in exclude_packages:
73 continue101 if name.startswith(package):
74 packages.append(name)102 skip = True
103 break
104 if not skip:
105 packages.append(name)
75106
76def add_description(metadata):107def add_description(metadata):
77 from beeseek.app import peer108 from beeseek.app import peer
@@ -83,6 +114,13 @@
83 metadata['description'] = summary.rstrip('.')114 metadata['description'] = summary.rstrip('.')
84 metadata['long_description'] = description.strip()115 metadata['long_description'] = description.strip()
85116
117exclude_packages = [
118 'beeseek.app.server',
119 'beeseek.docs',
120 'beeseek.testing',
121 'beeseek.tests',
122 ]
123
86metadata = {124metadata = {
87 'name': 'beeseek-peer',125 'name': 'beeseek-peer',
88 'version': beeseek.__version__,126 'version': beeseek.__version__,
89127
=== modified file 'testsuite.py'
--- testsuite.py 2009-08-05 16:40:13 +0000
+++ testsuite.py 2009-08-24 14:52:46 +0000
@@ -130,6 +130,9 @@
130 for test_case in testlist:130 for test_case in testlist:
131 test_case.run(run_dependencies)131 test_case.run(run_dependencies)
132 testing.Logger.finish()132 testing.Logger.finish()
133 if testing.Logger.failures or testing.Logger.errors:
134 sys.exit(1)
135 sys.exit(0)
133136
134137
135if __name__ == '__main__':138if __name__ == '__main__':

Subscribers

People subscribed via source and target branches