Skip to content

Commit 84dfc53

Browse files
committed
Build mpy-cross ourselves when not on Travis. Also add our version
into the bundle.
1 parent d09d191 commit 84dfc53

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

scripts/circuitpython-build-bundles

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import zipfile
3232

3333
from circuitpython_build_tools import build
3434

35+
import pkg_resources
3536

3637
def add_file(bundle, src_file, zip_name):
3738
bundle.write(src_file, zip_name)
@@ -74,6 +75,15 @@ def build_bundle(lib_location, bundle_version, output_filename,
7475
else:
7576
f.write(repo.decode("utf-8", "strict") + "/releases/tag/" + line.strip().decode("utf-8", "strict") + "\r\n")
7677

78+
79+
with open(os.path.join(build_lib_dir, ".build-tools-version.txt"), "w") as f:
80+
pkg = pkg_resources.get_distribution("circuitpython-travis-build-tools")
81+
82+
if pkg:
83+
f.write(pkg.version + "\n")
84+
else:
85+
f.write("devel\n")
86+
7787
with zipfile.ZipFile(output_filename, 'w') as bundle:
7888
total_size += add_file(bundle, "README.txt", "lib/README.txt")
7989
for filename in os.listdir("update_scripts"):
@@ -95,7 +105,6 @@ def build_bundle(lib_location, bundle_version, output_filename,
95105

96106
if __name__ == "__main__":
97107
from circuitpython_build_tools import target_versions
98-
from pkg_resources import resource_filename
99108

100109
bundle_lib_location = os.path.abspath(sys.argv[1])
101110
output_dir = os.path.abspath(sys.argv[2])
@@ -121,7 +130,13 @@ if __name__ == "__main__":
121130
build_bundle(bundle_lib_location, bundle_version, zip_filename)
122131
os.makedirs("build_deps", exist_ok=True)
123132
for version in target_versions.VERSIONS:
124-
mpy_cross = resource_filename(target_versions.__name__, "data/mpy-cross-" + version["name"])
133+
# Use prebuilt mpy-cross on Travis, otherwise build our own.
134+
if "TRAVIS" in os.environ:
135+
mpy_cross = pkg_resources.resource_filename(
136+
target_versions.__name__, "data/mpy-cross-" + version["name"])
137+
else:
138+
mpy_cross = "build_deps/mpy-cross-" + version["name"]
139+
build.mpy_cross(mpy_cross, version["tag"])
125140
zip_filename = os.path.join(output_dir,
126141
filename_prefix + '-{TAG}-{VERSION}.zip'.format(
127142
TAG=version["name"],

0 commit comments

Comments
 (0)