Skip to content

Instantly share code, notes, and snippets.

@markmevans
Created February 11, 2014 00:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markmevans/8926906 to your computer and use it in GitHub Desktop.
Save markmevans/8926906 to your computer and use it in GitHub Desktop.
A hack for PyBuilder build.py files so `pyb publish` will work in a filesystem that does not support hardlinks (like VirtualBox shared filesystems.)
#
# Hack the distutils_plugin's SETUP_TEMPLATE to disable hardlinks.
#
import string
from pybuilder.core import init
from pybuilder.plugins.python import distutils_plugin
SDIST_MONKEY_PATCH = """
# sdist_hack: Remove reference to os.link to disable using hardlinks when
# building setup.py's sdist target. This is done because
# VirtualBox VMs shared filesystems don't support hardlinks.
import os
del os.link
"""
@init
def initialize_sdist_hack(project):
#
# Monkey patch distutils_plugin's SETUP_TEMPLATE to disable hardlinks.
#
setup_template_array = distutils_plugin.SETUP_TEMPLATE.template.split('\n')
setup_template_array.insert(1, SDIST_MONKEY_PATCH)
distutils_plugin.SETUP_TEMPLATE = string.Template(
'\n'.join(setup_template_array)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment