Compare commits

...

16 commits

Author SHA1 Message Date
Dan Halbert
4672763fab
Merge pull request #58 from adafruit/tannewt-patch-7
Stop releasing for 5.x
2021-01-28 14:23:10 -05:00
Scott Shawcroft
a292909c21
Stop releasing for 5.x
5.x bundles would break with the pwmio.PWMOut changes otherwise.
2021-01-28 11:09:41 -08:00
Dan Halbert
06c4237c08
Merge pull request #57 from adafruit/tannewt-patch-7
Update versions for mpy-cross
2021-01-20 13:51:42 -05:00
Scott Shawcroft
bab005fb54
Update versions for mpy-cross
This brings in f-string support.
2021-01-20 10:47:06 -08:00
Limor "Ladyada" Fried
2c982ad536
Merge pull request #56 from mcauser/patch-1
Fix expired Discord link
2020-12-07 10:06:11 -05:00
Mike Causer
181368b0e4
Fix expired Discord link 2020-12-08 01:21:05 +11:00
Kattni
381253f2ae
Merge pull request #54 from adafruit/tannewt-patch-6
Turn off 4.x bundles and enable 6.x
2020-07-06 19:17:04 -04:00
Scott Shawcroft
8ccfa837a3
Turn off 4.x bundles and enable 6.x 2020-07-06 15:33:56 -07:00
Jeff Epler
b014d651cd
Merge pull request #53 from joedevivo/master
Added `ssh://git@` url pattern
2019-12-27 14:30:15 -06:00
Joe DeVivo
0fe0ed6353 My git urls look like ssh://git@github.com/**/.git 2019-12-27 08:26:09 -07:00
Kattni
e5da2baed3
Merge pull request #52 from sommersoft/fix_mpy_cross
Properly Truncate mpy Filenames
2019-10-15 19:46:26 -04:00
sommersoft
283d8286bd properly truncate mpy filenames 2019-10-15 17:28:38 -05:00
Scott Shawcroft
318fa70652
Merge pull request #50 from sommersoft/new_path_walk
Allow Multiple Package Folder Prefixes; Improve File Gathering
2019-09-25 11:13:09 -07:00
sommersoft
b803b26f4a allow for multiple entries for the 'package_folder_prefix" argument 2019-09-24 21:54:02 -05:00
sommersoft
83ecd9525a use 'pathlib' vs 'os.walk' to gather files 2019-09-24 18:40:09 -05:00
Kattni
ffcbdc598c
Merge pull request #47 from adafruit/tannewt-patch-5
Add 5.x and remove 2.x and 3.x
2019-09-03 17:35:39 -04:00
4 changed files with 62 additions and 70 deletions

View file

