3
3
""" Distutils Extensions needed for the mx Extensions.
5
5
Copyright (c) 1997-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
6
Copyright (c) 2000-2003, eGenix.com Software GmbH; mailto:info@egenix.com
6
Copyright (c) 2000-2004, eGenix.com Software GmbH; mailto:info@egenix.com
7
7
See the documentation for further information on copyrights,
8
8
or contact the author. All Rights Reserved.
12
# 2.1.2: added wide Unicode support
12
13
# 2.1.1: added support for Python 2.3 way of finding MSVC paths
13
14
# 2.1.0: added bdist_zope, support for classifiers
14
15
# 2.0.0: reworked the include and lib path logic; factored out the
103
104
index = index + len(pathlist) + 1
104
105
pathlist.insert(index, dir)
107
def py_version(unicode_aware=1, include_patchlevel=0):
109
""" Return the Python version as short string.
111
If unicode_aware is true (default), the function also tests
112
whether a UCS2 or UCS4 built is running and modifies the
115
If include_patchlevel is true (default is false), the patch
116
level is also included in the version string.
119
if include_patchlevel:
120
version = sys.version[:5]
122
version = sys.version[:3]
123
if unicode_aware and version > '2.0':
130
version = version + 'ucs4'
133
def check_zope_product_version(version, version_txt):
135
""" Check whether the version string version matches the
136
version data in the Zope product version.txt file
140
data = open(version_txt, 'r').read().strip()
141
return data[-len(version):] == version
106
143
def mx_customize_compiler(compiler):
108
145
# Allow environment variables to override settings in the
109
146
# Python Makefile on Unix; this overrides
110
147
# distutils.sysconfig.customize_compiler()
111
148
if compiler.compiler_type == "unix":
112
cc, opt, ccshared, ldshared, so = \
113
get_config_vars('CC', 'OPT', 'CCSHARED', 'LDSHARED', 'SO')
114
cc = os.environ.get('CC', cc)
115
opt = os.environ.get('OPT', opt)
116
ccshared = os.environ.get('CCSHARED', ccshared)
117
ldshared = os.environ.get('LDSHARED', ldshared)
118
so = os.environ.get('SO', so)
149
# Note: BASECFLAGS is new in Python 2.3; thanks to
150
# David M. Cooke for pointing this out to us.
151
cc, opt, ccshared, basecflags, ldshared, so = \
152
get_config_vars('CC', 'OPT', 'BASECFLAGS', 'CCSHARED',
154
cc = os.environ.get('CC', cc or '')
155
opt = os.environ.get('OPT', opt or '')
156
basecflags = os.environ.get('BASECFLAGS', basecflags or '')
157
ccshared = os.environ.get('CCSHARED', ccshared or '')
158
ldshared = os.environ.get('LDSHARED', ldshared or '')
159
so = os.environ.get('SO', so or '')
119
160
compiler.set_executables(
120
161
preprocessor='%s -E' % cc,
121
compiler='%s %s' % (cc, opt),
122
compiler_so='%s %s %s' % (cc, opt, ccshared),
162
compiler='%s %s %s' % (cc, opt, basecflags),
163
compiler_so='%s %s %s %s' % (cc, opt, ccshared, basecflags),
123
164
linker_so=ldshared,
125
166
compiler.shared_lib_extension = so
283
324
# Default paths for additional library and include file search (in
284
325
# addition to the standard system directories above); these are always
285
326
# added to the compile and link commands by mxSetup per default.
286
LIBPATH = build_path(['/usr/local/lib', os.path.join(sys.prefix, 'lib')])
287
INCLPATH = build_path(['/usr/local/include', os.path.join(sys.prefix, 'include')])
327
LIBPATH = build_path(['/usr/local/lib',
328
os.path.join(sys.prefix, 'lib')])
329
INCLPATH = build_path(['/usr/local/include',
330
os.path.join(sys.prefix, 'include')])
289
332
verify_path(LIBPATH)
290
333
verify_path(INCLPATH)
625
668
# here. This is an awful hack, but there seems to be no other way to
626
669
# subclass a standard distutils C compiler class...
671
if sys.version[:3] < '2.4':
673
MSVC_COMPILER_FLAGS = ['/O2', '/Gf', '/GB', '/GD', '/Ob2']
676
MSVC_COMPILER_FLAGS = ['/O2', '/GF', '/GB', '/Ob2']
628
678
# remember old __init__
629
679
old_MSVCCompiler__init__ = MSVCCompiler.__init__
631
681
def mx_msvccompiler__init__(self, *args, **kws):
633
683
apply(old_MSVCCompiler__init__, (self,) + args, kws)
634
self.compile_options.extend(['/O2','/Gf','/GB','/GD', '/Ob2'])
684
self.compile_options.extend(MSVC_COMPILER_FLAGS)
636
686
# "Install" new __init__
637
687
MSVCCompiler.__init__ = mx_msvccompiler__init__
1599
# mx Zope binary distribution command
1649
# mx in-place binary distribution command
1602
class mx_bdist_zope(bdist_dumb):
1652
class mx_bdist_inplace(bdist_dumb):
1604
1654
""" Build binary Zope product distribution.
1607
def finalize_options (self):
1657
# Path prefix to use in the distribution (all files will be placed
1658
# under this prefix)
1661
user_options = bdist_dumb.user_options + [
1662
('dist-prefix=', None,
1663
'path prefix the binary distribution with'),
1666
def finalize_options(self):
1609
1668
# Default to ZIP as format on all platforms
1610
1669
if self.format is None:
1611
1670
self.format = 'zip'
1612
1671
# Default to <platform>-py<version> on all platforms
1613
1672
if self.plat_name is None:
1614
self.plat_name = '%s-py%s' % (get_platform(), sys.version[:3])
1673
self.plat_name = '%s-py%s' % (get_platform(), py_version())
1615
1674
bdist_dumb.finalize_options(self)
1617
1676
# Hack to reuse bdist_dumb for our purposes; .run() calls
1621
1680
cmdobj = bdist_dumb.reinitialize_command(self, command,
1622
1681
reinit_subcommands)
1623
1682
if command == 'install':
1624
cmdobj.install_lib = 'lib/python'
1625
cmdobj.install_data = 'lib/python'
1683
cmdobj.install_lib = self.dist_prefix
1684
cmdobj.install_data = self.dist_prefix
1688
# mx Zope binary distribution command
1691
class mx_bdist_zope(mx_bdist_inplace):
1693
""" Build binary Zope product distribution.
1696
# Path prefix to use in the distribution (all files will be placed
1697
# under this prefix)
1698
dist_prefix = 'lib/python'
1630
1702
def run_setup(configurations):