~ubuntu-branches/debian/squeeze/screenlets/squeeze

1 by Julien Lavergne
Import upstream version 0.0.10
1
#
2
# INFO: The setup-script for the screenlets
3
#
4
# (c) RYX (Rico Pfaus) 2007 ...
5
#
6
7
from distutils.core import setup
8
import os
9
import sys
10
11
# import screenlets to get package constants (like path/prefix)
12
#sys.path.insert(0, 'src/')
13
#import lib	# screenlets-package called 'lib' here because of the dir-names
14
15
16
17
#----------------------------------------------------------------------------
18
# CONFIGURATION
19
#----------------------------------------------------------------------------
20
21
# install prefix (if you want to change this, change it in src/lib/__init__.py)
22
INSTALL_PREFIX	= '/usr/local'
23
# global install-path for daemon and screenlets-packages
24
INSTALL_PATH	= INSTALL_PREFIX + '/share/screenlets'
25
# current version of package
26
VERSION			= '0.0.10'
27
28
#----------------------------------------------------------------------------
29
# FUNCTIONS
30
#----------------------------------------------------------------------------
31
32
def filter_filename_callback(filename):
33
	"""Called by make_file_list to determine which files to add/install 
34
	to the package and which files are to be ignored."""
35
	# skip temp-files
36
	if filename[-1] == '~':
37
		return False
38
	return True
39
	
40
def scan_dir_list(path):
41
	"""makes a list of all subdirectories of a path"""
42
	out = []
43
	plen = len(path) + 1
44
	files = os.listdir(path)
45
	for f in files:
46
		full = path + '/' + f
47
		if (os.path.isdir(full)):
48
			out.append(full)
49
			out.extend(scan_dir_list(full))
50
	return out
51
52
def make_file_list(dirlist, install_path, strip=''):
53
	"""Takes a list with dirnames and creates a list suitable for the 
54
	data_files-attribute for the setup-function that includes all files 
55
	within the dir. The string defined by strip will be replaced from 
56
	within the directory names. TODO: the strip-arg is not very secure 
57
	and could cause errors ... fix that!!!!!!!!!! """
58
	data_files = []
59
	for d in dirlist:
60
		dlst = []
61
		files = os.listdir(d)
62
		for f in files:
63
			full = d +'/' + f
64
			if os.path.isfile(full):
65
				if filter_filename_callback(f):
66
					dlst.append(full)
67
		data_files.append((install_path + '/' + d.replace(strip, ''), dlst))
68
	return data_files
69
70
71
72
#----------------------------------------------------------------------------
73
# RUN SETUP
74
#----------------------------------------------------------------------------
75
76
# + Create list with additional files to be installed (passed as 
77
#   data_files-attribute to setup-function):
78
79
# - screenlets-subdirs and all their data go into INSTALL_PATH/<name>/...
80
dirlist		= scan_dir_list('src/share/screenlets')
81
files_list	= make_file_list(dirlist, INSTALL_PATH, 
82
	strip='src/share/screenlets/')	# to strip this string from filenames
83
84
# - our pseudo-"binaries" go into INSTALL_PREFIX/bin
85
files_list.insert(0, (INSTALL_PREFIX + '/bin', ['bin/screenletsd']))
86
files_list.insert(0, (INSTALL_PREFIX + '/bin', ['bin/screenlets-manager']))
87
files_list.insert(0, (INSTALL_PREFIX + '/bin', ['bin/screenlets-packager']))
88
89
# - the manager and its files go into INSTALL_PATH + '-manager'
90
files_list.insert(0, (INSTALL_PATH + '-manager', 
91
	['src/share/screenlets-manager/screenlets-manager.py',
92
	'src/share/screenlets-manager/screenlets-daemon.py',
93
	'src/share/screenlets-manager/screenlets-packager.py',
94
	'src/share/screenlets-manager/noimage.svg']))
95
	
96
# + Call setup function (installs screenlets into python's root)
97
setup(name = 'screenlets',
98
	# metainfo for this package
99
	version			= VERSION,
100
	author			= 'RYX (Rico Pfaus)',
101
	author_email	= 'ryx@ryxperience.com',
102
	url				= 'http://www.screenlets.org',
103
	license			= 'GPL v3',
104
	description		= 'Screenlets - widget-like mini-applications combining '+\
105
		'usability and eye-candy on the modern, composited Linux-desktop.',
106
	# packages (go into python-packages and become globally available)
107
	packages		= ['screenlets'],
108
	package_dir		= {'screenlets': 'src/lib'},
109
	# additional files to be installed
110
	data_files		= files_list
111
	)
112