~ubuntu-branches/ubuntu/gutsy/egenix-mx-base/gutsy

« back to all changes in this revision

Viewing changes to mxSetup.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2005-01-16 11:29:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050116112914-aew4kizr198v3oib
Tags: 2.0.6-0ubuntu1
* New upstream version (python2.4 compatibility fix).
* Clean up package depenencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
""" Distutils Extensions needed for the mx Extensions.
4
4
 
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.
9
9
"""
10
10
#
11
11
# History:
 
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)
105
106
 
 
107
def py_version(unicode_aware=1, include_patchlevel=0):
 
108
 
 
109
    """ Return the Python version as short string.
 
110
 
 
111
        If unicode_aware is true (default), the function also tests
 
112
        whether a UCS2 or UCS4 built is running and modifies the
 
113
        version accordingly.
 
114
 
 
115
        If include_patchlevel is true (default is false), the patch
 
116
        level is also included in the version string.
 
117
 
 
118
    """
 
119
    if include_patchlevel:
 
120
        version = sys.version[:5]
 
121
    else:
 
122
        version = sys.version[:3]
 
123
    if unicode_aware and version > '2.0':
 
124
        try:
 
125
            unichr(100000)
 
126
        except ValueError:
 
127
            pass
 
128
        else:
 
129
            # UCS4 build
 
130
            version = version + 'ucs4'
 
131
    return version
 
132
 
 
133
def check_zope_product_version(version, version_txt):
 
134
 
 
135
    """ Check whether the version string version matches the
 
136
        version data in the Zope product version.txt file
 
137
        version_txt.
 
138
 
 
139
    """
 
140
    data = open(version_txt, 'r').read().strip()
 
141
    return data[-len(version):] == version
 
142
 
106
143
def mx_customize_compiler(compiler):
107
144
 
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',
 
153
                             'LDSHARED', 'SO')
 
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,
124
165
            linker_exe=cc)
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')])
288
331
 
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...
627
670
 
 
671
if sys.version[:3] < '2.4':
 
672
    # VC6
 
673
    MSVC_COMPILER_FLAGS = ['/O2', '/Gf', '/GB', '/GD', '/Ob2']
 
674
else:
 
675
    # VC7
 
676
    MSVC_COMPILER_FLAGS = ['/O2', '/GF', '/GB', '/Ob2']
 
677
 
628
678
# remember old __init__
629
679
old_MSVCCompiler__init__ = MSVCCompiler.__init__
630
680
 
631
681
def mx_msvccompiler__init__(self, *args, **kws):
632
682
 
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)
635
685
 
636
686
# "Install" new __init__
637
687
MSVCCompiler.__init__ = mx_msvccompiler__init__
1102
1152
                                "removing %s" % filename,
1103
1153
                                verbose=verbose, dry_run=dry_run)
1104
1154
 
1105
 
    def get_outputs (self, include_bytecode=1):
 
1155
    def get_outputs(self, include_bytecode=1):
1106
1156
 
1107
1157
        if not self.without_source or \
1108
1158
           not include_bytecode:
1596
1646
        return l
1597
1647
    
1598
1648
#
1599
 
# mx Zope binary distribution command
 
1649
# mx in-place binary distribution command
1600
1650
#
1601
1651
 
1602
 
class mx_bdist_zope(bdist_dumb):
 
1652
class mx_bdist_inplace(bdist_dumb):
1603
1653
 
1604
1654
    """ Build binary Zope product distribution.
1605
1655
    """
1606
1656
 
1607
 
    def finalize_options (self):
 
1657
    # Path prefix to use in the distribution (all files will be placed
 
1658
    # under this prefix)
 
1659
    dist_prefix = ''
 
1660
 
 
1661
    user_options = bdist_dumb.user_options + [
 
1662
        ('dist-prefix=', None,
 
1663
         'path prefix the binary distribution with'),
 
1664
        ]
 
1665
 
 
1666
    def finalize_options(self):
1608
1667
 
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)
1616
1675
 
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
1626
1685
        return cmdobj
1627
1686
 
 
1687
#
 
1688
# mx Zope binary distribution command
 
1689
#
 
1690
 
 
1691
class mx_bdist_zope(mx_bdist_inplace):
 
1692
 
 
1693
    """ Build binary Zope product distribution.
 
1694
    """
 
1695
 
 
1696
    # Path prefix to use in the distribution (all files will be placed
 
1697
    # under this prefix)
 
1698
    dist_prefix = 'lib/python'
 
1699
 
1628
1700
###
1629
1701
 
1630
1702
def run_setup(configurations):
1667
1739
                  'uninstall': mx_uninstall,
1668
1740
                  'bdist_rpm': mx_bdist_rpm,
1669
1741
                  'bdist_zope': mx_bdist_zope,
 
1742
                  'bdist_inplace': mx_bdist_inplace,
1670
1743
                  }
1671
1744
    if bdist_ppm is not None:
1672
1745
        extensions['bdist_ppm'] = bdist_ppm.bdist_ppm