Skip to content

Commit

Permalink
Generate the MANIFEST file from git
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavid committed Jul 24, 2012
1 parent 5f4d98d commit 06969ba
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 77 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
MANIFEST
build
dist
pygit2.so
Expand Down
75 changes: 0 additions & 75 deletions MANIFEST

This file was deleted.

1 change: 0 additions & 1 deletion TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ Other
PyObject_Del or similar) if the type is subclassable. So, go through the
code and switch to tp_free, or make the type not subclassable, on a case by
case basis.
- Automatically generate the MANIFEST file using "git ls-files"
31 changes: 30 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@

"""Setup file for pygit2."""

from __future__ import print_function

import os
from subprocess import Popen, PIPE
import sys
from distutils.core import setup, Extension, Command
from distutils.command.build import build
from distutils.command.sdist import sdist
from distutils import log


# Use environment variable LIBGIT2 to set your own libgit2 configuration.
libgit2_path = os.getenv("LIBGIT2")
if libgit2_path is None:
Expand Down Expand Up @@ -117,7 +122,31 @@ def run(self):
self.copy_file(s, d)


cmdclass = {'test': TestCommand}
class sdist_files_from_git(sdist):
def get_file_list(self):
popen = Popen(['git', 'ls-files'], stdout=PIPE, stderr=PIPE)
stdoutdata, stderrdata = popen.communicate()
if popen.returncode != 0:
print(stderrdata)
sys.exit()

for line in stdoutdata.splitlines():
# Skip hidden files at the root
if line[0] == '.':
continue
self.filelist.append(line)

# Ok
self.filelist.sort()
self.filelist.remove_duplicates()
self.write_manifest()



cmdclass = {
'test': TestCommand,
'sdist': sdist_files_from_git}

if os.name == 'nt':
# BuildWithDLLs can copy external DLLs into source directory.
cmdclass['build'] = BuildWithDLLs
Expand Down

0 comments on commit 06969ba

Please sign in to comment.