changelog shortlog tags changeset files revisions annotate raw

setup.py

changeset 6550: 628da4a91628
parent:0231f763ebc8
child:b2c4be19d7b1
author: Patrick Mezard <pmezard@gmail.com>
date: Mon Apr 14 23:28:50 2008 +0200 (2 months ago)
permissions: -rw-r--r--
description: Merge with crew-stable, fix test output
1#!/usr/bin/env python
2#
3# This is the mercurial setup script.
4#
5# 'python setup.py install', or
6# 'python setup.py --help' for more options
7
8import sys
9if not hasattr(sys, 'version_info') or sys.version_info < (2, 3, 0, 'final'):
10 raise SystemExit, "Mercurial requires python 2.3 or later."
11
12import os
13import shutil
14import tempfile
15from distutils.core import setup, Extension
16from distutils.command.install_data import install_data
17from distutils.ccompiler import new_compiler
18
19import mercurial.version
20
21extra = {}
22scripts = ['hg']
23if os.name == 'nt':
24 scripts.append('contrib/win32/hg.bat')
25
26# simplified version of distutils.ccompiler.CCompiler.has_function
27# that actually removes its temporary files.
28def has_function(cc, funcname):
29 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
30 devnull = oldstderr = None
31 try:
32 try:
33 fname = os.path.join(tmpdir, 'funcname.c')
34 f = open(fname, 'w')
35 f.write('int main(void) {\n')
36 f.write(' %s();\n' % funcname)
37 f.write('}\n')
38 f.close()
39 # Redirect stderr to /dev/null to hide any error messages
40 # from the compiler.
41 # This will have to be changed if we ever have to check
42 # for a function on Windows.
43 devnull = open('/dev/null', 'w')
44 oldstderr = os.dup(sys.stderr.fileno())
45 os.dup2(devnull.fileno(), sys.stderr.fileno())
46 objects = cc.compile([fname])
47 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
48 except:
49 return False
50 return True
51 finally:
52 if oldstderr is not None:
53 os.dup2(oldstderr, sys.stderr.fileno())
54 if devnull is not None:
55 devnull.close()
56 shutil.rmtree(tmpdir)
57
58# py2exe needs to be installed to work
59try:
60 import py2exe
61
62 # Help py2exe to find win32com.shell
63 try:
64 import modulefinder
65 import win32com
66 for p in win32com.__path__[1:]: # Take the path to win32comext
67 modulefinder.AddPackagePath("win32com", p)
68 pn = "win32com.shell"
69 __import__(pn)
70 m = sys.modules[pn]
71 for p in m.__path__[1:]:
72 modulefinder.AddPackagePath(pn, p)
73 except ImportError:
74 pass
75
76 extra['console'] = ['hg']
77
78except ImportError:
79 pass
80
81# specify version string, otherwise 'hg identify' will be used:
82version = ''
83
84class install_package_data(install_data):
85 def finalize_options(self):
86 self.set_undefined_options('install',
87 ('install_lib', 'install_dir'))
88 install_data.finalize_options(self)
89
90mercurial.version.remember_version(version)
91cmdclass = {'install_data': install_package_data}
92
93ext_modules=[
94 Extension('mercurial.base85', ['mercurial/base85.c']),
95 Extension('mercurial.bdiff', ['mercurial/bdiff.c']),
96 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']),
97 Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
98 Extension('mercurial.parsers', ['mercurial/parsers.c']),
99 ]
100
101packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert']
102
103try:
104 import posix
105 ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
106
107 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
108 # The inotify extension is only usable with Linux 2.6 kernels.
109 # You also need a reasonably recent C library.
110 cc = new_compiler()
111 if has_function(cc, 'inotify_add_watch'):
112 ext_modules.append(Extension('hgext.inotify.linux._inotify',
113 ['hgext/inotify/linux/_inotify.c']))
114 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
115except ImportError:
116 pass
117
118setup(name='mercurial',
119 version=mercurial.version.get_version(),
120 author='Matt Mackall',
121 author_email='mpm@selenic.com',
122 url='http://selenic.com/mercurial',
123 description='Scalable distributed SCM',
124 license='GNU GPL',
125 scripts=scripts,
126 packages=packages,
127 ext_modules=ext_modules,
128 data_files=[(os.path.join('mercurial', root),
129 [os.path.join(root, file_) for file_ in files])
130 for root, dirs, files in os.walk('templates')],
131 cmdclass=cmdclass,
132 options=dict(py2exe=dict(packages=['hgext']),
133 bdist_mpkg=dict(zipdist=True,
134 license='COPYING',
135 readme='contrib/macosx/Readme.html',
136 welcome='contrib/macosx/Welcome.html')),
137 **extra)
back to repositories index - hg@intevation.org - Intevation GmbH