annotate SConstruct @ 11:4706e0194af3

Various improvements to the build process including support for self-contained builds. * Note that despite all of these changes PARPG still does not run because asset paths are not standardized, * Modified the SCons script so that by default running `scons` with no arguments creates a self-contained "build" under a build subdirectory to make in-source testing easier. To install PARPG, use `scons install` instead. * Got rid of the binary launcher and replaced it with a shell script for unix and a batch script for Windows (batch script is untested). The binary turned out to be too much trouble to maintain. * Modified the parpg.settings module and parpg.main entry script so that PARPG searches through several default search paths for configuration file(s). PARPG thus no longer crashes if it can't find a configuration file in any particular search path, but will crash it if can't find any configuration files. * Paths supplied to parpg.main are now appended as search paths for the configuration file(s). * Changed the default configuration file name to "parpg.cfg" to simplify searches. * Created the site_scons directory tree where SCons extensions and tools should be placed. * Created a new SCons builder, CopyRecurse, which can copy only certain files and folders from a directory tree using filters (files and folders that start with a leading dot "." e.g. ".svn" are ignored by default). * Added the CPython SCons tool (stands for Compile-Python - I didn't name it!), which provides the InstallPython builder for pre-compiling python sources before they are installed. However, it is currently broken and only installs the python sources.
author M. George Hansen <technopolitica@gmail.com>
date Tue, 31 May 2011 02:46:20 -0700
parents dd4ed4945411
children d60f1dab8469
rev   line source
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
1 import sys
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
2 import os
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
3 import platform
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
4 import compileall
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
5 import fnmatch
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
6 from copy import copy
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
7 from collections import Sequence
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
8 from types import StringType
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
9 from multiprocessing import cpu_count
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
10
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
11 from SCons.Util import is_Sequence, is_Dict
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
12 from SCons.Tool.install import copyFunc
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
13
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
14 #def recursive_glob(topdir_path, include_pattern='*', exclude_pattern=''):
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
15 # """
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
16 # Locate all files matching supplied filename pattern in and below
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
17 # supplied root directory.
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
18 # """
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
19 # for dir_path, subdir_names, file_names in \
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
20 # os.walk(os.path.abspath(topdir_path)):
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
21 # for file_name in fnmatch.filter(file_names, include_pattern):
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
22 # if not fnmatch.fnmatch(file_name, exclude_pattern):
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
23 # file_path = os.path.join(dir_path, file_name)
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
24 # yield File(file_path)
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
25 # for subdir_name in copy(subdir_names):
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
26 # if not fnmatch.fnmatch(subdir_name, include_pattern) or \
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
27 # fnmatch.fnmatch(subdir_name, exclude_pattern):
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
28 # subdir_names.remove(subdir_name)
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
29 # else:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
30 # subdir_path = os.path.join(dir_path, subdir_name)
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
31
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
32 def InstallChmod(env, dest, source, mode):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
33 targets = env.Install(dest, source)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
34 for target in targets:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
35 env.AddPostAction(target, Chmod(target, mode))
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
36 return targets
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
37
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
38 def InstallExecutable(env, dest, source):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
39 return env.InstallChmod(dest, source, mode=0755)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
40
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
41 def InstallReadOnly(env, dest, source):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
42 if not isinstance(source, Sequence):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
43 source = [source]
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
44 targets = []
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
45 for entry in map(Entry, source):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
46 entry.disambiguate()
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
47 if entry.isdir():
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
48 target = env.InstallChmod(dest, entry, mode=0755)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
49 elif entry.isfile():
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
50 target = env.InstallChmod(dest, entry, mode=0644)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
51 else:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
52 # Something really weird happened and entry is not a Dir or a
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
53 # File... (Note: Yes this can happen!)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
54 error_message = \
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
55 'expected entry to be a Dir or a File, but got {0!r}'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
56 raise ValueError(error_message.format(entry))
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
57 targets.append(target)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
58 return targets
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
59
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
60 def SubstfileEscape(env, *args, **kwargs):
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
61 subst_dict = kwargs.get('SUBST_DICT') or env.get('SUBST_DICT')
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
62 escape_sequences = kwargs.get('ESCAPE_SEQUENCES') or env.get('ESCAPE_SEQUENCES')
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
63 if subst_dict is not None and escape_sequences is not None:
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
64 if not is_Dict(subst_dict) and is_Sequence(subst_dict):
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
65 subst_dict = dict(subst_dict)
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
66 else:
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
67 error_message = 'SUBST_DICT must be dict or sequence'
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
68 raise SCons.Errors.UserError(error_message)
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
69 escaped_subst_dict = {}
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
70 for key, value in subst_dict.items():
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
71 escaped_value = value
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
72 for seq, escaped_seq in escape_sequences.items():
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
73 escaped_value = escaped_value.replace(seq, escaped_seq)
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
74 escaped_subst_dict[key] = escaped_value
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
75 kwargs['SUBST_DICT'] = escaped_subst_dict
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
76
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
77 target = env.Substfile(*args, **kwargs)
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
78 return target
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
79
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
80 AddMethod(Environment, InstallChmod)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
81 AddMethod(Environment, InstallExecutable)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
82 AddMethod(Environment, InstallReadOnly)
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
83 AddMethod(Environment, SubstfileEscape)
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
84
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
85 EnsurePythonVersion(2, 6)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
86
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
87 AddOption(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
88 '--stand-alone',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
89 dest='stand_alone',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
90 action='store_true',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
91 default=False,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
92 help='install the entire program under installation prefix instead of in '
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
93 'various system folders'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
94 )
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
95 AddOption(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
96 '--no-compile',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
97 dest='compile',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
98 action='store_false',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
99 default=True,
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
100 help='don\'t compile any Python modules into .pyc files before installing',
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
101 )
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
102 SetOption('num_jobs', cpu_count())
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
103
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
104 def is_abs_path(key, val, env):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
105 if not os.path.isabs(val):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
106 error_message = '${key} must be an absolute path'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
107 raise ValueError(error_message.format(key=key))
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
108 env[key] = os.path.normpath(val)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
109
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
110 variables = Variables()
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
111 # NOTE M. George Hansen 2011-05-13: Path variables are based on the GNU
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
112 # standards as defined at http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
113
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
114 # Platform-specific variable defaults.
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
115 # FIXME M. George Hansen 2011-05-12: Define the MacOS-specific
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
116 # environmental variables (and check version...)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
117 platform_name = platform.system()
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
118 if platform_name in ['Linux', 'MacOS']:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
119 if GetOption('stand_alone'):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
120 PREFIX_DEFAULT = '/opt'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
121 else:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
122 PREFIX_DEFAULT = '/usr/local'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
123 BIN_DIR_DEFAULT = '$EXEC_PREFIX/bin'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
124 DATA_ROOT_DIR_DEFAULT = '$PREFIX/share/$PROJECT_NAME'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
125 SYS_CONF_DIR_DEFAULT = '$PREFIX/etc/$PROJECT_NAME'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
126 INCLUDE_DIR_DEFAULT = '$PREFIX/include/$PROJECT_NAME'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
127 DOC_DIR_DEFAULT = '$DATA_ROOT_DIR/doc/$PROJECT_NAME'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
128 LIB_DIR_DEFAULT = '$EXEC_PREFIX/lib'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
129 dist_name, dist_version, dist_id = \
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
130 platform.linux_distribution(full_distribution_name=False)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
131 if dist_name in ['debian', 'Ubuntu']:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
132 # Debian uses dist-packages instead of site-packages for Python
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
133 # versions > 2.5.
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
134 PY_PACKAGES_DIR_DEFAULT = '$EXEC_PREFIX/lib/python$PY_VERSION_SHORT/' \
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
135 'dist-packages'
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
136 else:
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
137 PY_PACKAGES_DIR_DEFAULT = '$EXEC_PREFIX/lib/python$PY_VERSION_SHORT/' \
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
138 'site-packages'
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
139 PY_HEADERS_DIR_DEFAULT = '/usr/include/python$PY_VERSION_SHORT'
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
140 PY_LIB_DIR_DEFAULT = '/usr/lib'
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
141 PY_LIB_NAME = 'python$PY_VERSION_SHORT'
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
142 elif platform_name == 'Windows':
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
143 try:
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
144 PREFIX_DEFAULT = os.environ['PROGRAMFILES'] + r'\$PROGRAM_NAME'
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
145 except KeyError:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
146 PREFIX_DEFAULT = ''
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
147 error_message = '%PROGRAMFILES% environmental variable is not ' \
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
148 'set, unable to determine path to Program Files ' \
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
149 'folder'
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
150 raise SConfWarning(error_message)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
151 BIN_DIR_DEFAULT = '$EXEC_PREFIX'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
152 DATA_ROOT_DIR_DEFAULT = '$PREFIX/data'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
153 SYS_CONF_DIR_DEFAULT = '$PREFIX/config'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
154 INCLUDE_DIR_DEFAULT = '$PREFIX/include'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
155 DOC_DIR_DEFAULT = '$PREFIX/doc/'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
156 LIB_DIR_DEFAULT = '$EXEC_PREFIX/lib'
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
157 # FIXME M. George Hansen 2011-05-12: Does sys.prefix include the
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
158 # PythonX.Y part on Windows?
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
159 python_prefix = sys.prefix
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
160 if GetOption('stand_alone'):
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
161 PY_PACKAGES_DIR_DEFAULT = '$PREFIX/lib'
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
162 else:
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
163 PY_PACKAGES_DIR_DEFAULT = \
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
164 os.path.join(python_prefix, 'Lib', 'site-packages')
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
165 PY_HEADERS_DIR_DEFAULT = os.path.join(python_prefix, 'include')
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
166 PY_LIB_DIR_DEFAULT = os.path.join(python_prefix, 'libs')
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
167 PY_LIB_NAME = 'python$PY_VERSION_MAJOR$PY_VERSION_MINOR'
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
168
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
169 # Platform-independant variables:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
170 variables.AddVariables(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
171 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
172 'PREFIX',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
173 'directory under which most or all of the program components should '
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
174 'be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
175 PREFIX_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
176 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
177 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
178 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
179 'EXEC_PREFIX',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
180 'directory under which machine-specific compiled libraries and '
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
181 'objects should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
182 '$PREFIX',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
183 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
184 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
185 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
186 'BIN_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
187 'directory where program executables should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
188 BIN_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
189 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
190 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
191 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
192 'DATA_ROOT_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
193 'directory under which read-only, architecture-independant data files '
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
194 'should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
195 DATA_ROOT_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
196 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
197 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
198 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
199 'DATA_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
200 'directory where read-only, architecture-independant data files '
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
201 'should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
202 '$DATA_ROOT_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
203 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
204 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
205 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
206 'SYS_CONF_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
207 'directory where read-only, machine-specific data files should be '
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
208 'installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
209 SYS_CONF_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
210 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
211 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
212 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
213 'INCLUDE_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
214 'directory where C/C++ header files should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
215 INCLUDE_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
216 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
217 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
218 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
219 'DOC_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
220 'directory where program documentation should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
221 DOC_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
222 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
223 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
224 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
225 'LIB_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
226 'directory where platform-dependant, compiled library and object '
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
227 'files should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
228 LIB_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
229 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
230 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
231 PathVariable(
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
232 'PY_PACKAGES_DIR',
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
233 'directory where pure Python modules and packages should be installed',
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
234 PY_PACKAGES_DIR_DEFAULT,
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
235 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
236 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
237 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
238 'INCLUDE_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
239 'directory where C/C++ header files should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
240 INCLUDE_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
241 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
242 ),
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
243 PathVariable(
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
244 'PY_HEADERS_DIR',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
245 'directory where Python.h can be found',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
246 PY_HEADERS_DIR_DEFAULT,
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
247 ),
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
248 PathVariable(
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
249 'PY_LIB_DIR',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
250 'directory where the Python shared library can be found',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
251 PY_LIB_DIR_DEFAULT,
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
252 ),
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
253 BoolVariable(
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
254 'DEBUG',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
255 'if True, compile the program launcher executable with debugging '
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
256 'symbols',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
257 False,
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
258 ),
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
259 )
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
260
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
261 python_version_tuple = platform.python_version_tuple()
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
262
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
263 environment = Environment(
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
264 tools=['default', 'cpython', 'copyrecurse', 'textfile', 'packaging'],
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
265 variables=variables,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
266 PROJECT_NAME='parpg',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
267 PROJECT_VERSION_MAJOR=0,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
268 PROJECT_VERSION_MINOR=2,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
269 PROJECT_VERSION_PATCH=0,
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
270 PROJECT_VERSION_SHORT='${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MAJOR}',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
271 PROJECT_VERSION_LONG='${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.'
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
272 '${PROJECT_VERSION_PATCH}',
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
273 PYTHON=sys.executable,
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
274 PY_VERSION_MAJOR=python_version_tuple[0],
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
275 PY_VERSION_MINOR=python_version_tuple[1],
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
276 PY_VERSION_PATCH=python_version_tuple[2],
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
277 PY_VERSION_SHORT='${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
278 PY_VERSION_LONG='${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}.'
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
279 '${PY_VERSION_PATCH}',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
280 PY_LIB_NAME=PY_LIB_NAME,
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
281 BUILD_DIR='build',
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
282 )
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
283 if environment['DEBUG']:
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
284 if platform_name == 'Windows':
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
285 environment['CCPDBFLAGS'] = '/Z7 /Od'
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
286 environment.AppendUnique(LINKFLAGS='/DEBUG')
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
287 else:
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
288 environment.AppendUnique(CCFLAGS=['-gdwarf-2', '-g3'])
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
289
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
290 Help(variables.GenerateHelpText(environment))
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
291
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
292 config_dict = [('@{0}@'.format(key), environment.Dictionary()[key]) for key in
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
293 ('PREFIX', 'LIB_DIR', 'PY_PACKAGES_DIR', 'BIN_DIR',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
294 'SYS_CONF_DIR', 'DATA_DIR', 'PYTHON')]
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
295
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
296 copy_py_packages = environment.Install(
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
297 '$BUILD_DIR',
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
298 'src/parpg',
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
299 )
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
300 install_py_packages = environment.InstallPython(
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
301 '$PY_PACKAGES_DIR',
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
302 copy_py_packages,
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
303 PYTHON_COMPILE=GetOption('compile'),
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
304 )
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
305
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
306 copy_data = environment.CopyRecurse(
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
307 '$BUILD_DIR',
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
308 'data',
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
309 )
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
310
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
311 subst_config_file = environment.Substfile(
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
312 '$BUILD_DIR/parpg.cfg',
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
313 'parpg.cfg.in',
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
314 SUBST_DICT=config_dict,
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
315 )
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
316 install_config_files = environment.InstallChmod(
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
317 '$SYS_CONF_DIR',
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
318 subst_config_file,
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
319 mode=0755,
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
320 )
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
321 Requires(install_config_files, subst_config_file)
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
322
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
323 if platform_name == 'Windows':
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
324 launcher_name = 'parpg.bat'
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
325 else:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
326 launcher_name = 'parpg.sh'
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
327 # FIXME M. George Hansen 2011-05-20: Do any other sequences need to be escaped?
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
328 launcher = environment.SubstfileEscape(
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
329 'build/$LAUNCHER_NAME',
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
330 'bin/${LAUNCHER_NAME}.in',
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
331 LAUNCHER_NAME=launcher_name,
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
332 SUBST_DICT=config_dict,
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
333 ESCAPE_SEQUENCES={'\\': r'\\\\', '"': r'\\"'},
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
334 )
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
335 if platform_name == 'Windows':
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
336 install_launcher = environment.InstallExecutable(
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
337 '$BIN_DIR',
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
338 launcher,
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
339 )
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
340 else:
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
341 # Remove the .sh suffix, since it isn't needed on unix platforms.
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
342 install_launcher = environment.InstallAs(
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
343 '$BIN_DIR/parpg',
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
344 launcher,
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
345 )
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
346
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
347 # TODO M. George Hansen 2011-05-12: Implement package builder.
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
348 #package = environment.Package(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
349 # NAME='parpg',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
350 # VERSION='0.2.0',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
351 # PACKAGEVERSION=0,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
352 # LICENSE='gpl',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
353 # SUMMARY='',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
354 # DESCRIPTION='',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
355 # X_RPM_GROUP='Application/parpg',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
356 #)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
357
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
358 build = Alias('build', [launcher, subst_config_file, copy_py_packages,
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
359 copy_data])
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
360 install = Alias('install', [build, install_launcher, install_py_packages,
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
361 install_config_files])
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
362
11
4706e0194af3 Various improvements to the build process including support for self-contained builds.
M. George Hansen <technopolitica@gmail.com>
parents: 6
diff changeset
363 Default(build)