Show More
@@ -97,7 +97,10 b' try:' | |||||
97 | except ImportError: |
|
97 | except ImportError: | |
98 | pass |
|
98 | pass | |
99 |
|
99 | |||
100 | try: |
|
100 | def getversion(): | |
|
101 | if not os.path.exists('.hg'): | |||
|
102 | return None # not in a repository | |||
|
103 | ||||
101 | # execute hg out of this directory with a custom environment which |
|
104 | # execute hg out of this directory with a custom environment which | |
102 | # includes the pure Python modules in mercurial/pure |
|
105 | # includes the pure Python modules in mercurial/pure | |
103 | pypath = os.environ.get('PYTHONPATH', '') |
|
106 | pypath = os.environ.get('PYTHONPATH', '') | |
@@ -105,23 +108,31 b' try:' | |||||
105 | os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath]) |
|
108 | os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath]) | |
106 | os.environ['HGRCPATH'] = '' # do not read any config file |
|
109 | os.environ['HGRCPATH'] = '' # do not read any config file | |
107 | cmd = '%s hg id -it' % sys.executable |
|
110 | cmd = '%s hg id -it' % sys.executable | |
108 | l = os.popen(cmd).read().split() |
|
111 | ||
|
112 | try: | |||
|
113 | l = os.popen(cmd).read().split() | |||
|
114 | except OSError, e: | |||
|
115 | print "warning: could not establish Mercurial version: %s" % e | |||
|
116 | ||||
109 | os.environ['PYTHONPATH'] = pypath |
|
117 | os.environ['PYTHONPATH'] = pypath | |
|
118 | ||||
110 | while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags |
|
119 | while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags | |
111 | l.pop() |
|
120 | l.pop() | |
112 | version = l and l[-1] or 'unknown' # latest tag or revision number |
|
121 | if l: | |
113 | if version.endswith('+'): |
|
122 | version = l[-1] # latest tag or revision number | |
114 | version += time.strftime('%Y%m%d') |
|
123 | if version.endswith('+'): | |
|
124 | version += time.strftime('%Y%m%d') | |||
|
125 | return version | |||
115 |
|
126 | |||
116 | except OSError, e: |
|
127 | version = getversion() | |
117 | print "warning: could not establish Mercurial version: %s" % e |
|
128 | if version: | |
|
129 | f = file("mercurial/__version__.py", "w") | |||
|
130 | f.write('# this file is autogenerated by setup.py\n') | |||
|
131 | f.write('version = "%s"\n' % version) | |||
|
132 | f.close() | |||
|
133 | else: | |||
118 | version = "unknown" |
|
134 | version = "unknown" | |
119 |
|
135 | |||
120 | f = file("mercurial/__version__.py", "w") |
|
|||
121 | f.write('# this file is autogenerated by setup.py\n') |
|
|||
122 | f.write('version = "%s"\n' % version) |
|
|||
123 | f.close() |
|
|||
124 |
|
||||
125 | class install_package_data(install_data): |
|
136 | class install_package_data(install_data): | |
126 | def finalize_options(self): |
|
137 | def finalize_options(self): | |
127 | self.set_undefined_options('install', |
|
138 | self.set_undefined_options('install', |
General Comments 0
You need to be logged in to leave comments.
Login now