Exemplo n.º 1
0
    def _create_package_and_reference(self, bento_info, r_bento_info):
        pkg = PackageDescription.from_string(bento_info)
        node_pkg = NodeRepresentation(self.run_node, self.top_node)
        node_pkg.update_package(pkg)

        r_pkg = PackageDescription.from_string(r_bento_info)
        r_node_pkg = NodeRepresentation(self.run_node, self.top_node)
        r_node_pkg.update_package(r_pkg)

        return node_pkg, r_node_pkg
Exemplo n.º 2
0
    def _create_package_and_reference(self, bento_info, r_bento_info):
        pkg = PackageDescription.from_string(bento_info)
        node_pkg = NodeRepresentation(self.run_node, self.top_node)
        node_pkg.update_package(pkg)

        r_pkg = PackageDescription.from_string(r_bento_info)
        r_node_pkg = NodeRepresentation(self.run_node, self.top_node)
        r_node_pkg.update_package(r_pkg)

        return node_pkg, r_node_pkg
Exemplo n.º 3
0
def generate_version_py(filename):
    pkg = PackageDescription.from_file("bento.info")

    FULL_VERSION = pkg.version
    if "dev" in FULL_VERSION:
        RELEASED = False
    else:
        RELEASED = True

    try:
        if os.path.exists(".git"):
            s = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
            out = s.communicate()[0]
            GIT_REVISION = out.decode().strip()
        else:
            GIT_REVISION = ""
    except WindowsError:
        GIT_REVISION = ""

    cnt = """\
# This file was autogenerated
version = '%s'
git_revision = '%s'
"""
    cnt = cnt % (FULL_VERSION, GIT_REVISION)

    f = open(filename, "w")
    try:
        f.write(cnt)
    finally:
        f.close()

    return FULL_VERSION, GIT_REVISION
Exemplo n.º 4
0
    def _compute_scheme(self, bento_info, options):
        package_options = PackageOptions.from_string(bento_info)
        pkg = PackageDescription.from_string(bento_info)
        scheme = _compute_scheme(package_options)
        set_scheme_win32(scheme, options, pkg)

        return scheme
Exemplo n.º 5
0
def run_cmd(global_context, cached_package, cmd_name, cmd_argv, run_node,
            top_node, build_node):
    cmd = global_context.retrieve_command(cmd_name)

    # XXX: fix this special casing (commands which do not need a pkg instance)
    if cmd_name in ["help", "convert"]:
        global_context.run_command(cmd_name, cmd_argv, PackageDescription(),
                                   run_node)
        return

    if is_help_only(global_context, cmd_name, cmd_argv):
        options_context = global_context.retrieve_options_context(cmd_name)
        options_context.parser.print_help()
        return

    bento_info = top_node.find_node(BENTO_SCRIPT)
    if bento_info is None:
        raise bento.errors.UsageException(
            "Error: no %s found !" %
            os.path.join(top_node.abspath(), BENTO_SCRIPT))

    running_package = get_running_package(global_context, cached_package,
                                          bento_info)
    run_with_dependencies(global_context, cmd_name, cmd_argv, run_node,
                          top_node, running_package)

    global_context.save_command_argv(cmd_name, cmd_argv)
    global_context.store()
Exemplo n.º 6
0
    def _compute_scheme(self, bento_info, options):
        package_options = PackageOptions.from_string(bento_info)
        pkg = PackageDescription.from_string(bento_info)
        scheme = _compute_scheme(package_options)
        set_scheme_win32(scheme, options, pkg)

        return scheme
Exemplo n.º 7
0
Arquivo: utils.py Projeto: pv/bento
def prepare_package(top_node, bento_info, backend=None):
    package = PackageDescription.from_string(bento_info)
    package_options = PackageOptions.from_string(bento_info)

    create_fake_package_from_bento_info(top_node, bento_info)
    top_node.make_node("bento.info").safe_write(bento_info)

    return create_global_context(package, package_options, backend)
