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