Fix use of bare repositories.
[jelmer/gitpython.git] / setup.py
1 from ez_setup import use_setuptools
2 use_setuptools()
3 from setuptools import setup, find_packages
4 from distutils.command.build_py import build_py as _build_py
5 from setuptools.command.sdist import sdist as _sdist
6 import os
7 from os import path
8
9 v = open(path.join(path.dirname(__file__), 'VERSION'))
10 VERSION = v.readline().strip()
11 v.close()
12
13 class build_py(_build_py):
14     def run(self):
15         init = path.join(self.build_lib, 'git', '__init__.py')
16         if path.exists(init):
17             os.unlink(init)
18         _build_py.run(self)
19         _stamp_version(init)
20         self.byte_compile([init])
21
22 class sdist(_sdist):
23     def make_release_tree (self, base_dir, files):
24         _sdist.make_release_tree(self, base_dir, files)
25         orig = path.join('lib', 'git', '__init__.py')
26         assert path.exists(orig)
27         dest = path.join(base_dir, orig)
28         if hasattr(os, 'link') and path.exists(dest):
29             os.unlink(dest)
30         self.copy_file(orig, dest)
31         _stamp_version(dest)
32
33 def _stamp_version(filename):
34     found, out = False, []
35     f = open(filename, 'r')
36     for line in f:
37         if '__version__ =' in line:
38             line = line.replace("'git'", "'%s'" % VERSION)
39             found = True
40         out.append(line)
41     f.close()
42
43     if found:
44         f = open(filename, 'w')
45         f.writelines(out)
46         f.close()
47
48
49 setup(name = "GitPython",
50       cmdclass={'build_py': build_py, 'sdist': sdist},
51       version = VERSION,
52       description = "Python Git Library",
53       author = "Michael Trier",
54       author_email = "mtrier@gmail.com",
55       url = "http://gitorious.org/projects/git-python/",
56       packages = find_packages('lib'),
57       package_dir = {'':'lib'},
58       license = "BSD License",
59       long_description = """\
60 GitPython is a python library used to interact with Git repositories.
61
62 GitPython provides object model access to your git repository. Once you have
63 created a repository object, you can traverse it to find parent commit(s),
64 trees, blobs, etc.
65
66 GitPython is a port of the grit library in Ruby created by 
67 Tom Preston-Werner and Chris Wanstrath.
68 """,
69       classifiers = [
70         "Development Status :: 3 - Alpha",
71         "Intended Audience :: Developers",
72         "License :: OSI Approved :: BSD License",
73         "Programming Language :: Python",
74         "Topic :: Software Development :: Libraries :: Python Modules",
75         ]
76       )