annotate SConstruct @ 10:5deaf494934a

Reverted accidental edit of .hgsub which caused the parpg-assets subrepo to hang on update. * Changed https:// entry back to http:// for parpg-assets.
author M. George Hansen <technopolitica@gmail.com>
date Wed, 01 Jun 2011 00:45:27 -0700
parents dd4ed4945411
children 4706e0194af3
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
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
6 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
7 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
8 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
9
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
10 from SCons.Util import is_Sequence, is_Dict
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
11
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
12 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
13 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
14 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
15 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
16 return targets
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
17
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
18 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
19 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
20
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
21 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
22 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
23 source = [source]
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
24 targets = []
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
25 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
26 entry.disambiguate()
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
27 if entry.isdir():
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
28 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
29 elif entry.isfile():
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
30 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
31 else:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
32 # 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
33 # 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
34 error_message = \
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
35 '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
36 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
37 targets.append(target)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
38 return targets
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
39
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
40 def InstallPyPackages(env, dest, source, compile=True):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
41 # Remove all existing *.pyc and *.pyo files for a sanitary install
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
42 # environment.
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
43 def _remove_compiled_modules(path):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
44 for dir_path, dir_names, file_names in os.walk(path):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
45 for file_name in fnmatch.filter(file_names, '*.py[co]'):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
46 file_path = os.path.join(dir_path, file_name)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
47 os.remove(file_path)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
48
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
49 def _add_targets(path):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
50 for dir_path, dir_names, file_names in os.walk(path):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
51 for file_name in fnmatch.filter(file_names, '*.py[co]'):
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
52 file_path = os.path.join(dir_path, file_name)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
53 env.Clean(path, file_path)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
54 source_file_path = file_path.rstrip('oc')
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
55 env.Depends(file_path, source_file_path)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
56
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
57 if not isinstance(source, Sequence) or isinstance(source, StringType):
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
58 source = [source]
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
59 for dir in source:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
60 _remove_compiled_modules(str(dir))
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
61 if compile:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
62 compileall.compile_dir(str(dir), ddir=str(dest), force=True)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
63 _add_targets(str(dir))
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
64 targets = env.InstallReadOnly(dest, source)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
65 return targets
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
66
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
67 def SubstfileEscape(env, *args, **kwargs):
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
68 subst_dict = kwargs.get('SUBST_DICT') or env.get('SUBST_DICT')
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
69 escape_sequences = kwargs.get('ESCAPE_SEQUENCES') or env.get('ESCAPE_SEQUENCES')
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
70 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
71 if not is_Dict(subst_dict) and is_Sequence(subst_dict):
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
72 subst_dict = dict(subst_dict)
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
73 else:
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
74 error_message = 'SUBST_DICT must be dict or sequence'
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
75 raise SCons.Errors.UserError(error_message)
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
76 escaped_subst_dict = {}
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
77 for key, value in subst_dict.items():
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
78 escaped_value = value
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
79 for seq, escaped_seq in escape_sequences.items():
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
80 escaped_value = escaped_value.replace(seq, escaped_seq)
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
81 escaped_subst_dict[key] = escaped_value
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
82 kwargs['SUBST_DICT'] = escaped_subst_dict
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
83
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
84 target = env.Substfile(*args, **kwargs)
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
85 return target
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
86
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
87 AddMethod(Environment, InstallChmod)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
88 AddMethod(Environment, InstallExecutable)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
89 AddMethod(Environment, InstallReadOnly)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
90 AddMethod(Environment, InstallPyPackages)
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
91 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
92
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
93 EnsurePythonVersion(2, 6)
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 '--stand-alone',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
97 dest='stand_alone',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
98 action='store_true',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
99 default=False,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
100 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
101 'various system folders'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
102 )
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
103 AddOption(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
104 '--no-compile',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
105 dest='compile',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
106 action='store_false',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
107 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
108 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
109 )
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
110 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
111
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
112 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
113 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
114 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
115 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
116 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
117
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
118 variables = Variables()
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
119 # 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
120 # 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
121
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
122 # 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
123 # 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
124 # 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
125 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
126 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
127 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
128 PREFIX_DEFAULT = '/opt'
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
129 else:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 # 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
141 # 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
142 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
143 'dist-packages'
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
144 else:
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
145 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
146 'site-packages'
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
147 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
148 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
149 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
150 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
151 try:
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
152 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
153 except KeyError:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
154 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
155 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
156 '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
157 'folder'
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 # 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
166 # 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
167 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
168 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
169 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
170 else:
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
171 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
172 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
173 PY_HEADERS_DIR_DEFAULT = os.path.join(python_prefix, 'include')
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
174 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
175 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
176
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
177 # Platform-independant variables:
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
178 variables.AddVariables(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
179 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
180 'PREFIX',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
181 '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
182 'be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
183 PREFIX_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
184 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
185 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
186 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
187 'EXEC_PREFIX',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
188 '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
189 '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
190 '$PREFIX',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
191 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
192 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
193 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
194 'BIN_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
195 '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
196 BIN_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
197 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
198 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
199 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
200 'DATA_ROOT_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
201 '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
202 'should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
203 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
204 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
205 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
206 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
207 'DATA_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
208 '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
209 'should be installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
210 '$DATA_ROOT_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
211 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
212 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
213 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
214 'SYS_CONF_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
215 '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
216 'installed',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
217 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
218 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
219 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
220 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
221 'INCLUDE_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
222 '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
223 INCLUDE_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
224 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
225 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
226 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
227 'DOC_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
228 '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
229 DOC_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
230 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
231 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
232 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
233 'LIB_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
234 '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
235 '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
236 LIB_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
237 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
238 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
239 PathVariable(
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
240 '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
241 '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
242 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
243 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
244 ),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
245 PathVariable(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
246 'INCLUDE_DIR',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
247 '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
248 INCLUDE_DIR_DEFAULT,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
249 is_abs_path,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
250 ),
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
251 PathVariable(
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
252 '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
253 '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
254 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
255 ),
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
256 PathVariable(
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
257 '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
258 '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
259 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
260 ),
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
261 BoolVariable(
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
262 'DEBUG',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
263 '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
264 'symbols',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
265 False,
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
266 ),
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
267 )
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
268
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
269 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
270
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
271 environment = Environment(
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
272 tools=['default', 'textfile', 'packaging'],
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
273 variables=variables,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
274 PROJECT_NAME='parpg',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
275 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
276 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
277 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
278 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
279 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
280 '${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
281 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
282 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
283 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
284 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
285 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
286 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
287 '${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
288 PY_LIB_NAME=PY_LIB_NAME,
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
289 PY_PACKAGES=[],
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
290 CONFIG_FILES=[],
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
291 DATA_FILES=[],
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
292 EXECUTABLES=[],
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
293 )
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
294 if environment['DEBUG']:
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
295 if platform_name == 'Windows':
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
296 environment['CCPDBFLAGS'] = '/Z7 /Od'
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
297 environment.AppendUnique(LINKFLAGS='/DEBUG')
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
298 else:
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
299 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
300
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
301 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
302
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
303 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
304 ('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
305 '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
306
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
307 install_py_packages = environment.InstallPyPackages(
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
308 '$PY_PACKAGES_DIR',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
309 'src/parpg',
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
310 compile=GetOption('compile'),
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
311 )
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
312
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
313 subst_config_file = environment.Substfile(
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
314 'system.cfg.in',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
315 SUBST_DICT=config_dict
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
316 )
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
317 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
318 '$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
319 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
320 mode=0755
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
321 )
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
322 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
323
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
324 install_data = environment.InstallReadOnly(
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
325 '$DATA_DIR',
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
326 Glob('data/*'),
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
327 )
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
328
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
329 # FIXME M. George Hansen 2011-05-20: Do any other sequences need to be escaped
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
330 # in a C string?
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
331 executable_source = environment.SubstfileEscape(
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
332 'bin/parpg.c.in',
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
333 SUBST_DICT=config_dict,
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
334 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
335 )
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
336 build_executable = environment.Program(
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
337 executable_source,
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
338 LIBS=['$PY_LIB_NAME'],
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
339 LIBPATH='$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
340 CPPPATH=['$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
341 )
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
342 # Clean up any files created by the MSVC compiler on Windows.
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
343 if platform_name == 'Windows':
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
344 environment.Clean(build_executable, 'bin/parpg.ilk')
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
345 environment.Clean(build_executable, 'bin/parpg.pdb')
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
346 install_executable = environment.InstallExecutable(
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
347 '$BIN_DIR',
6
dd4ed4945411 Ported binary launcher to Windows.
M. George Hansen
parents: 5
diff changeset
348 build_executable,
2
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
349 )
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
350
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
351 # 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
352 #package = environment.Package(
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
353 # NAME='parpg',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
354 # 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
355 # PACKAGEVERSION=0,
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
356 # LICENSE='gpl',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
357 # SUMMARY='',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
358 # DESCRIPTION='',
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
359 # 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
360 #)
e2a8e3805b04 Made parpg-core the main repository to pull from and build.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
361
5
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
362 build = Alias('build', [build_executable])
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
363 install = Alias('install', [build, install_executable, install_py_packages,
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
364 install_config_files, install_data])
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
365
33684971cdb1 Replaced the shell script launcher with a cross-platform C executable.
M. George Hansen <technopolitica@gmail.com>
parents: 2
diff changeset
366 Default(install)