aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-07-21 12:14:42 -0400
committerJason R. Coombs <jaraco@jaraco.com>2016-07-21 12:14:42 -0400
commit9f77a068c02a3937762b8292c20e06d072247825 (patch)
tree44af03e2ab497cd3c60ae494a601bf97d9c556f5
parentbe2684d801b99757d35345809d6a0343ce863d75 (diff)
downloadexternal_python_setuptools-9f77a068c02a3937762b8292c20e06d072247825.tar.gz
external_python_setuptools-9f77a068c02a3937762b8292c20e06d072247825.tar.bz2
external_python_setuptools-9f77a068c02a3937762b8292c20e06d072247825.zip
Disable os.link during make_distribution. Fixes #516.
Note that better would be if sdist provided some sort of hooks to better control the file copying, but since it does not, this technique will suffice for now.
-rw-r--r--CHANGES.rst8
-rwxr-xr-xsetuptools/command/sdist.py27
2 files changed, 35 insertions, 0 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 63a634fb..b01a6fad 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -2,6 +2,14 @@
CHANGES
=======
+v24.3.0
+-------
+
+* #516: Disable ``os.link`` to avoid hard linking
+ in ``sdist.make_distribution``, avoiding errors on
+ systems that support hard links but not on the
+ file system in which the build is occurring.
+
v24.2.1
-------
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index 041ee42e..b86aae50 100755
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -4,6 +4,7 @@ import distutils.command.sdist as orig
import os
import sys
import io
+import contextlib
from setuptools.extern import six
@@ -65,6 +66,32 @@ class sdist(orig.sdist):
if data not in dist_files:
dist_files.append(data)
+ def make_distribution(self):
+ """
+ Workaround for #516
+ """
+ with self._remove_os_link():
+ orig.sdist.make_distribution(self)
+
+ @staticmethod
+ @contextlib.contextmanager
+ def _remove_os_link():
+ """
+ In a context, remove and restore os.link if it exists
+ """
+ class NoValue:
+ pass
+ orig_val = getattr(os, 'link', NoValue)
+ try:
+ del os.link
+ except Exception:
+ pass
+ try:
+ yield
+ finally:
+ if orig_val is not NoValue:
+ setattr(os, 'link', orig_val)
+
def __read_template_hack(self):
# This grody hack closes the template file (MANIFEST.in) if an
# exception occurs during read_template.