[Distutils] Hardlinks v copying
mal at egenix.com
Thu Aug 18 14:35:09 CEST 2005
Bo Nygaard Bai wrote:
> I was trying to use the distutils sdist target on an AFS mounted
> filesystem on Linux. It fails because it can't make hard links between
> directories on AFS (you can inside a directory). I have not been able
> to find any options to make it copy the files instead.
> 1) Is there a way for me to force it to copy the files into the
> temporary directory instead of using hard links?
> 2) Given that it is very hard to predict whether a particular usage of
> hard links is possible on any given OS/filesystem/mount combination.
> It seems to me that the best strategy would be to try to make the
> hard links, and if this fails, silently fall back to making a copy.
How do you test whether a hard link works ? I suppose
this would have to be made based on the path since you
have mixed setups where some parts of the file system
tree allow hard links where others don't.
I don't find hard links all that useful. Disk space
is cheap and they often cause problems (e.g. in our
case with symlinks in the source tree).
Here's a quick hack:
This is more elegant, but requires extra work:
""" Build a source distribution.
This version does not use hard links when preparing the source
archive - hard links don't match well with symlinks which we
use in our source repositories.
def make_release_tree (self, base_dir, files):
# Prepare release dir
if not files:
log.warn('no files found in release !')
# Create dir structure
log.info('preparing release tree in %s...' % base_dir)
create_tree(base_dir, files, dry_run=self.dry_run)
for file in files:
if not os.path.isfile(file):
log.warn('%s is not a regular file -- skipping' % file)
dest = os.path.join(base_dir, file)
self.copy_file(file, dest, link=None)
and then register this command class as replacement for
Professional Python Services directly from the Source (#1, Aug 18 2005)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the Distutils-SIG