def stage0(tmpdir):
    """STAGE 0: Prepare and install distribute via included (patched) distribute_setup.py script."""

    info("\n\n+++ STAGE 0: installing distribute via included (patched) distribute_setup.py...\n\n")

    txt = DISTRIBUTE_SETUP_PY
    if not print_debug:
        # silence distribute_setup.py by redirecting output to /dev/null
        txt = re.sub(r'([^\n]*)(return subprocess.call\(args)(\) == 0)',
                     r"\1f = open(os.devnull, 'w'); \2, stdout=f, stderr=f\3",
                     txt)
        # silence distribute_setup.py completely by setting high log level threshold
        txt = re.sub(r'([^\n]*)(# extracting the tarball[^\n]*)', r'\1log.set_verbosity(1000)\n\1\2', txt)

    # write distribute_setup.py to file (with correct header)
    distribute_setup = os.path.join(tmpdir, 'distribute_setup.py')
    f = open(distribute_setup, "w")
    f.write(txt)
    f.close()

    # create expected directories, set Python search path
    debug("preparing environment...")
    prep(tmpdir)

    import distribute_setup
    debug("distribute_setup.__file__: %s" % distribute_setup.__file__)

    # install easy_install to temporary directory
    from distribute_setup import main as distribute_setup_main
    orig_sys_argv = sys.argv[:]  # make a copy
    sys.argv.append('--prefix=%s' % tmpdir)
    # We download a custom version of distribute: it uses a newer version of markerlib to avoid a bug (#1099)
    # It's is the source of distribute 0.6.49 with the file _markerlib/markers.py replaced by the 0.6 version of
    # markerlib which can be found at https://pypi.python.org/pypi/markerlib/0.6.0
    sys.argv.append('--download-base=http://hpcugent.github.io/easybuild/files/')
    distribute_setup_main(version="0.6.49-patched1")
    sys.argv = orig_sys_argv

    # sanity check
    if os.path.exists(os.path.join(tmpdir, 'bin', 'easy_install')):
        debug("easy_install sanity check OK")
    else:
        error("Installing distribute which should deliver easy_install failed?")

    # prepend distribute egg dir to sys.path, so we know which setuptools we're using
    distribute_egg_dir = find_egg_dir_for(tmpdir, 'distribute')
    if distribute_egg_dir is None:
        error("Failed to determine egg dir path for distribute_egg_dir in %s" % tmpdir)
    else:
        sys.path.insert(0, distribute_egg_dir)

    # make sure we're getting the setuptools we expect
    import setuptools
    if tmpdir not in setuptools.__file__:
        error("Found another setuptools than expected: %s" % setuptools.__file__)
    else:
        debug("Found setuptools in expected path, good!")

    return distribute_egg_dir
Beispiel #2
0
def stage0(tmpdir):
    """STAGE 0: Prepare and install distribute via included (patched) distribute_setup.py script."""

    info("\n\n+++ STAGE 0: installing distribute via included (patched) distribute_setup.py...\n\n")

    txt = DISTRIBUTE_SETUP_PY
    if not print_debug:
        # silence distribute_setup.py by redirecting output to /dev/null
        txt = re.sub(r'([^\n]*)(return subprocess.call\(args)(\) == 0)',
                     r"\1f = open(os.devnull, 'w'); \2, stdout=f, stderr=f\3",
                     txt)
        # silence distribute_setup.py completely by setting high log level threshold
        txt = re.sub(r'([^\n]*)(# extracting the tarball[^\n]*)', r'\1log.set_verbosity(1000)\n\1\2', txt)

    # write distribute_setup.py to file (with correct header)
    distribute_setup = os.path.join(tmpdir, 'distribute_setup.py')
    f = open(distribute_setup, "w")
    f.write(txt)
    f.close()

    # create expected directories, set Python search path
    debug("preparing environment...")
    prep(tmpdir)

    import distribute_setup
    debug("distribute_setup.__file__: %s" % distribute_setup.__file__)

    # install easy_install to temporary directory
    from distribute_setup import main as distribute_setup_main
    orig_sys_argv = sys.argv[:]  # make a copy
    sys.argv.append('--prefix=%s' % tmpdir)
    distribute_setup_main()
    sys.argv = orig_sys_argv

    # sanity check
    if os.path.exists(os.path.join(tmpdir, 'bin', 'easy_install')):
        debug("easy_install sanity check OK")
    else:
        error("Installing distribute which should deliver easy_install failed?")

    # prepend distribute egg dir to sys.path, so we know which setuptools we're using
    distribute_egg_dir = find_egg_dir_for(tmpdir, 'distribute')
    if distribute_egg_dir is None:
        error("Failed to determine egg dir path for distribute_egg_dir in %s" % tmpdir)
    else:
        sys.path.insert(0, distribute_egg_dir)

    # make sure we're getting the setuptools we expect
    import setuptools
    if not tmpdir in setuptools.__file__:
        error("Found another setuptools than expected: %s" % setuptools.__file__)
    else:
        debug("Found setuptools in expected path, good!")

    return distribute_egg_dir
