From 9f77a068c02a3937762b8292c20e06d072247825 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 21 Jul 2016 12:14:42 -0400 Subject: 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. --- setuptools/command/sdist.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'setuptools/command/sdist.py') 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. -- cgit v1.2.3