Esempio n. 1
0
def build_bundles(filename_prefix, output_directory, library_location,
                  library_depth):
    os.makedirs(output_directory, exist_ok=True)

    bundle_version = build.version_string()

    libs = _find_libraries(os.path.abspath(library_location), library_depth)

    pkg = pkg_resources.get_distribution("circuitpython-build-tools")
    build_tools_version = "devel"
    if pkg:
        build_tools_version = pkg.version

    build_tools_fn = "z-build_tools_version-{}.ignore".format(
        build_tools_version)
    build_tools_fn = os.path.join(output_directory, build_tools_fn)
    with open(build_tools_fn, "w") as f:
        f.write(build_tools_version)

    # Build raw source .py bundle
    zip_filename = os.path.join(
        output_directory,
        filename_prefix + '-py-{VERSION}.zip'.format(VERSION=bundle_version))
    build_bundle(libs,
                 bundle_version,
                 zip_filename,
                 build_tools_version=build_tools_version)

    # Build .mpy bundle(s)
    os.makedirs("build_deps", exist_ok=True)
    for version in target_versions.VERSIONS:
        # Use prebuilt mpy-cross on Travis, otherwise build our own.
        if "TRAVIS" in os.environ:
            mpy_cross = pkg_resources.resource_filename(
                target_versions.__name__, "data/mpy-cross-" + version["name"])
        else:
            mpy_cross = "build_deps/mpy-cross-" + version["name"]
            build.mpy_cross(mpy_cross, version["tag"])
        zip_filename = os.path.join(
            output_directory,
            filename_prefix + '-{TAG}-mpy-{VERSION}.zip'.format(
                TAG=version["name"], VERSION=bundle_version))
        build_bundle(libs,
                     bundle_version,
                     zip_filename,
                     mpy_cross=mpy_cross,
                     build_tools_version=build_tools_version)

    # Build example bundle
    zip_filename = os.path.join(
        output_directory, filename_prefix +
        '-examples-{VERSION}.zip'.format(VERSION=bundle_version))
    build_bundle(libs,
                 bundle_version,
                 zip_filename,
                 build_tools_version=build_tools_version,
                 example_bundle=True)
def build_bundles(filename_prefix, output_directory, library_location, library_depth):
    os.makedirs(output_directory, exist_ok=True)

    bundle_version = None
    tag = subprocess.run('git describe --tags --exact-match', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    if tag.returncode == 0:
        bundle_version = tag
    else:
        commitish = subprocess.run("git log --pretty=format:'%h' -n 1", shell=True, stdout=subprocess.PIPE)
        bundle_version = commitish
    bundle_version = bundle_version.stdout.strip().decode("utf-8", "strict")

    libs = _find_libraries(os.path.abspath(library_location), library_depth)
    print(libs)

    pkg = pkg_resources.get_distribution("circuitpython-build-tools")
    build_tools_version = "devel"
    if pkg:
        build_tools_version = pkg.version

    build_tools_fn = "z-build_tools_version-{}.ignore".format(
        build_tools_version)
    build_tools_fn = os.path.join(output_directory, build_tools_fn)
    with open(build_tools_fn, "w") as f:
        f.write(build_tools_version)

    zip_filename = os.path.join(output_directory,
        filename_prefix + '-py-{VERSION}.zip'.format(
            VERSION=bundle_version))
    build_bundle(libs, bundle_version, zip_filename,
                 build_tools_version=build_tools_version)
    os.makedirs("build_deps", exist_ok=True)
    for version in target_versions.VERSIONS:
        # Use prebuilt mpy-cross on Travis, otherwise build our own.
        if "TRAVIS" in os.environ:
            mpy_cross = pkg_resources.resource_filename(
                target_versions.__name__, "data/mpy-cross-" + version["name"])
        else:
            mpy_cross = "build_deps/mpy-cross-" + version["name"]
            build.mpy_cross(mpy_cross, version["tag"])
        zip_filename = os.path.join(output_directory,
            filename_prefix + '-{TAG}-{VERSION}.zip'.format(
                TAG=version["name"],
                VERSION=bundle_version))
        build_bundle(libs, bundle_version, zip_filename, mpy_cross=mpy_cross,
                     build_tools_version=build_tools_version)
Esempio n. 3
0
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

from circuitpython_build_tools import build
from circuitpython_build_tools import target_versions

import os
import sys

if __name__ == "__main__":
    output_directory = sys.argv[1]
    os.makedirs(output_directory, exist_ok=True)
    for version in target_versions.VERSIONS:
        mpy_cross = output_directory + "/mpy-cross-" + version["name"]
        build.mpy_cross(mpy_cross, version["tag"])