/usr/share/pyshared/childsplay_sp/setup.py is in childsplay 1.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2006-2007 Stas Zykiewicz <stas.zytkiewicz@gmail.com>
#
# setup.py
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 3 of the GNU General Public License
# as published by the Free Software Foundation. A copy of this license should
# be included in the file GPL-3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""
------------------------------------------------------------------------------
This script will install childsplay on your system.
All the Python modules are installed in the default Python location on your
system, on most GNU/Linux systems that's '/python/site-packages'.
The rest of the modules and files are installed in /usr/local/childsplay_sp.
You can change the non-python install location by altering the variable called
'PREFIX' inside this script.
(Change it only if you understand why you want to change it)
This script also generate a module with all the paths needed by childsplay.
Childsplay is "fun and games" part of the schoolsplay project and uses many
of the schoolsplay modules. See www.schoolsplay.org, for more info.
This means that sometimes it's possible that certain messages speak of
"schoolsplay", you can just read "childsplay" instead.
-------------------------------------------------------------------------------
"""
import os.path
import sys
# we check for the special 'uninstall' option, other options are handled by
# the distutils stuff.
if sys.argv[1] == 'uninstall':
UNINSTALL = True
print "\n------------ Uninstalling childsplay ----------------\n"
print "I'm going to completely remove childsplay from your system."
ans = raw_input("Hit 'y' to remove childsplay > ")
if ans.lower() != 'y':
print "Operation canceled, leaving childsplay intact."
sys.exit(0)
else:
UNINSTALL = False
print __doc__
raw_input("Hit any key to continue\n")
# Change this if you want to install all the non-python stuff in a different
# location.
PREFIX = '/usr/local'
#PREFIX = '/tmp'
# Don't change anything below this line unless you fully understand why you want
# to make changes.
# This script basically runs from top to bottom.
import Version
try:
import distutils
except ImportError:
raise SystemExit, "childsplay requires distutils (Python-dev) to build and install."
from distutils.core import setup
from distutils.sysconfig import get_python_lib
# Check to see if we have an old cp install
try:
from childsplay_sp import SPBasePaths
except ImportError:
OLDBASEPATHS = False
else:
OLDBASEPATHS = SPBasePaths
import os, glob, shutil
### TODO: WINDOWS STUFF IS UNCHECKED, IT MUST BE CHECKED.
def check_for_windows():
"""Check if we are on Windows, if so return the tuple with the version info.
If not, return None.
Taken from the python docs:
Return a tuple containing five components, describing the Windows version
currently running.
The elements are major, minor, build, platform, and text. text contains a
string while all other values are integers.
platform may be one of the following values:
Constant Platform
0 (VER_PLATFORM_WIN32s) Win32s on Windows 3.1
1 (VER_PLATFORM_WIN32_WINDOWS) Windows 95/98/ME
2 (VER_PLATFORM_WIN32_NT) Windows NT/2000/XP
3 (VER_PLATFORM_WIN32_CE) Windows CE
"""
print " Checking for Windows version..."
try:
winver = sys.getwindowsversion()
except:
print " No Windows found, your must be a sensible person."
return None
else:
print " %s found" % winver[4]
return winver
# from here we setup the non-python stuff and write a module with the paths.
if not UNINSTALL:
print "\n------------ Installing non-python files ------------\n"
ARE_WE_WINDOWS = check_for_windows()
module = 'SPBasePaths.py'
modulepaths = {'ALPHABETDIR':os.path.join(PREFIX, 'share', 'sp_alphabetsounds')}
#--------------- Remove old SPBasePaths
if os.path.exists(module):
print "Found an old %s file, removing it..." % module,
os.remove(module)
print " done"
modulepaths['BASEDIR'] = os.path.join(PREFIX, 'childsplay_sp')
#-------------- copy activity data dirs
# if there's already a FlashcardsData/names dir we back it up as the user can
# have localized names files.
# REMINDER: This can cause trouble when the included English names ever changes.
fcd = os.path.join(PREFIX, 'share', 'childsplay_sp', 'CPData', 'FlashcardsData', 'names')
fcd_back = ""
if os.path.exists(fcd):
print "Found an existing FlashcardsData/names directory used by the Flashcards activity"
print "It can contain localized soundfiles so I will save it and restore it after the"
print "new FlashcardsData directory is installed."
fcd_back = os.path.join(os.getcwd(), 'names_back')
shutil.copytree(fcd, fcd_back)
dest = os.path.join(PREFIX, 'share', 'childsplay_sp')
if os.path.exists(dest):
print "Found an old %s directory, removing it..." % dest,
shutil.rmtree(dest)
print " done"
if not UNINSTALL:
dest = os.path.join(PREFIX, 'share', 'childsplay_sp')
if not os.path.exists(dest):
print "Creating %s..." % dest,
os.makedirs(dest)
modulepaths['SHARELIBDATADIR'] = dest
print " done"
print "Copy childsplay activity data dirs..."
src = os.path.join(os.getcwd(), 'lib')
for sppath in glob.glob(src + os.sep + '*'):
if os.path.isdir(sppath):
name = os.path.basename(sppath)
fdest = os.path.join(dest, name)
print "copy %s to\n %s" % (sppath, fdest)
shutil.copytree(sppath, fdest)
print " done"
# restore the names if any
if fcd_back:
print "restore %s" % fcd
shutil.rmtree(fcd)
shutil.copytree(fcd_back, fcd)
shutil.rmtree(fcd_back)
#----------- copy alphabetsounds dir
if UNINSTALL:
dest = os.path.join(PREFIX, 'share', 'sp_alphabethsounds')
if os.path.exists(dest):
print "Found an old %s directory, removing it..." % dest,
shutil.rmtree(dest)
print " done"
if not UNINSTALL:
# special Python2.4 fix as 2.4 shutil doesn't create complete trees
try:
os.makedirs(os.path.join(PREFIX, 'share', 'sp_alphabetsounds'))
except:
pass
dest = os.path.join(PREFIX, 'share', 'sp_alphabetsounds', 'en')
if os.path.exists(dest):
print "Removing old English alphabetsounds directory"
shutil.rmtree(dest)
print " done"
print "Copy childsplay English alphabetsounds directory..."
src = os.path.join(os.getcwd(), 'alphabetsounds', 'en')
print "copy %s to\n %s" % (src, dest)
shutil.copytree(src, dest)
print " done"
#---------- copy locale dirs
def cleanup( * args):
"""Used by os.path.walk to traverse the locale tree and remove childsplay mo files."""
#print "cleanup:",args
try:
if 'childsplay_sp.mo' in args[2]:
fpath = os.path.join(args[1], 'childsplay_sp.mo')
print "Removed old localization file: %s" % fpath,
os.remove(fpath)
print " done"
except (IndexError, AttributeError):
# empty LC_MESSAGES directory
pass
def install( * args):
#print "install:",args
#if os.path.basename(args[2][0]) == 'childsplay_sp.mo':
if len(args[2]) > 0 and os.path.basename(args[2][0]) == 'childsplay_sp.mo':
fpath = os.path.join(args[1], args[2][0])
dest = os.path.join(args[0], args[1].split('locale' + os.sep)[1])
print "Install localization file in: %s" % dest,
#print "copy",fpath,dest
if not os.path.exists(dest):
os.makedirs(dest)
shutil.copy(fpath, dest)
print " done"
src = os.path.join(os.getcwd(), 'locale')
dest = os.path.join(PREFIX, 'share', 'locale')
print dest
if os.path.exists(dest):
# we must digg through all the locale directories to find any childsplay_sp mo files
# removing the mo files
os.path.walk('%s' % dest, cleanup, None)
if not UNINSTALL:
print "Creating %s..." % dest,
if not os.path.exists(dest):
os.makedirs(dest)
modulepaths['LOCALEDIR'] = dest
print " done"
print "Copy localization files..."
os.path.walk('%s' % src, install, dest)
#---------------- copy docs
###### temp code to remove old named schoolsplay
dest = os.path.join(PREFIX, 'share', 'doc', 'schoolsplay')
if os.path.exists(dest):
print "Found an old %s directory, removing it..." % dest,
shutil.rmtree(dest)
print " done"
##################################
src = os.path.join(os.getcwd(), 'doc')
dest = os.path.join(PREFIX, 'share', 'doc', 'childsplay_sp')
if os.path.exists(dest):
print "Found an old %s directory, removing it..." % dest,
shutil.rmtree(dest)
print " done"
if not UNINSTALL:
print "Creating %s..." % dest,
os.makedirs(dest)
modulepaths['DOCDIR'] = dest
print " done"
print "Copy documentation files..."
for sppath in glob.glob(src + os.sep + '*'):
name = os.path.basename(sppath)
fdest = os.path.join(dest, name)
print "copy %s to\n %s" % (sppath, fdest)
if os.path.isdir(sppath):
shutil.copytree(sppath, fdest)
else:
shutil.copy(sppath, fdest)
#-------- remove old python modules, if any.
if OLDBASEPATHS:
pdest = OLDBASEPATHS.PYTHONCPDIR
else:
pdest = os.path.join(get_python_lib(), 'childsplay_sp')
print "Looking for previous childsplay python install in %s" % pdest
modulepaths['PYTHONCPDIR'] = pdest
if os.path.exists(pdest):
print "Found old childsplay_sp python package in %s, removing it..." % pdest,
shutil.rmtree(pdest)
print " done"
#---------- copy starters
dest = os.path.join(PREFIX, 'bin')
starterpath = os.path.join(dest, 'childsplay_sp')
if os.path.exists(starterpath):
print "Found an old %s file, removing it..." % starterpath,
os.remove(starterpath)
print " done"
starterpath = os.path.join(dest, 'cognitionplay')
if os.path.exists(starterpath):
print "Found an old %s file, removing it..." % starterpath,
os.remove(starterpath)
print " done"
if not UNINSTALL:
print "Install childsplay programs..."
src = os.path.join(os.getcwd(), 'bin')
if not os.path.exists(dest):
print "Creating %s..." % dest
os.makedirs(dest)
for sppath in glob.glob(src + os.sep + '*'):
name = os.path.basename(sppath)
print "copy %s to\n %s" % (sppath, dest)
shutil.copy(sppath, dest)
# all the uninstalling is done so we check if we should stop now
if UNINSTALL:
print "childsplay IS REMOVED"
print "Bye..."
sys.exit(0)
# check where we will install python stuff, needed for the SPBasePaths file.
if not os.path.exists('/usr/lib/python2.6/site-packages') and os.path.exists('/usr/local/lib/python2.6/dist-packages'):
print "Not found destination path: %s" % '/usr/local/lib/python2.6/site-packages'
print "This is a known problem on some Debian based systems like Ubuntu 9.04 and newer."
print "If your not on a Debian based system, please inform the childsplay developers"
modulepaths['PYTHONCPDIR'] = '/usr/local/lib/python2.6/dist-packages/childsplay_sp'
print "Using %s as the install path" % modulepaths['PYTHONCPDIR']
# write the paths module. This file is placed inside the sourcetree and the
# python installer will also install it.
# Add the path to the childsplay_sp python libs. This is needed when we write
# the starter script.
if ARE_WE_WINDOWS:
src = os.path.join(os.getcwd(), 'windows', 'SPBasePaths.py')
dest = os.getcwd()
shutil.copy(src, dest)
else:
print "Writing the SPBasePaths module...",
filelines = ["# AUTO-GENERATED MODULE, DON'T EDIT", \
"# This module holds all the paths needed for childsplay_sp.\n"]
for k, v in modulepaths.items():
filelines.append("%s = '%s'" % (k, v))
f = open(module, 'w')
f.write("\n".join(filelines))
f.close()
print "done"
# Here we start installing the Python modules
print "\n------------- Installing Python modules ------------------\n"
# add a quiet commandline option to supress all the "compile to" crap
sys.argv.insert(1, '--quiet')
DESCRIPTION = """childsplay is a collection of educational activities and
comes with extensive data collecting and multi user support."""
VERSION = Version.version
print "Installing new childsplay_sp python package..."
print "Installing childsplay_sp ocempgui..."
setup(name="childsplay_sp",
version=VERSION,
license="GPL",
url="http://schoolsplay.sf.net",
author="Stas Zytkiewicz",
author_email="stas.zytkiewicz@gmail.com",
description="Collection of educational activities",
long_description=DESCRIPTION,
packages=['childsplay_sp', 'childsplay_sp.gui', 'childsplay_sp.lib', \
'childsplay_sp.ocempgui', \
'childsplay_sp.ocempgui.access', 'childsplay_sp.ocempgui.draw', \
'childsplay_sp.ocempgui.events', 'childsplay_sp.ocempgui.object', \
'childsplay_sp.ocempgui.widgets', \
'childsplay_sp.ocempgui.widgets.components', \
'childsplay_sp.ocempgui.widgets.images', \
'childsplay_sp.ocempgui.widgets.themes', \
'childsplay_sp.ocempgui.widgets.themes.default'],
package_dir={'childsplay_sp':''}
)
print "All done"
#--------------- Remove generated SPBasePaths
if os.path.exists(module):
print "\nRemoving from the sourcedir %s ..." % module,
os.remove(module)
print "Installation finished"
print "\n====== all done ======"
print "childsplay is installed in %s" % starterpath
print "To start childsplay just type 'childsplay' in a xterm"
print "To see the available commandline options type 'childsplay --help in a xterm\n"
|