Exemplo n.º 8
0
def use_waf(d):
    old_cwd = os.getcwd()
    try:
        os.chdir(d)
        package = PackageDescription.from_file("bento.info")
        return "Waf" in package.use_backends
    finally:
        os.chdir(old_cwd)
Exemplo n.º 9
0
def use_waf(d):
    old_cwd = os.getcwd()
    try:
        os.chdir(d)
        package = PackageDescription.from_file("bento.info")
        return "Waf" in package.use_backends
    finally:
        os.chdir(old_cwd)
Exemplo n.º 10
0
def prepare_package(top_node, bento_info, backend=None):
    package = PackageDescription.from_string(bento_info)
    package_options = PackageOptions.from_string(bento_info)

    create_fake_package_from_bento_info(top_node, bento_info)
    top_node.make_node("bento.info").safe_write(bento_info)

    return create_global_context(package, package_options, backend)
Exemplo n.º 11
0
def distutils_to_package_description(dist):
    root = bento.core.node.Node("", None)
    top = root.find_dir(os.getcwd())

    data = {}

    data['name'] = dist.get_name()
    data['version'] = dist.get_version()
    data['author'] = dist.get_author()
    data['author_email'] = dist.get_author_email()
    data['maintainer'] = dist.get_contact()
    data['maintainer_email'] = dist.get_contact_email()
    data['summary'] = dist.get_description()
    data['description'] = dist.get_long_description().replace("#", "\#")
    data['license'] = dist.get_license()
    data['platforms'] = dist.get_platforms()

    data['download_url'] = dist.get_download_url()
    data['url'] = dist.get_url()

    # XXX: reliable way to detect whether Distribution was monkey-patched by
    # setuptools
    try:
        reqs = getattr(dist, "install_requires")
        # FIXME: how to detect this correctly
        if is_string(reqs):
            reqs = [reqs]
        data['install_requires'] = reqs
    except AttributeError:
        pass

    if dist.py_modules is None:
        data['py_modules'] = []
    else:
        data['py_modules'] = dist.py_modules
    if dist.packages is None:
        packages = []
    else:
        packages = dist.packages
    data['packages'] = validate_packages(packages, top)
    if dist.ext_modules:
        data['extensions'] = dict([(e.name, e) for e in dist.ext_modules])
    else:
        data['extensions'] = {}
    data['classifiers'] = dist.get_classifiers()

    data["executables"] = {}

    entry_points = entry_points_from_dist(dist)
    if entry_points:
        console_scripts = entry_points.get("console_scripts", [])
        for entry in console_scripts:
            exe = Executable.from_representation(entry)
            data["executables"][exe.name] = exe

    return PackageDescription(**data)
Exemplo n.º 12
0
    def test_simple_no_cython(self):
        bento_info = """\
Library:
    Extension: foo
        Sources: foo1.c, foo2.c
"""
        bentos = {"bento.info": bento_info}
        create_fake_package_from_bento_infos(self.run_node, bentos)

        pkg = PackageDescription.from_string(bento_info)
        self.assertFalse(has_cython_code(pkg))
Exemplo n.º 13
0
    def test_simple_no_cython(self):
        bento_info = """\
Library:
    Extension: foo
        Sources: foo1.c, foo2.c
"""
        bentos = {"bento.info": bento_info}
        create_fake_package_from_bento_infos(self.run_node, bentos)

        pkg = PackageDescription.from_string(bento_info)
        self.assertFalse(has_cython_code(pkg))
Exemplo n.º 14
0
    def test_simple(self):
        help = HelpCommand()
        options = OptionsContext()
        for option in HelpCommand.common_options:
            options.add_option(option)
        global_context = GlobalContext(None,
                commands_registry=self.registry,
                options_registry=self.options_registry)
        pkg = PackageDescription()
        context = HelpContext(global_context, [], options, pkg, self.run_node)

        run_command_in_context(context, help)
Exemplo n.º 15
0
    def test_recurse(self):
        """Check that we raise a proper exception when mixing recurse and
        sub_directory features."""
        bento_info = """\
Name: foo

Recurse: bar

Library:
    SubDirectory: lib
"""
        self.assertRaises(InvalidPackage, lambda: PackageDescription.from_string(bento_info))
Exemplo n.º 16
0
    def test_recurse(self):
        """Check that we raise a proper exception when mixing recurse and
        sub_directory features."""
        bento_info = """\
Name: foo

Recurse: bar

Library:
    SubDirectory: lib
"""
        self.assertRaises(InvalidPackage,
                          lambda: PackageDescription.from_string(bento_info))
Exemplo n.º 17
0
    def _test_register_server_errors(self):
        package = PackageDescription(name="foo")
        config = PyPIConfig.from_string("""
[distutils]
index-servers = pypi

[pypi]
username = cdavid
password = yoyo
server = http://testpypi.python.org
""")

        post_data = build_post_data(package, "submit")
        return post_to_server(post_data, config)
Exemplo n.º 18
0
    def test_register_server(self):
        package = PackageDescription(name="foo")
        repository = 'http://testpypi.python.org/pypi'
        realm = DEFAULT_REALM
        config = PyPIConfig(username="******", password="******", repository=repository, realm=realm)

        auth = HTTPPasswordMgr()
        host = urlparse(config.repository)[0]
        auth.add_password(config.realm, host, config.username, config.password)

        post_data = build_post_data(package, "submit")
        code, msg = post_to_server(post_data, config, auth)
        self.assertEqual(code, 200)
        self.assertEqual(msg, "OK")
Exemplo n.º 19
0
Arquivo: utils.py Projeto: pv/bento
def _prepare_command(run_node, bento_info, cmd_klass, context_klass, cmd_argv):
    top_node = run_node._ctx.srcnode
    top_node.make_node("bento.info").safe_write(bento_info)

    package = PackageDescription.from_string(bento_info)
    package_options = PackageOptions.from_string(bento_info)

    cmd = cmd_klass()
    options_context = OptionsContext.from_command(cmd)

    cmd.register_options(options_context, package_options)

    global_context = GlobalContext(None)
    global_context.register_package_options(package_options)

    context = context_klass(global_context, cmd_argv, options_context, package, run_node)
    return context, cmd
Exemplo n.º 20
0
def _prepare_command(run_node, bento_info, cmd_klass, context_klass, cmd_argv):
    top_node = run_node._ctx.srcnode
    top_node.make_node("bento.info").safe_write(bento_info)

    package = PackageDescription.from_string(bento_info)
    package_options = PackageOptions.from_string(bento_info)

    cmd = cmd_klass()
    options_context = OptionsContext.from_command(cmd)

    cmd.register_options(options_context, package_options)

    global_context = GlobalContext(None)
    global_context.register_package_options(package_options)

    context = context_klass(global_context, cmd_argv, options_context, package, run_node)
    return context, cmd
Exemplo n.º 21
0
    def test_sub_package(self):
        bento_info = """\
Recurse: foo

Library:
    Extension: foo
        Sources: foo1.c
"""
        bento_sub1_info = """
Library:
    Extension: bar
        Sources: bar.pyx
"""
        bentos = {"bento.info": bento_info, op.join("foo", "bento.info"): bento_sub1_info}
        create_fake_package_from_bento_infos(self.run_node, bentos)

        pkg = PackageDescription.from_string(bento_info)
        self.assertTrue(has_cython_code(pkg))
Exemplo n.º 22
0
    def test_sub_package(self):
        bento_info = """\
Recurse: foo

Library:
    Extension: foo
        Sources: foo1.c
"""
        bento_sub1_info = """
Library:
    Extension: bar
        Sources: bar.pyx
"""
        bentos = {"bento.info": bento_info, op.join("foo", "bento.info"): bento_sub1_info}
        create_fake_package_from_bento_infos(self.run_node, bentos)

        pkg = PackageDescription.from_string(bento_info)
        self.assertTrue(has_cython_code(pkg))