def stage0(tmpdir):
    """STAGE 0: Prepare and install distribute via included (patched) distribute_setup.py script."""

    info("\n\n+++ STAGE 0: installing distribute via included (patched) distribute_setup.py...\n\n")

    txt = DISTRIBUTE_SETUP_PY
    if not print_debug:
        # silence distribute_setup.py by redirecting output to /dev/null
        txt = re.sub(r'([^\n]*)(return subprocess.call\(args)(\) == 0)',
                     r"\1f = open(os.devnull, 'w'); \2, stdout=f, stderr=f\3",
                     txt)
        # silence distribute_setup.py completely by setting high log level threshold
        txt = re.sub(r'([^\n]*)(# extracting the tarball[^\n]*)', r'\1log.set_verbosity(1000)\n\1\2', txt)

    # write distribute_setup.py to file (with correct header)
    distribute_setup = os.path.join(tmpdir, 'distribute_setup.py')
    f = open(distribute_setup, "w")
    f.write(txt)
    f.close()

    # create expected directories, set Python search path
    debug("preparing environment...")
    prep(tmpdir)

    import distribute_setup
    debug("distribute_setup.__file__: %s" % distribute_setup.__file__)

    # install easy_install to temporary directory
    from distribute_setup import main as distribute_setup_main
    orig_sys_argv = sys.argv[:]  # make a copy
    sys.argv.append('--prefix=%s' % tmpdir)
    distribute_setup_main()
    sys.argv = orig_sys_argv

    # sanity check
    if os.path.exists(os.path.join(tmpdir, 'bin', 'easy_install')):
        debug("easy_install sanity check OK")
    else:
        error("Installing distribute which should deliver easy_install failed?")

    # prepend distribute egg dir to sys.path, so we know which setuptools we're using
    sys.path.insert(0, find_egg_dir_for(tmpdir, 'distribute'))

    # make sure we're getting the setuptools we expect
    import setuptools
    if not tmpdir in setuptools.__file__:
        error("Found another setuptools than expected: %s" % setuptools.__file__)
    else:
        debug("Found setuptools in expected path, good!")
def stage0(tmpdir):
    """STAGE 0: Prepare and install distribute via included (patched) distribute_setup.py script."""

    print('\n')
    info("+++ STAGE 0: installing distribute via included (patched) distribute_setup.py...\n")

    txt = DISTRIBUTE_SETUP_PY
    if not print_debug:
        # silence distribute_setup.py by redirecting output to /dev/null
        txt = re.sub(r'([^\n]*)(return subprocess.call\(args)(\) == 0)',
                     r"\1f = open(os.devnull, 'w'); \2, stdout=f, stderr=f\3",
                     txt)
        # silence distribute_setup.py completely by setting high log level threshold
        txt = re.sub(r'([^\n]*)(# extracting the tarball[^\n]*)', r'\1log.set_verbosity(1000)\n\1\2', txt)

    # write distribute_setup.py to file (with correct header)
    distribute_setup = os.path.join(tmpdir, 'distribute_setup.py')
    f = open(distribute_setup, "w")
    f.write(txt)
    f.close()

    # create expected directories, set Python search path
    debug("preparing environment...")
    prep(tmpdir)

    import distribute_setup
    debug("distribute_setup.__file__: %s" % distribute_setup.__file__)

    # install easy_install to temporary directory
    from distribute_setup import main as distribute_setup_main
    orig_sys_argv = sys.argv[:]  # make a copy
    sys.argv.append('--prefix=%s' % tmpdir)
    # We download a custom version of distribute: it uses a newer version of markerlib to avoid a bug (#1099)
    # It's is the source of distribute 0.6.49 with the file _markerlib/markers.py replaced by the 0.6 version of
    # markerlib which can be found at https://pypi.python.org/pypi/markerlib/0.6.0
    sys.argv.append('--download-base=http://hpcugent.github.io/easybuild/files/')
    distribute_setup_main(version="0.6.49-patched1")
    sys.argv = orig_sys_argv

    # sanity check
    if os.path.exists(os.path.join(tmpdir, 'bin', 'easy_install')):
        debug("easy_install sanity check OK")
    else:
        error("Installing distribute which should deliver easy_install failed?")

    # prepend distribute egg dir to sys.path, so we know which setuptools we're using
    distribute_egg_dir = find_egg_dir_for(tmpdir, 'distribute')
    if distribute_egg_dir is None:
        error("Failed to determine egg dir path for distribute_egg_dir in %s" % tmpdir)
    else:
        sys.path.insert(0, distribute_egg_dir)

    # make sure we're getting the setuptools we expect
    import setuptools
    from setuptools.command import easy_install

    for mod, path in [('setuptools', setuptools.__file__), ('easy_install', easy_install.__file__)]:
        if tmpdir not in path:
            error("Found another %s module than expected: %s" % (mod, path))
        else:
            debug("Found %s in expected path, good!" % mod)

    info("Installed setuptools version %s (%s)" % (setuptools.__version__, setuptools.__file__))

    return distribute_egg_dir