Commit 9f77a068 authored by Jason R. Coombs's avatar Jason R. Coombs

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.
parent be2684d8
......@@ -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
-------
......
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment