Hello, We've got a pretty specific setup where various Python scripts in /usr/bin are symlinked to a common wrapper. For example:
/usr/bin/easy_install -> python-exec
As a result, calling 'setup.py install' in a package that installs
setuptools' legacy script wrappers (e.g. setuptools itself) rewrites
python-exec (which -- shortly saying -- breaks a lot) rather than
replacing the 'easy_install' symlink.
I believe that the core issue is in command/easy_install.py. There,
the write_script() command writes directly onto the destination file
with no precautions:
if not self.dry_run:
ensure_directory(target)
f = open(target,"w"+mode)
f.write(contents)
f.close()
Therefore, if 'target' is a symlink, the symlink target is opened
rather than the expected path.
distutils itself is free of this issue since it removes the target
before writing (distutils/file_util.py):
if os.path.exists(dst):
try:
os.unlink(dst)
except os.error, (errno, errstr):
raise DistutilsFileError(
"could not delete '%s': %s" % (dst, errstr))
This suffers a race condition but is better than nothing. Other tools
usually create a temporary file in the target directory and use
rename() to atomically replace the target.
I'm willing to write a patch. Please just tell me which solution would
you prefer.
(please keep [email protected] in CC when replying)
--
Best regards,
Michał Górny
signature.asc
Description: PGP signature
_______________________________________________ Distutils-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/distutils-sig
