[Distutils] distutils & AFS
Christian Pfaffel
flash@itp.tu-graz.ac.at
Thu Oct 17 07:35:03 2002
--=-=-=
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello!
I have a problem with using distutils on a filesystem residing on AFS.
AFS does not allow hard-linking across directory boundaries. So the
copy method from file_util.py using hard links files fails, e.g.:
# ./setup.py sdist
running sdist
reading manifest file 'MANIFEST'
making hard links in foo-1.0...
hard linking MANIFEST.in -> foo-1.0
error: Invalid cross-device link
The system I run is linux, thus it tries to hard link, I did not dig
too deep into file_util.py but I figured out that it is the link mode
which has to be set to None to make it working on AFS so that it
copies files.
I made a rather non elegant change to the code, which I attached. I am
sure that you can come up with a better solution. I do, unfortunately
not have the time, to fix it elsewhere.
Just wanted to let you know.
Best regards,
Christian Pfaffel
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=file_util.py.diff
Content-Description: patch for an ugly fix
--- /usr/lib/python2.2/distutils/file_util.py~ Fri Apr 12 21:30:22 2002
+++ /usr/lib/python2.2/distutils/file_util.py Wed Oct 16 17:30:04 2002
@@ -151,7 +151,20 @@
# (Unix only, of course, but that's the caller's responsibility)
elif link == 'hard':
if not (os.path.exists(dst) and os.path.samefile(src, dst)):
- os.link(src, dst)
+ try:
+ os.link(src, dst)
+ except:
+ _copy_file_contents(src, dst)
+ if preserve_mode or preserve_times:
+ st = os.stat(src)
+
+ # According to David Ascher <da@ski.org>, utime() should be done
+ # before chmod() (at least under NT).
+ if preserve_times:
+ os.utime(dst, (st[ST_ATIME], st[ST_MTIME]))
+ if preserve_mode:
+ os.chmod(dst, S_IMODE(st[ST_MODE]))
+
elif link == 'sym':
if not (os.path.exists(dst) and os.path.samefile(src, dst)):
os.symlink(src, dst)
--=-=-=
- --
PGP-Key: http://fubphpc.tu-graz.ac.at/~flash/pubkey.gpg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.7 <http://mailcrypt.sourceforge.net/>
iD8DBQE9rqAzzNp7/ndBhMQRAoO3AJ90Q77x3TUU6S/OaP/ehzKbFYrIWACcDBBZ
UK4XthK4zZjpSYRxxRCBoTY=
=bfqa
-----END PGP SIGNATURE-----
--=-=-=--