annotate setup.py @ 1050:fb0715c9347d

decrease verbosity somewhat while at it, follow convention that output starts with lowercase letters
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 09 Aug 2013 16:05:29 -0500
parents bdc9b21ea8d0
children 7d47a0f73135
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
562
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
4 import re
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
5 import subprocess
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
6 import sys
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
7 import time
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
8 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
9 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
10
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
11 try:
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
12 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
13 except ImportError:
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
14 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
15 try:
1ad05cffb20f setup.py: Use setuptools if available.
Augie Fackler <durin42@gmail.com>
parents: 347
diff changeset
16 from setuptools import setup
1ad05cffb20f setup.py: Use setuptools if available.
Augie Fackler <durin42@gmail.com>
parents: 347
diff changeset
17 except ImportError:
1ad05cffb20f setup.py: Use setuptools if available.
Augie Fackler <durin42@gmail.com>
parents: 347
diff changeset
18 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
19
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
20 def runcmd(cmd, env):
799
0b56b1492d23 Fix setup.py calls to hg.bat on Windows
Patrick Mezard <pmezard@gmail.com>
parents: 798
diff changeset
21 shell = os.name == 'nt'
0b56b1492d23 Fix setup.py calls to hg.bat on Windows
Patrick Mezard <pmezard@gmail.com>
parents: 798
diff changeset
22 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=shell,
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
23 stderr=subprocess.PIPE, env=env)
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
24 out, err = p.communicate()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
25 # 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
26 # 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
27 # 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
28 # fine, we don't want to load it anyway.
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
29 err = [e for e in err.splitlines()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
30 if not e.startswith('Not trusting file')]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
31 if err:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
32 return ''
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
33 return out
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
34
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 version = ''
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
37
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
38 if os.path.isdir('.hg'):
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
39 # 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
40 # 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
41 # 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
42 env = {'HGRCPATH': '',
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
43 'LANGUAGE': 'C'}
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
44 for copyenv in ('LD_LIBRARY_PATH', 'PYTHONPATH', 'PATH'):
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
45 if copyenv in os.environ:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
46 env[copyenv] = os.environ[copyenv]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
47 if 'SystemRoot' in os.environ:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
48 # 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
49 # under Windows. Otherwise, the subprocess will fail with
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
50 # error 0xc0150004. See: http://bugs.python.org/issue3440
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
51 env['SystemRoot'] = os.environ['SystemRoot']
798
3bffdf0e5948 Backed out changeset 7bf283d4c7a9 in favor of a better win32 fix
Augie Fackler <durin42@gmail.com>
parents: 797
diff changeset
52 cmd = ['hg', 'id', '-i', '-t']
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
53 l = runcmd(cmd, env).split()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
54 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
55 l.pop()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
56 if len(l) > 1: # tag found
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
57 version = l[-1]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
58 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
59 version += '+'
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
60 elif len(l) == 1: # no tag found
798
3bffdf0e5948 Backed out changeset 7bf283d4c7a9 in favor of a better win32 fix
Augie Fackler <durin42@gmail.com>
parents: 797
diff changeset
61 cmd = ['hg', 'parents', '--template',
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
62 '{latesttag}+{latesttagdistance}-']
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
63 version = runcmd(cmd, env) + l[0]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
64 if not version:
798
3bffdf0e5948 Backed out changeset 7bf283d4c7a9 in favor of a better win32 fix
Augie Fackler <durin42@gmail.com>
parents: 797
diff changeset
65 version = runcmd(['hg', 'parents', '--template' '{node|short}\n'],
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
66 env)
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
67 if version:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
68 version = version.split()[0]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
69 if version.endswith('+'):
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
70 version += time.strftime('%Y%m%d')
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
71 elif os.path.exists('.hg_archival.txt'):
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
72 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
73 for l in open('.hg_archival.txt'))
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
74 if 'tag' in kw:
827
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
75 version = kw['tag']
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
76 elif 'latesttag' in kw:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
77 version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
78 else:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
79 version = kw.get('node', '')[:12]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
80
562
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
81 verfile = os.path.join("hgsubversion", "__version__.py")
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
82 if version:
562
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
83 f = open(verfile, "w")
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
84 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
85 f.write('version = "%s"\n' % version)
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
86 f.close()
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
87
562
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
88 if os.path.exists(verfile):
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
89 # scrape the version out with a regex because setuptools
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
90 # needlessly swaps out file() for some non-object thing
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
91 # and breaks importing hgsubversion entirely
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
92 mat = re.findall('.*"(.*)"', open(verfile).read())
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
93 version = mat[0]
c538229d02ca setup: work around easy_install by getting version with a regex
Augie Fackler <durin42@gmail.com>
parents: 553
diff changeset
94 if not version:
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
95 version = 'unknown'
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 353
diff changeset
96
563
09c016174e33 setup: work around easy_intall overzealously installing mercurial
Augie Fackler <durin42@gmail.com>
parents: 562
diff changeset
97 requires = []
09c016174e33 setup: work around easy_intall overzealously installing mercurial
Augie Fackler <durin42@gmail.com>
parents: 562
diff changeset
98 try:
09c016174e33 setup: work around easy_intall overzealously installing mercurial
Augie Fackler <durin42@gmail.com>
parents: 562
diff changeset
99 import mercurial
09c016174e33 setup: work around easy_intall overzealously installing mercurial
Augie Fackler <durin42@gmail.com>
parents: 562
diff changeset
100 except ImportError:
09c016174e33 setup: work around easy_intall overzealously installing mercurial
Augie Fackler <durin42@gmail.com>
parents: 562
diff changeset
101 requires.append('mercurial')
553
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
102
681
26b85c0cf48a setup: require Subvertpy when the SWIG bindings are unavailable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 659
diff changeset
103 # If the Subversion SWIG bindings aren't present, require Subvertpy
26b85c0cf48a setup: require Subvertpy when the SWIG bindings are unavailable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 659
diff changeset
104 try:
26b85c0cf48a setup: require Subvertpy when the SWIG bindings are unavailable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 659
diff changeset
105 from hgsubversion.svnwrap import svn_swig_wrapper
26b85c0cf48a setup: require Subvertpy when the SWIG bindings are unavailable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 659
diff changeset
106 except ImportError:
732
050f03a3bdf5 setup/README: update Subvertpy requirement to 0.7.4.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 681
diff changeset
107 requires.append('subvertpy>=0.7.4')
612
2c15e4c50a54 setup: check for Subversion by importing the `svnwrap' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 563
diff changeset
108
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
109 setup(
827
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
110 name='hgsubversion',
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
111 version=version,
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
112 url='http://bitbucket.org/durin42/hgsubversion',
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
113 license='GNU GPL',
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
114 author='Augie Fackler, others',
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
115 author_email='durin42@gmail.com',
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
116 description=('hgsubversion is a Mercurial extension for working with '
318
0291afdd7555 Style nit in setup.py
Augie Fackler <durin42@gmail.com>
parents: 308
diff changeset
117 'Subversion repositories.'),
827
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
118 long_description=open(os.path.join(os.path.dirname(__file__),
320
1ba8ed29148e Fix package name, use README for long_description
Augie Fackler <durin42@gmail.com>
parents: 318
diff changeset
119 'README')).read(),
827
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
120 keywords='mercurial',
1008
bdc9b21ea8d0 setup: add layouts subdir
Bryan O'Sullivan <bryano@fb.com>
parents: 919
diff changeset
121 packages=('hgsubversion', 'hgsubversion.hooks', 'hgsubversion.layouts',
bdc9b21ea8d0 setup: add layouts subdir
Bryan O'Sullivan <bryano@fb.com>
parents: 919
diff changeset
122 'hgsubversion.svnwrap'),
827
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
123 package_data={ 'hgsubversion': ['help/subversion.rst'] },
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
124 platforms='any',
563
09c016174e33 setup: work around easy_intall overzealously installing mercurial
Augie Fackler <durin42@gmail.com>
parents: 562
diff changeset
125 install_requires=requires,
827
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
126 classifiers=[
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
127 '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
128 'Intended Audience :: Developers',
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
129 'Topic :: Software Development :: Version Control',
553
97f2079e3778 setup: updates for release
Augie Fackler <durin42@gmail.com>
parents: 526
diff changeset
130 'Development Status :: 4 - Beta',
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
131 'Programming Language :: Python',
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
132 'Operating System :: OS Independent',
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
133 ],
827
076ded084655 setup.py: clean up indentation
Yonggang Luo <luoyonggang@gmail.com>
parents: 799
diff changeset
134 cmdclass={'build_py': build_py},
308
41aa4c3f789e A quick stab at a distutils installation script.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
135 )