Last active
August 29, 2015 14:15
-
-
Save jackmaney/afcc8802283c8232e513 to your computer and use it in GitHub Desktop.
Using distutils to parse MANIFEST.in and grab files against the manifest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from https://github.com/python/cpython/blob/2.7/Lib/distutils/command/sdist.py#L386 | |
from distutils.text_file import TextFile | |
from distutils.filelist import FileList | |
template = TextFile("MANIFEST.in", strip_comments=1, skip_blanks=1, join_lines=1, lstrip_ws=1, rstrip_ws=1, collapse_join=1) | |
filelist = FileList() | |
try: | |
while True: | |
line = template.readline() | |
if line is None: | |
break | |
try: | |
filelist.process_template_line(line) | |
except: | |
print "Crap, couldn't process line: %s" % line | |
finally: | |
template.close() | |
# filelist.files now contains the files accepted by MANIFEST.in: | |
for file in filelist.files: | |
print file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment