Generating Distutils MANIFEST file with hg manifest
Martin Geisler
mgeisler at mgeisler.net
Tue Oct 30 19:20:35 UTC 2007
Hello,
I have recently packaged my first Python project with Distutils, and
it worked well. But updating the MANIFEST.in file with new include
patterns when I add new directories to the repository seems silly, so
I have automated it.
The class below defines a new command which will use 'hg manifest' to
generate a preliminary list of files. The MANIFEST.in file is then
processed like normal to include/exclude more files.
from distutils.command.sdist import sdist
from distutils.core import setup
class hg_sdist(sdist):
def get_file_list(self):
try:
# Attempt the import here so that users can run the other
# Distutils commands without needing Mercurial.
from mercurial import hg
except ImportError:
from distutils.errors import DistutilsModuleError
raise DistutilsModuleError("could not import mercurial")
repo = hg.repository(None)
changeset = repo.changectx()
files = changeset.manifest().keys()
# Add the files *before* the normal manifest magic is done.
# That allows the manifest template to exclude some files
# tracked by hg and to include others.
self.filelist.extend(files)
sdist.get_file_list(self)
The command can replace the normal sdist command like this:
setup(cmdclass={'sdist': hg_sdist},
...
)
I have no experience with Distutils, and have not played with the
Mercurial code before --- so I would like any feedback you have on
this method.
I noticed that Mercurial is packaged in a similar way where the
MANIFEST is created from 'hg manifest' and then doc/MANIFEST is added.
--
Martin Geisler
Do your secure multi-party computations (SMPC) with VIFF,
the Virtual Ideal Functionality Framework.
Download at http://viff.dk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20071030/33dc301b/attachment.asc>
More information about the Mercurial-devel
mailing list