示例#1
0
def generate_setup_py(target, source, env):
    tile = env['TILE']
    data = {}

    # Figure out the packages and modules that we need to put in this package
    typelibs = [os.path.basename(x) for x in tile.type_packages()]

    # Now figure out all of the entry points that group type_packages, proxy_plugins and proxy_modules
    # and allow us to find them.

    entry_points = {}

    modentries = [os.path.splitext(os.path.basename(x))[0] for x in tile.proxy_modules()]
    pluginentries = [os.path.splitext(os.path.basename(x))[0] for x in tile.proxy_plugins()]
    appentries = [os.path.splitext(os.path.basename(x))[0] for x in tile.app_modules()]

    buildentries = tile.build_steps()
    buildentry_parsed = [x.split(':') for x in buildentries]
    buildentries = [(os.path.splitext(os.path.basename(x[0]))[0], x[1]) for x in buildentry_parsed]

    if len(modentries) > 0:
        entry_points['iotile.proxy'] = ["{0} = {1}.{0}".format(x, tile.support_distribution) for x in modentries]
    if len(pluginentries) > 0:
        entry_points['iotile.proxy_plugin'] = ["{0} = {1}.{0}".format(x, tile.support_distribution) for x in pluginentries]
    if len(typelibs) > 0:
        entry_points['iotile.type_package'] = ["{0} = {1}.{0}".format(x, tile.support_distribution) for x in typelibs]
    if len(appentries) > 0:
        entry_points['iotile.app'] = ["{0} = {1}.{0}".format(x, tile.support_distribution) for x in appentries]
    if len(buildentries) > 0:
        entry_points['iotile.recipe_action'] = ["{1} = {2}.{0}:{1}".format(x[0], x[1], tile.support_distribution) for x in buildentries]

    data['name'] = tile.support_distribution
    data['package'] = tile.support_distribution
    data['version'] = tile.parsed_version.pep440_string()
    data['deps'] = ["{0} ~= {1}".format(x.support_distribution, x.parsed_version.pep440_string()) for x in _iter_dependencies(tile) if x.has_wheel]

    # If there are some python packages needed, we add them to the list of dependencies required
    if tile.support_wheel_depends:
        data['deps'] += tile.support_wheel_depends

    data['entry_points'] = entry_points

    outdir = os.path.dirname(str(target[0]))

    render_template('setup.py.tpl', data, out_path=str(target[0]))

    # Run setuptools to generate a wheel and an sdist
    curr = os.getcwd()
    os.chdir(outdir)
    try:
        setuptools.sandbox.run_setup('setup.py', ['-q', 'clean', 'sdist'])
        setuptools.sandbox.run_setup('setup.py', ['-q', 'clean', 'bdist_wheel'])
    finally:
        os.chdir(curr)
示例#2
0
def generate_setup_and_manifest(target, source, env):
    """Generate the setup.py and MANIFEST.in files for this distribution."""

    tile = env['TILE']
    data = {}

    entry_points = {}

    for _mod, import_string, entry_point in iter_python_modules(tile):
        if entry_point not in entry_points:
            entry_points[entry_point] = []

        entry_points[entry_point].append(import_string)

    data['name'] = tile.support_distribution
    data['package'] = tile.support_distribution
    data['version'] = tile.parsed_version.pep440_string()
    data['deps'] = [
        "{0} {1}".format(x.support_distribution,
                         x.parsed_version.pep440_compatibility_specifier())
        for x in _iter_dependencies(tile) if x.has_wheel
    ]

    # If there are some python packages needed, we add them to the list of dependencies required
    if tile.support_wheel_depends:
        data['deps'] += tile.support_wheel_depends

    data['entry_points'] = entry_points
    data['include_package_data'] = True

    outdir = os.path.dirname(str(target[0]))

    render_template('setup.py.tpl', data, out_path=str(target[0]))

    manifest_path = os.path.join(outdir, 'MANIFEST.in')
    with open(manifest_path, 'w') as manifest_file:
        for data in env['datafiles']:
            manifest_file.write('include %s\n' % data)

    # Run setuptools to generate a wheel and an sdist
    curr = os.getcwd()
    os.chdir(outdir)
    try:
        setuptools.sandbox.run_setup('setup.py', ['-q', 'clean', 'sdist'])
        if "python_universal" in tile.settings:
            setuptools.sandbox.run_setup(
                'setup.py', ['-q', 'clean', 'bdist_wheel', '--universal'])
        else:
            setuptools.sandbox.run_setup('setup.py',
                                         ['-q', 'clean', 'bdist_wheel'])
    finally:
        os.chdir(curr)
示例#3
0
def generate_doxygen_file(output_path, iotile):
    """Fill in our default doxygen template file with info from an IOTile

    This populates things like name, version, etc.

    Arguments:
        output_path (str):  a string path for where the filled template should go
        iotile (IOTile): An IOTile object that can be queried for information
    """

    mapping = {}

    mapping['short_name'] = iotile.short_name
    mapping['full_name'] = iotile.full_name
    mapping['authors'] = iotile.authors
    mapping['version'] = iotile.version

    render_template('doxygen.txt.tpl', mapping, out_path=output_path)
示例#4
0
    def render_template(self, template_name, out_path=None):
        """Render a template based on this TileBus Block.

        The template has access to all of the attributes of this block as a
        dictionary (the result of calling self.to_dict()).

        You can optionally render to a file by passing out_path.

        Args:
            template_name (str): The name of the template to load.  This must
                be a file in config/templates inside this package
            out_path (str): An optional path of where to save the output
                file, otherwise it is just returned as a string.

        Returns:
            string: The rendered template data.
        """

        return render_template(template_name,
                               self.to_dict(),
                               out_path=out_path)