1
#!/usr/bin/env python
2
try:
3
	from setuptools import setup, find_packages
4
except ImportError:
5
	from ez_setup import use_setuptools
6
	use_setuptools()
7
	from setuptools import setup, find_packages
8
9
from distutils.command.build_py import build_py as _build_py
10
from setuptools.command.sdist import sdist as _sdist
11
import os
12
import sys
13
from os import path
14
15
v = open(path.join(path.dirname(__file__), 'VERSION'))
16
VERSION = v.readline().strip()
17
v.close()
18
19
20
class build_py(_build_py):
21
	def run(self):
22
		init = path.join(self.build_lib, 'git', '__init__.py')
23
		if path.exists(init):
24
			os.unlink(init)
25
		_build_py.run(self)
26
		_stamp_version(init)
27
		self.byte_compile([init])
28
29
30
class sdist(_sdist):
31
	def make_release_tree (self, base_dir, files):
32
		_sdist.make_release_tree(self, base_dir, files)
33
		orig = path.join('git', '__init__.py')
34
		assert path.exists(orig), orig
35
		dest = path.join(base_dir, orig)
36
		if hasattr(os, 'link') and path.exists(dest):
37
			os.unlink(dest)
38
		self.copy_file(orig, dest)
39
		_stamp_version(dest)
40
41
42
def _stamp_version(filename):
43
	found, out = False, list()
44
	try:
45
		f = open(filename, 'r')
46
	except (IOError, OSError):
47
		print >> sys.stderr, "Couldn't find file %s to stamp version" % filename
48
		return
49
	#END handle error, usually happens during binary builds
50
	for line in f:
51
		if '__version__ =' in line:
52
			line = line.replace("'git'", "'%s'" % VERSION)
53
			found = True
54
		out.append(line)
55
	f.close()
56
57
	if found:
58
		f = open(filename, 'w')
59
		f.writelines(out)
60
		f.close()
61
	else:
62
		print >> sys.stderr, "WARNING: Couldn't find version line in file %s" % filename
63
64
setup(name = "GitPython",
65
	  cmdclass={'build_py': build_py, 'sdist': sdist},
66
	  version = VERSION,
67
	  description = "Python Git Library",
68
	  author = "Sebastian Thiel, Michael Trier",
69
	  author_email = "byronimo@gmail.com, mtrier@gmail.com",
70
	  url = "http://gitorious.org/projects/git-python/",
71
	  packages = find_packages('.'),
72
	  py_modules = ['git.'+f[:-3] for f in os.listdir('./git') if f.endswith('.py')],
73
	  package_data = {'git.test' : ['fixtures/*']},
74
	  package_dir = {'git':'git'},
75
	  license = "BSD License",
76
	  requires=('gitdb (>=0.5.1)',),
77
	  install_requires='gitdb >= 0.5.1',
78
	  zip_safe=False,
79
	  long_description = """\
80
GitPython is a python library used to interact with Git repositories""",
81
	  classifiers = [
82
		"Development Status :: 4 - Beta",
83
		"Intended Audience :: Developers",
84
		"License :: OSI Approved :: BSD License",
85
		"Operating System :: OS Independent",
86
		"Programming Language :: Python",
87
		"Programming Language :: Python :: 2.5",
88
		"Programming Language :: Python :: 2.6",
89
		"Topic :: Software Development :: Libraries :: Python Modules",
90
		]
91
	  )