@ -1,6 +1,6 @@
# Adafruit CircuitPython Build Tools
[![Discord](https://img.shields.io/discord/327254708534116352.svg)](https://discord.gg/nBQh6qu)
[![Discord](https://img.shields.io/discord/327254708534116352.svg)](https://adafru.it/discord)
This repo contains build scripts used to build the
[Adafruit CircuitPython bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle), [CircuitPython Community bundle](https://github.com/adafruit/CircuitPython_Community_Bundle)

View file

@ -3,6 +3,7 @@
# The MIT License (MIT)
#
# Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
# 2018, 2019 Michael Schroeder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@ -24,6 +25,7 @@
import os
import os.path
import pathlib
import semver
import shutil
import sys
@ -31,6 +33,7 @@ import subprocess
import tempfile
IGNORE_PY = ["setup.py", "conf.py", "__init__.py"]
GLOB_PATTERNS = ["*.py", "font5x8.bin"]
def version_string(path=None, *, valid_semver=False):
version = None
@ -106,71 +109,46 @@ def library(library_path, output_directory, package_folder_prefix,
package_files = []
example_files = []
total_size = 512
for filename in os.listdir(library_path):
full_path = os.path.join(library_path, filename)
if os.path.isdir(full_path):
path_walk = [names for names in os.walk(full_path)]
#print("- '{}' walk: {}".format(filename, path_walk))
# iterate through path_walk, appending each file to
# 'walked_files' while retaining subdirectory structure
walked_files = []
for path in path_walk:
rel_path = ""
if filename.startswith("examples"):
path_tail_idx = path[0].rfind("examples/")
if path_tail_idx != -1:
rel_path = "{}/".format(path[0][path_tail_idx + 9:])
lib_path = pathlib.Path(library_path)
parent_idx = len(lib_path.parts)
glob_search = []
for pattern in GLOB_PATTERNS:
glob_search.extend(list(lib_path.rglob(pattern)))
for file in glob_search:
if file.parts[parent_idx] == "examples":
example_files.append(file)
else:
path_tail_idx = (path[0].rfind("{}/".format(filename))
+ (len(filename) +1))
path_tail = path[0][path_tail_idx:]
# if this entry is the package top dir, keep it
# empty so we don't double append the dir name
if filename not in path_tail:
rel_path = "{}/".format(path_tail)
for path_files in path[2]:
walked_files.append("{}{}".format(rel_path, path_files))
#print(" - expanded file walk: {}".format(walked_files))
files = filter(
lambda x: x.endswith(".py") or x.startswith("font5x8.bin"),
walked_files
)
files = map(lambda x: os.path.join(filename, x), files)
if filename.startswith("examples"):
example_files.extend(files)
#print("- example files: {}".format(example_files))
else:
if (not example_bundle and
not filename.startswith(package_folder_prefix)):
print("skipped path: {}".format(full_path))
continue
if not example_bundle:
package_files.extend(files)
#print("- package files: {} | {}".format(filename, package_files))
is_package = False
for prefix in package_folder_prefix:
if file.parts[parent_idx].startswith(prefix):
is_package = True
if (filename.endswith(".py") and
filename not in IGNORE_PY and
not example_bundle):
py_files.append(filename)
if is_package:
package_files.append(file)
else:
if file.name in IGNORE_PY:
#print("Ignoring:", file.resolve())
continue
if file.parent == lib_path:
py_files.append(file)
if len(py_files) > 1:
raise ValueError("Multiple top level py files not allowed. Please put them in a package "
"or combine them into a single file.")
raise ValueError("Multiple top level py files not allowed. Please put "
"them in a package or combine them into a single file.")
for fn in example_files:
base_dir = os.path.join(output_directory.replace("/lib", "/"), os.path.dirname(fn))
base_dir = os.path.join(output_directory.replace("/lib", "/"),
fn.relative_to(library_path).parent)
if not os.path.isdir(base_dir):
os.makedirs(base_dir)
total_size += 512
for fn in package_files:
base_dir = os.path.join(output_directory, os.path.dirname(fn))
base_dir = os.path.join(output_directory,
fn.relative_to(library_path).parent)
if not os.path.isdir(base_dir):
os.makedirs(base_dir)
total_size += 512
@ -188,16 +166,20 @@ def library(library_path, output_directory, package_folder_prefix,
for filename in py_files:
full_path = os.path.join(library_path, filename)
output_file = os.path.join(output_directory,
filename.replace(".py", new_extension))
output_file = os.path.join(
output_directory,
filename.relative_to(library_path).with_suffix(new_extension)
)
with tempfile.NamedTemporaryFile() as temp_file:
_munge_to_temp(full_path, temp_file, library_version)
if mpy_cross:
mpy_success = subprocess.call([mpy_cross,
mpy_success = subprocess.call([
mpy_cross,
"-o", output_file,
"-s", filename,
temp_file.name])
"-s", str(filename.relative_to(library_path)),
temp_file.name
])
if mpy_success != 0:
raise RuntimeError("mpy-cross failed on", full_path)
else:
@ -208,21 +190,28 @@ def library(library_path, output_directory, package_folder_prefix,
with tempfile.NamedTemporaryFile() as temp_file:
_munge_to_temp(full_path, temp_file, library_version)
if not mpy_cross or os.stat(full_path).st_size == 0:
output_file = os.path.join(output_directory, filename)
output_file = os.path.join(output_directory,
filename.relative_to(library_path))
shutil.copyfile(temp_file.name, output_file)
else:
output_file = os.path.join(output_directory,
filename.replace(".py", new_extension))
mpy_success = subprocess.call([mpy_cross,
output_file = os.path.join(
output_directory,
filename.relative_to(library_path).with_suffix(new_extension)
)
mpy_success = subprocess.call([
mpy_cross,
"-o", output_file,
"-s", filename,
temp_file.name])
"-s", str(filename.relative_to(library_path)),
temp_file.name
])
if mpy_success != 0:
raise RuntimeError("mpy-cross failed on", full_path)
for filename in example_files:
full_path = os.path.join(library_path, filename)
output_file = os.path.join(output_directory.replace("/lib", "/"), filename)
output_file = os.path.join(output_directory.replace("/lib", "/"),
filename.relative_to(library_path))
with tempfile.NamedTemporaryFile() as temp_file:
_munge_to_temp(full_path, temp_file, library_version)
shutil.copyfile(temp_file.name, output_file)

View file

@ -91,7 +91,9 @@ def build_bundle(libs, bundle_version, output_filename, package_folder_prefix,
for line in versions.stdout.split(b"\n"):
if not line:
continue
if line.startswith(b"git@"):
if line.startswith(b"ssh://git@"):
repo = b"https://" + line.split(b"@")[1][:-len(".git")]
elif line.startswith(b"git@"):
repo = b"https://github.com/" + line.split(b":")[1][:-len(".git")]
elif line.startswith(b"https:"):
repo = line.strip()[:-len(".git")]
@ -139,6 +141,8 @@ def _find_libraries(current_path, depth):
def build_bundles(filename_prefix, output_directory, library_location, library_depth, package_folder_prefix):
os.makedirs(output_directory, exist_ok=True)
package_folder_prefix = package_folder_prefix.split(", ")
bundle_version = build.version_string()
libs = _find_libraries(os.path.abspath(library_location), library_depth)

View file

@ -25,6 +25,5 @@
# The tag specifies which version of CircuitPython to use for mpy-cross.
# The name is used when constructing the zip file names.
VERSIONS = [
{"tag": "4.0.0-alpha.2", "name": "4.x"},
{"tag": "5.0.0-alpha.0", "name": "5.x"},
{"tag": "6.1.0", "name": "6.x"},
]