bootstrap 1.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#!/usr/bin/python3 -S
import glob, os, shutil, sys, tarfile, tempfile, zipfile
dist = "download-cache/dist"
tmp = tempfile.mkdtemp()
try:
    setuptools, = glob.glob(dist + "/setuptools-*")
    if setuptools.endswith(".zip"):
        zipfile.ZipFile(setuptools).extractall(tmp)
    else:
        tarfile.TarFile.open(setuptools, "r:*").extractall(tmp)
    x, = os.listdir(tmp)
    sys.path.insert(0, os.path.join(tmp, x))
    from setuptools.command.easy_install import main
    for x in "bin", "eggs":
        try:
            os.mkdir(x)
        except OSError:
            pass
    main(["-f", dist, "-mxd", x, setuptools, "zc.buildout"])
finally:
  shutil.rmtree(tmp)

with os.fdopen(os.open("bin/buildout", os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0o777), 'w') as f:
    f.write("""\
#!%s -S
import os, sys
d = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
d = os.path.dirname(d) + %r
sys.path[:0] = (%s)
from zc.buildout.buildout import main
sys.exit(main())
""" % (
    sys.executable,
    "/%s/" % x,
    ", ".join(map("d + %r".__mod__, os.listdir(x))),
    ))