annotate setup.py @ 554:d2d5c09b33d0

Added tag 1.0 for changeset 97f2079e3778
author Augie Fackler <durin42@gmail.com>
date Sun, 07 Feb 2010 03:33:40 -0600
parents 97f2079e3778
children c538229d02ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
320
1ba8ed29148e Fix package name, use README for long_description
Augie Fackler <durin42@gmail.com>
parents: 318
diff changeset
3 import os
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
4 import subprocess
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
5 import sys
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
6 import time
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
7 if not hasattr(sys, 'version_info') or sys.version_info < (2, 4, 0, 'final'):
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
8 raise SystemExit("Mercurial requires python 2.4 or later.")
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
9
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
10 try:
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
11 from distutils.command.build_py import build_py_2to3 as build_py
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
12 except ImportError:
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
13 from distutils.command.build_py import build_py
353
1ad05cffb20f setup.py: Use setuptools if available.
Augie Fackler <durin42@gmail.com>
parents: 347
diff changeset
14 try:
1ad05cffb20f setup.py: Use setuptools if available.
Augie Fackler <durin42@gmail.com>
parents: 347
diff changeset
15 from setuptools import setup
1ad05cffb20f setup.py: Use setuptools if available.
Augie Fackler <durin42@gmail.com>
parents: 347
diff changeset
16 except ImportError:
1ad05cffb20f setup.py: Use setuptools if available.
Augie Fackler <durin42@gmail.com>
parents: 347
diff changeset
17 from distutils.core import setup
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
18
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
19 def runcmd(cmd, env):
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
20 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
21 stderr=subprocess.PIPE, env=env)
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
22 out, err = p.communicate()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
23 # If root is executing setup.py, but the repository is owned by
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
24 # another user (as in "sudo python setup.py install") we will get
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
25 # trust warnings since the .hg/hgrc file is untrusted. That is
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
26 # fine, we don't want to load it anyway.
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
27 err = [e for e in err.splitlines()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
28 if not e.startswith('Not trusting file')]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
29 if err:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
30 return ''
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
31 return out
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
32
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
33
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
34 version = ''
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
35
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
36 if os.path.isdir('.hg'):
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
37 # Execute hg out of this directory with a custom environment which
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
38 # includes the pure Python modules in mercurial/pure. We also take
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
39 # care to not use any hgrc files and do no localization.
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
40 env = {'HGRCPATH': '',
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
41 'LANGUAGE': 'C'}
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
42 for copyenv in ('LD_LIBRARY_PATH', 'PYTHONPATH', 'PATH'):
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
43 if copyenv in os.environ:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
44 env[copyenv] = os.environ[copyenv]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
45 if 'SystemRoot' in os.environ:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
46 # Copy SystemRoot into the custom environment for Python 2.6
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
47 # under Windows. Otherwise, the subprocess will fail with
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
48 # error 0xc0150004. See: http://bugs.python.org/issue3440
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
49 env['SystemRoot'] = os.environ['SystemRoot']
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
50 cmd = ['hg', 'id', '-i', '-t']
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
51 l = runcmd(cmd, env).split()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
52 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
53 l.pop()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
54 if len(l) > 1: # tag found
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
55 version = l[-1]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
56 if l[0].endswith('+'): # propagate the dirty status to the tag
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
57 version += '+'
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
58 elif len(l) == 1: # no tag found
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
59 cmd = ['hg', 'parents', '--template',
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
60 '{latesttag}+{latesttagdistance}-']
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
61 version = runcmd(cmd, env) + l[0]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
62 if not version:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
63 version = runcmd(['hg', 'parents', '--template' '{node|short}\n'],
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
64 env)
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
65 if version:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
66 version = version.split()[0]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
67 if version.endswith('+'):
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
68 version += time.strftime('%Y%m%d')
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
69 elif os.path.exists('.hg_archival.txt'):
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
70 kw = dict([t.strip() for t in l.split(':', 1)]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
71 for l in open('.hg_archival.txt'))
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
72 if 'tag' in kw:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
73 version = kw['tag']
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
74 elif 'latesttag' in kw:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
75 version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
76 else:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
77 version = kw.get('node', '')[:12]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
78
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
79 if version:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
80 f = open("hgsubversion/__version__.py", "w")
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
81 f.write('# this file is autogenerated by setup.py\n')
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
82 f.write('version = "%s"\n' % version)
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
83 f.close()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
84
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
85 try:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
86 from hgsubversion import __version__
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
87 version = __version__.version
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
88 except ImportError:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
89 version = 'unknown'
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
90
553
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
91 try:
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
92 from svn import core
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
93 assert core.SVN_VER_MAJOR == 1
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
94 assert core.SVN_VER_MINOR >= 5
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
95 except ImportError:
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
96 raise Exception('You need to install the SWIG'
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
97 ' bindings for Subversion to use this package.')
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
98 except AssertionError:
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
99 raise Exception('You need at least Subversion 1.5 to use this package.')
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
100
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
101
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
102 setup(
320
1ba8ed29148e Fix package name, use README for long_description
Augie Fackler <durin42@gmail.com>
parents: 318
diff changeset
103 name = 'hgsubversion',
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
104 version = version,
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
105 url = 'http://bitbucket.org/durin42/hgsubversion',
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
106 license = 'GNU GPL',
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
107 author = 'Augie Fackler, others',
553
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
108 author_email = 'durin42@gmail.com',
318
0291afdd7555 Style nit in setup.py
Augie Fackler <durin42@gmail.com>
parents: 308
diff changeset
109 description = ('hgsubversion is a Mercurial extension for working with '
0291afdd7555 Style nit in setup.py
Augie Fackler <durin42@gmail.com>
parents: 308
diff changeset
110 'Subversion repositories.'),
320
1ba8ed29148e Fix package name, use README for long_description
Augie Fackler <durin42@gmail.com>
parents: 318
diff changeset
111 long_description = open(os.path.join(os.path.dirname(__file__),
1ba8ed29148e Fix package name, use README for long_description
Augie Fackler <durin42@gmail.com>
parents: 318
diff changeset
112 'README')).read(),
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
113 keywords = 'mercurial',
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
114 packages = ('hgsubversion', 'hgsubversion.svnwrap'),
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
115 platforms = 'any',
553
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
116 install_requires=['mercurial', ],
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
117 classifiers = [
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
118 'License :: OSI Approved :: GNU General Public License (GPL)',
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
119 'Intended Audience :: Developers',
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
120 'Topic :: Software Development :: Version Control',
553
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
121 'Development Status :: 4 - Beta',
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
122 'Programming Language :: Python',
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
123 'Operating System :: OS Independent',
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
124 ],
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
125 cmdclass = {'build_py': build_py},
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
126 )