Exemplo n.º 23
0
    def test_build_post_data(self):
        r_content = six.b(
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="maintainer"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="name"\r\n\r\n"""
            """foo\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="license"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="author"\r\n\r\n"""
            """John Doe\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="url"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name=":action"\r\n\r\n"""
            """submit\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="download_url"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="maintainer_email"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="author_email"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="version"\r\n\r\n"""
            """1.0\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="long_description"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="description"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254--\r\n"""
            """"""
        )
        bento_info = """\
Name: foo
Version: 1.0
Author: John Doe
"""
        package = PackageDescription.from_string(bento_info)
        post_data = build_post_data(package, "submit")
        content_type, body = encode_multipart(post_data.items(), [])
        self.assertEqual(r_content, body)
Exemplo n.º 24
0
def prepare_configure(run_node, bento_info, context_klass=ConfigureYakuContext, cmd_argv=None):
    if cmd_argv is None:
        cmd_argv = []

    top_node = run_node._ctx.srcnode
    top_node.make_node("bento.info").safe_write(bento_info)

    package = PackageDescription.from_string(bento_info)
    package_options = PackageOptions.from_string(bento_info)

    configure = ConfigureCommand()
    opts = OptionsContext.from_command(configure)

    # FIXME: this emulates the big ugly hack inside bentomaker.
    _setup_options_parser(opts, package_options)

    context = context_klass(None, cmd_argv, opts, package, run_node)
    context.package_options = package_options

    return context, configure
Exemplo n.º 25
0
    def test_build_post_data(self):
        r_content = six.b("""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="maintainer"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="name"\r\n\r\n""" \
"""foo\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="license"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="author"\r\n\r\n""" \
"""John Doe\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="url"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name=":action"\r\n\r\n""" \
"""submit\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="download_url"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="maintainer_email"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="author_email"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="version"\r\n\r\n""" \
"""1.0\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="long_description"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="description"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254--\r\n""" \
"""""")
        bento_info = """\
Name: foo
Version: 1.0
Author: John Doe
"""
        package = PackageDescription.from_string(bento_info)
        post_data = build_post_data(package, "submit")
        content_type, body = encode_multipart(list(post_data.items()), [])
        self.assertEqual(r_content, body)
Exemplo n.º 26
0
        sources: src/dog.c
"""

PKG = PackageDescription(
    name="Sphinx",
    version="0.6.3",
    summary="Python documentation generator",
    url="http://sphinx.pocoo.org/",
    download_url="http://pypi.python.org/pypi/Sphinx",
    description="Some long description.",
    author="Georg Brandl",
    author_email="*****@*****.**",
    maintainer="Georg Brandl",
    maintainer_email="*****@*****.**",
    license="BSD",
    platforms=["any"],
    classifiers=[
        "Development Status :: 4 - Beta",
        "Environment :: Console",
        "Environment :: Web Environment",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: BSD License",
        "Operating System :: OS Independent",
        "Programming Language :: Python",
        "Topic :: Documentation",
        "Topic :: Utilities",],
    py_modules=["cat.py"],
    packages=["sphinx", "sphinx.builders"],
    extensions={"_dog": Extension(name="_dog", sources=["src/dog.c"])},
)
Exemplo n.º 27
0
    stat.S_IROTH | stat.S_IXOTH

root = create_root_with_source_tree(os.getcwd(), os.path.join(os.getcwd(), "build"))

def _create_executable(name, executable, scripts_node):
    if sys.platform == "win32":
        nodes = create_win32_script(name, executable, scripts_node)
    else:
        nodes = create_posix_script(name, executable, scripts_node)
        for n in nodes:
            n.chmod(MODE_755)
    return nodes

def install_inplace(pkg):
    """Install scripts of pkg in the current directory."""
    for basename, executable in pkg.executables.items():
        version_str = ".".join([str(i) for i in sys.version_info[:2]])
        scripts_node = root._ctx.srcnode
        for name in [basename, "%s-%s" % (basename, version_str)]:
            nodes = _create_executable(name, executable, scripts_node)
            installed = ",".join([n.path_from(scripts_node) for n in nodes])
            pprint("GREEN", "installing %s in current directory" % installed)

if __name__ == "__main__":
    from setup_common import generate_version_py
    generate_version_py("bento/__dev_version.py")

    pkg = PackageDescription.from_file("bento.info")
    if pkg.executables:
        install_inplace(pkg)
Exemplo n.º 28
0
def main():
    pkg = PackageDescription.from_file("bento.info")
    if pkg.executables:
        install_inplace(pkg)
Exemplo n.º 29
0
from distutils.core import setup
from bento.core import PackageDescription
from bento.conv import pkg_to_distutils

pkg = PackageDescription.from_file("bento.info")
setup(**pkg_to_distutils(pkg))
Exemplo n.º 30
0
def create_script(config):
    import tarfile, re

    script_name = config["script_name"]
    extra_files = config["extra_files"]
    print(("Creating self-contained script %r in %s" %
           (script_name, os.getcwd())))
    mw = "tmp-foo-" + VERSION

    zip_type = "bz2"

    tar = tarfile.open('%s.tar.%s' % (mw, zip_type), "w:%s" % zip_type)

    # List of (source, arcname) pairs
    files = []
    nodes = []

    cwd_node = ROOT.find_node(os.getcwd())

    def list_nodes(packages, base_node=cwd_node):
        nodes = []
        for package_name in packages:
            init = os.path.join(*(package_name.split(".") + ["__init__.py"]))
            n = base_node.find_node(init)
            if n is None:
                raise IOError("init file for package %s not found (looked for %r)!" \
                              % (package_name, init))
            else:
                p = n.parent
                nodes.extend(
                    p.find_node(f) for f in p.listdir() if f.endswith(".py"))
        return nodes

    package = PackageDescription.from_file("bento.info",
                                           user_flags={
                                               "bundle": True,
                                               "bundle_yaku": True
                                           })
    nodes.extend(list_nodes(package.packages))

    for module in package.py_modules:
        n = cwd_node.find_node(module + ".py")
        if n is None:
            raise IOError("init file for package %s not found (looked for %r)!" \
                          % (package_name, init))
        else:
            nodes.append(n)

    files.extend([(n.abspath(), n.path_from(cwd_node)) for n in nodes])

    if config["include_waf"]:
        base_dir = config["waf"]["base_dir"]
        packages = config["waf"]["packages"]
        base_node = ROOT.find_node(op.expanduser(base_dir))
        if base_node is None:
            raise ValueError("Waf base dir not found (misconfigured ?): %s" %
                             base_dir)
        nodes = list_nodes(packages, base_node)
        files.extend([(n.abspath(), n.path_from(base_node)) for n in nodes])

    for pattern in extra_files:
        for f in glob.glob(pattern):
            files.append((f, f))

    for name, arcname in files:
        tarinfo = tar.gettarinfo(name, arcname)
        tarinfo.uid = tarinfo.gid = 1000
        tarinfo.uname = tarinfo.gname = "baka"
        (code, size, cnt) = sfilter(name)
        tarinfo.size = size
        tar.addfile(tarinfo, code)
    tar.close()

    variables = {}
    for k in [
            "script_name", "script_pkg_root", "script_version",
            "script_entry_point"
    ]:
        variables[k] = config[k]
    variables["script_name"] = "'%s'" % variables["script_name"]
    variables["script_pkg_root"] = "'%s'" % variables["script_pkg_root"]

    code1 = create_script_light(config["script_template"], variables)

    f = open("%s.tar.%s" % (mw, zip_type), 'rb')
    cnt = f.read()
    f.close()

    m = md5()
    m.update(cnt)
    REVISION = m.hexdigest()
    reg = re.compile('^REVISION=(.*)', re.M)
    code1 = reg.sub(r'REVISION="%s"' % REVISION, code1)

    f = open(script_name, 'wb')
    #f.write(code1.replace("C1='x'", "C1='%s'" % C1).replace("C2='x'", "C2='%s'" % C2))
    f.write(code1)
    f.write('#==>\n')
    f.write('#')
    f.write(base64.b64encode(cnt))
    f.write('\n')
    f.write('#<==\n')
    f.close()

    if sys.platform != 'win32':
        from bento.utils.utils import MODE_755
        os.chmod(script_name, MODE_755)
    os.unlink('%s.tar.%s' % (mw, zip_type))
Exemplo n.º 31
0
def create_script(config):
    import tarfile, re

    script_name = config["script_name"]
    extra_files = config["extra_files"]
    print("Creating self-contained script %r in %s" % (script_name, os.getcwd()))
    mw = "tmp-foo-" + VERSION

    zip_type = "bz2"

    tar = tarfile.open('%s.tar.%s' % (mw, zip_type), "w:%s" % zip_type)

    # List of (source, arcname) pairs
    files = []
    nodes = []

    cwd_node = ROOT.find_node(os.getcwd())

    def list_nodes(packages, base_node=cwd_node):
        nodes = []
        for package_name in packages:
            init = os.path.join(*(package_name.split(".") + ["__init__.py"]))
            n = base_node.find_node(init)
            if n is None:
                raise IOError("init file for package %s not found (looked for %r)!" \
                              % (package_name, init))
            else:
                p = n.parent
                nodes.extend(p.find_node(f) for f in p.listdir() if f.endswith(".py"))
        return nodes

    package = PackageDescription.from_file("bento.info", user_flags={"bundle": True, "bundle_yaku": True})
    nodes.extend(list_nodes(package.packages))

    for module in package.py_modules:
        n = cwd_node.find_node(module + ".py")
        if n is None:
            raise IOError("init file for package %s not found (looked for %r)!" \
                          % (package_name, init))
        else:
            nodes.append(n)

    files.extend([(n.abspath(), n.path_from(cwd_node)) for n in nodes])

    if config["include_waf"]:
        base_dir = config["waf"]["base_dir"]
        packages = config["waf"]["packages"]
        base_node = ROOT.find_node(op.expanduser(base_dir))
        if base_node is None:
            raise ValueError("Waf base dir not found (misconfigured ?): %s" % base_dir)
        nodes = list_nodes(packages, base_node)
        files.extend([(n.abspath(), n.path_from(base_node)) for n in nodes])

    for pattern in extra_files:
        for f in glob.glob(pattern):
            files.append((f, f))

    for name, arcname in files:
        tarinfo = tar.gettarinfo(name, arcname)
        tarinfo.uid = tarinfo.gid = 1000
        tarinfo.uname = tarinfo.gname = "baka"
        (code, size, cnt) = sfilter(name)
        tarinfo.size = size
        tar.addfile(tarinfo, code)
    tar.close()

    variables = {}
    for k in ["script_name", "script_pkg_root", "script_version", "script_entry_point"]:
        variables[k] = config[k]
    variables["script_name"] = "'%s'" % variables["script_name"]
    variables["script_pkg_root"] = "'%s'" % variables["script_pkg_root"]

    code1 = create_script_light(config["script_template"], variables)

    f = open("%s.tar.%s" % (mw, zip_type), 'rb')
    cnt = f.read()
    f.close()

    m = md5()
    m.update(cnt)
    REVISION = m.hexdigest()
    reg = re.compile('^REVISION=(.*)', re.M)
    code1 = reg.sub(r'REVISION="%s"' % REVISION, code1)

    f = open(script_name, 'wb')
    #f.write(code1.replace("C1='x'", "C1='%s'" % C1).replace("C2='x'", "C2='%s'" % C2))
    f.write(code1)
    f.write('#==>\n')
    f.write('#')
    f.write(base64.b64encode(cnt))
    f.write('\n')
    f.write('#<==\n')
    f.close()

    if sys.platform != 'win32':
        from bento.utils.utils import MODE_755
        os.chmod(script_name, MODE_755)
    os.unlink('%s.tar.%s' % (mw, zip_type))