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