Show More
@@ -1,67 +1,74 | |||
|
1 | 1 | # Copyright (C) 2005 by Intevation GmbH |
|
2 | 2 | # Author(s): |
|
3 | 3 | # Thomas Arendsen Hein <thomas@intevation.de> |
|
4 | 4 | # |
|
5 | 5 | # This program is free software under the GNU GPL (>=v2) |
|
6 | 6 | # Read the file COPYING coming with the software for details. |
|
7 | 7 | |
|
8 | 8 | """ |
|
9 | 9 | Mercurial version |
|
10 | 10 | """ |
|
11 | 11 | |
|
12 | 12 | import os |
|
13 | 13 | import os.path |
|
14 | 14 | import re |
|
15 | 15 | import time |
|
16 | 16 | import util |
|
17 | 17 | |
|
18 | 18 | unknown_version = 'unknown' |
|
19 | 19 | remembered_version = False |
|
20 | 20 | |
|
21 | 21 | def get_version(): |
|
22 | 22 | """Return version information if available.""" |
|
23 | 23 | try: |
|
24 | 24 | from mercurial.__version__ import version |
|
25 | 25 | except ImportError: |
|
26 | 26 | version = unknown_version |
|
27 | 27 | return version |
|
28 | 28 | |
|
29 | 29 | def write_version(version): |
|
30 | 30 | """Overwrite version file.""" |
|
31 | filename = os.path.join(os.path.dirname(__file__), '__version__.py') | |
|
32 | f = open(filename, 'w') | |
|
31 | if version == get_version(): | |
|
32 | return | |
|
33 | directory = os.path.dirname(__file__) | |
|
34 | for suffix in ['py', 'pyc', 'pyo']: | |
|
35 | try: | |
|
36 | os.unlink(os.path.join(directory, '__version__.%s' % suffix)) | |
|
37 | except OSError: | |
|
38 | pass | |
|
39 | f = open(os.path.join(directory, '__version__.py'), 'w') | |
|
33 | 40 | f.write("# This file is auto-generated.\n") |
|
34 | 41 | f.write("version = %r\n" % version) |
|
35 | 42 | f.close() |
|
36 | 43 | |
|
37 | 44 | def remember_version(version=None): |
|
38 | 45 | """Store version information.""" |
|
39 | 46 | global remembered_version |
|
40 | 47 | if not version and os.path.isdir(".hg"): |
|
41 | 48 | f = os.popen("hg identify 2> %s" % util.nulldev) # use real hg installation |
|
42 | 49 | ident = f.read()[:-1] |
|
43 | 50 | if not f.close() and ident: |
|
44 | 51 | ids = ident.split(' ', 1) |
|
45 | 52 | version = ids.pop(0) |
|
46 | 53 | if version[-1] == '+': |
|
47 | 54 | version = version[:-1] |
|
48 | 55 | modified = True |
|
49 | 56 | else: |
|
50 | 57 | modified = False |
|
51 | 58 | if version.isalnum() and ids: |
|
52 | 59 | for tag in ids[0].split('/'): |
|
53 | 60 | # is a tag is suitable as a version number? |
|
54 | 61 | if re.match(r'^(\d+\.)+[\w.-]+$', tag): |
|
55 | 62 | version = tag |
|
56 | 63 | break |
|
57 | 64 | if modified: |
|
58 | 65 | version += time.strftime('+%Y%m%d') |
|
59 | 66 | if version: |
|
60 | 67 | remembered_version = True |
|
61 | 68 | write_version(version) |
|
62 | 69 | |
|
63 | 70 | def forget_version(): |
|
64 | 71 | """Remove version information.""" |
|
65 | 72 | if remembered_version: |
|
66 | 73 | write_version(unknown_version) |
|
67 | 74 |
@@ -1,106 +1,103 | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # |
|
3 | 3 | # This is the mercurial setup script. |
|
4 | 4 | # |
|
5 | 5 | # './setup.py install', or |
|
6 | 6 | # './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): |
|
10 | 10 | raise SystemExit, "Mercurial requires python 2.3 or later." |
|
11 | 11 | |
|
12 | 12 | import glob |
|
13 | 13 | from distutils.core import setup, Extension |
|
14 | 14 | from distutils.command.install_data import install_data |
|
15 | 15 | |
|
16 | 16 | import mercurial.version |
|
17 | 17 | |
|
18 | 18 | # py2exe needs to be installed to work |
|
19 | 19 | try: |
|
20 | 20 | import py2exe |
|
21 | 21 | |
|
22 | 22 | # Help py2exe to find win32com.shell |
|
23 | 23 | try: |
|
24 | 24 | import modulefinder |
|
25 | 25 | import win32com |
|
26 | 26 | for p in win32com.__path__[1:]: # Take the path to win32comext |
|
27 | 27 | modulefinder.AddPackagePath("win32com", p) |
|
28 | 28 | pn = "win32com.shell" |
|
29 | 29 | __import__(pn) |
|
30 | 30 | m = sys.modules[pn] |
|
31 | 31 | for p in m.__path__[1:]: |
|
32 | 32 | modulefinder.AddPackagePath(pn, p) |
|
33 | 33 | except ImportError: |
|
34 | 34 | pass |
|
35 | 35 | |
|
36 | 36 | # Due to the use of demandload py2exe is not finding the modules. |
|
37 | 37 | # packagescan.getmodules creates a list of modules included in |
|
38 | 38 | # the mercurial package plus depdent modules. |
|
39 | 39 | import mercurial.packagescan |
|
40 | 40 | from py2exe.build_exe import py2exe as build_exe |
|
41 | 41 | |
|
42 | 42 | class py2exe_for_demandload(build_exe): |
|
43 | 43 | """ overwrites the py2exe command class for getting the build |
|
44 | 44 | directory and for setting the 'includes' option.""" |
|
45 | 45 | def initialize_options(self): |
|
46 | 46 | self.build_lib = None |
|
47 | 47 | build_exe.initialize_options(self) |
|
48 | 48 | def finalize_options(self): |
|
49 | 49 | # Get the build directory, ie. where to search for modules. |
|
50 | 50 | self.set_undefined_options('build', |
|
51 | 51 | ('build_lib', 'build_lib')) |
|
52 | 52 | # Sets the 'includes' option with the list of needed modules |
|
53 | 53 | if not self.includes: |
|
54 | 54 | self.includes = [] |
|
55 | 55 | else: |
|
56 | 56 | self.includes = self.includes.split(',') |
|
57 | 57 | self.includes += mercurial.packagescan.getmodules(self.build_lib, |
|
58 | 58 | 'mercurial') |
|
59 | 59 | self.includes += mercurial.packagescan.getmodules(self.build_lib, |
|
60 | 60 | 'hgext') |
|
61 | 61 | build_exe.finalize_options(self) |
|
62 | 62 | except ImportError: |
|
63 | 63 | py2exe_for_demandload = None |
|
64 | 64 | |
|
65 | 65 | |
|
66 | 66 | # specify version string, otherwise 'hg identify' will be used: |
|
67 | 67 | version = '' |
|
68 | 68 | |
|
69 | 69 | class install_package_data(install_data): |
|
70 | 70 | def finalize_options(self): |
|
71 | 71 | self.set_undefined_options('install', |
|
72 | 72 | ('install_lib', 'install_dir')) |
|
73 | 73 | install_data.finalize_options(self) |
|
74 | 74 | |
|
75 | try: | |
|
76 | mercurial.version.remember_version(version) | |
|
77 | cmdclass = {'install_data': install_package_data} | |
|
78 | py2exe_opts = {} | |
|
79 | if py2exe_for_demandload is not None: | |
|
80 | cmdclass['py2exe'] = py2exe_for_demandload | |
|
81 | py2exe_opts['console'] = ['hg'] | |
|
82 | setup(name='mercurial', | |
|
83 | version=mercurial.version.get_version(), | |
|
84 | author='Matt Mackall', | |
|
85 |
|
|
|
86 | url='http://selenic.com/mercurial', | |
|
87 | description='Scalable distributed SCM', | |
|
88 | license='GNU GPL', | |
|
89 | packages=['mercurial', 'hgext'], | |
|
90 |
|
|
|
91 | Extension('mercurial.bdiff', ['mercurial/bdiff.c'])], | |
|
92 | data_files=[('mercurial/templates', | |
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 | glob.glob('templates/static/*'))], | |
|
98 | cmdclass=cmdclass, | |
|
99 | scripts=['hg', 'hgmerge'], | |
|
100 | options=dict(bdist_mpkg=dict(zipdist=True, | |
|
101 |
|
|
|
102 |
|
|
|
103 | welcome='contrib/macosx/Welcome.html')), | |
|
104 | **py2exe_opts) | |
|
105 | finally: | |
|
106 | mercurial.version.forget_version() | |
|
75 | mercurial.version.remember_version(version) | |
|
76 | cmdclass = {'install_data': install_package_data} | |
|
77 | py2exe_opts = {} | |
|
78 | if py2exe_for_demandload is not None: | |
|
79 | cmdclass['py2exe'] = py2exe_for_demandload | |
|
80 | py2exe_opts['console'] = ['hg'] | |
|
81 | setup(name='mercurial', | |
|
82 | version=mercurial.version.get_version(), | |
|
83 | author='Matt Mackall', | |
|
84 | author_email='mpm@selenic.com', | |
|
85 | url='http://selenic.com/mercurial', | |
|
86 | description='Scalable distributed SCM', | |
|
87 | license='GNU GPL', | |
|
88 | packages=['mercurial', 'hgext'], | |
|
89 | ext_modules=[Extension('mercurial.mpatch', ['mercurial/mpatch.c']), | |
|
90 | Extension('mercurial.bdiff', ['mercurial/bdiff.c'])], | |
|
91 | data_files=[('mercurial/templates', | |
|
92 | ['templates/map'] + | |
|
93 | glob.glob('templates/map-*') + | |
|
94 | glob.glob('templates/*.tmpl')), | |
|
95 | ('mercurial/templates/static', | |
|
96 | glob.glob('templates/static/*'))], | |
|
97 | cmdclass=cmdclass, | |
|
98 | scripts=['hg', 'hgmerge'], | |
|
99 | options=dict(bdist_mpkg=dict(zipdist=True, | |
|
100 | license='COPYING', | |
|
101 | readme='contrib/macosx/Readme.html', | |
|
102 | welcome='contrib/macosx/Welcome.html')), | |
|
103 | **py2exe_opts) |
General Comments 0
You need to be logged in to leave comments.
Login now