Compare commits

...

40 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
Scott Shawcroft
098a636b09
Add 5.x and remove 2.x and 3.x
The libraries may not support the older versions so remove them.
2019-08-22 20:59:36 -07:00
Kattni
26ca8730a1
Merge pull request #46 from sommersoft/test_examps_bundle
Fix Example Bundling When 'examples' In Subfolder Name
2019-08-18 11:38:45 -04:00
sommersoft
519c62f3aa allow subfolders with 'examples' in the name, without truncating the path 2019-08-18 08:09:23 -05:00
Scott Shawcroft
800ee1a567
Merge pull request #44 from sommersoft/fix_subfolder
Retain Full Subfolder Structure In Packages
2019-05-31 17:12:49 -07:00
sommersoft
8175c6c9a0 retain full subfolder structure in packages 2019-05-31 18:49:59 -05:00
sommersoft
930c053791
Merge pull request #42 from sommersoft/more_fix_deploy
Re-add `on: tags: true` to Travis deploy
2019-05-23 19:13:17 -05:00
sommersoft
1d60da1bb1 re-add to deployment 2019-05-23 18:43:07 -05:00
Kattni
a5b09751d5
Merge pull request #41 from sommersoft/fix_deploy
Fix PyPI Deployment
2019-05-23 19:16:43 -04:00
sommersoft
d19f810cbe restructure .travis.yml so that releases actually trigger a PyPI deployment 2019-05-23 18:07:35 -05:00
Kattni
fbb43bd2d8
Merge pull request #40 from sommersoft/fix_arg_round_2
Attempt 2: Include mpy-cross '__init__.py' In Packages; Restructure Package Bundling
2019-05-15 13:46:41 -04:00
sommersoft
7f8af9417d de-confuse 'package_folder_prefix' parameter naming 2019-05-14 20:29:52 -05:00
sommersoft
0e839df058 README: remove build mpy-cross cmd in local testing; only used on Travis 2019-05-11 09:33:41 -05:00
sommersoft
50ddabd2cc change 'package_folder_prefix' to a pos arg; grab examples subfolders 2019-05-11 09:32:21 -05:00
sommersoft
18df89a3ef Merge branch 'master' of https://github.com/adafruit/circuitpython-build-tools into fix_arg_round_2 2019-05-10 18:44:45 -05:00
Scott Shawcroft
63c6be10cb
Merge pull request #39 from sommersoft/add_pr_tests
Add Test Matrix For Pull Requests
2019-05-09 13:36:40 -07:00
sommersoft
67abd08f71 missed local testing step: build mpy-cross's 2019-05-08 17:28:17 -05:00
sommersoft
1079f0b041 README: add local test example, and CoC link. 2019-05-08 17:07:50 -05:00
sommersoft
3c51a8bfff include a test matrix for PRs; one for the whole bundle, and one for a single library. 2019-05-08 16:57:57 -05:00
sommersoft
6fa843f03c add '.env/' to .gitignore 2019-05-08 16:55:55 -05:00
sommersoft
03373f49a9 set @click 'package_folder_prefix' default to 'adafruit_' to maintain backwards compatibility 2019-05-07 20:39:07 -05:00
sommersoft
f9ac09d94e Revert "Revert "Fix arg; again...""
This reverts commit 495627bf29.
2019-05-07 18:13:39 -05:00
sommersoft
346ab583d0 Revert "Revert "Fix Mismatched arg Between Click And build_bundles()""
This reverts commit e010f5a10d.
2019-05-07 18:13:12 -05:00
sommersoft
55c69b7b66 Revert "Revert "Include mpy-cross '__init__.py' In Packages; Restructure Package Bundling""
This reverts commit cd1a858a01.
2019-05-07 18:12:43 -05:00
Kattni
7804a09df1
Merge pull request #38 from adafruit/revert-31-include_init
Revert "Include mpy-cross '__init__.py' In Packages; Restructure Package Bundling"
2019-05-07 15:04:30 -04:00
6 changed files with 146 additions and 61 deletions

1
.gitignore vendored
View file

@ -7,3 +7,4 @@ dist
circuitpython_build_tools/data/
.eggs
version.py
.env/*

View file

@ -1,17 +1,50 @@
sudo: false
dist: trusty
dist: xenial
language: python
python:
- '3.6'
script:
- python3 -m circuitpython_build_tools.scripts.build_mpy_cross circuitpython_build_tools/data/
stages:
- name: Tests
if: type = pull_request
- name: deploy
if: tag IS present
jobs:
include:
- stage: Tests
name: "Test CircuitPython Bundle"
python: "3.6"
script:
- echo "Building mpy-cross" && echo "travis_fold:start:mpy-cross"
- python3 -u -m circuitpython_build_tools.scripts.build_mpy_cross circuitpython_build_tools/data/
- echo "travis_fold:end:mpy-cross"
- pip install -e .
- echo "Cloning Adafruit_CircuitPython_Bundle" && echo "travis_fold:start:clone"
- git clone --recurse-submodules https://github.com/adafruit/Adafruit_CircuitPython_Bundle.git
- echo "travis_fold:end:clone"
- cd Adafruit_CircuitPython_Bundle
- circuitpython-build-bundles --filename_prefix test-bundle --library_location libraries --library_depth 2
- stage: Tests
name: "Test Single Library Bundle"
script:
- echo "Building mpy-cross" && echo "travis_fold:start:mpy-cross"
- python3 -u -m circuitpython_build_tools.scripts.build_mpy_cross circuitpython_build_tools/data/
- echo "travis_fold:end:mpy-cross"
- pip install -e .
- git clone https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git
- cd Adafruit_CircuitPython_FeatherWing
- circuitpython-build-bundles --filename_prefix test-single --library_location .
- stage: deploy
script:
- python3 -u -m circuitpython_build_tools.scripts.build_mpy_cross circuitpython_build_tools/data/
deploy:
provider: pypi
user: "adafruit-travis"
password:
secure: tCjXwD8YeitG0HZLxW1D1QlVv4Xbj8mfRoqW0CM9ikPp3KY1PCz6Axj0PiOcyVwKdnxcUQ0EGRl16wEqwkObrmo9MboYrPuPqN00ULmyCQCRvJa2abIN6jDoLtBuf6bcze88t0XY2LdMOcj2Udv5Iijgf95zUgE+Z6BqT9Rgche78JEOeANJ7BlAJ6nRCA4whDdG7J9s7SmFtIjKWtMxig2J3X+Qy0bZ+Armtfp9/CRvjLJ8juDrcCBSysWLnAYLS4u8e/rbSTh8YwFeoeJ1pp9qSmME5NuwScY18QmfESNSqz8wVVXtAFKdoMOCoN+/CodTxp9aB0QsXX6yOYg74ahDIaci239wgnuUqxSaeLxeSwWkkVCXWdQVuP4vgq3GZwm2yNOQ1ZjfFbXF156yv0uSVw5nuaxv0YblQTinJtL4x9hwOdPDJio3b6UT3H1ue9l1qK0LT2OSkzDgn12WmTnTfRUH3BkU6onsYsdP33PK1YhepeQnfbT1P3ikrRHIwGYb7XqcjOtJh413kid6YezCXRqccl8kAxegnqX+cQG7K9ilpZtWaVYLu4RRBJ37H4vpuOb3SV686Y62sWPUXEbI3MR1OxU+RrRr/9DCH1EFXnlYT9LF986wXFJtWuSc+pbXuxY7qduai0hn5Pft6XH31exyiOwAHBIFeYebnVM=
skip_cleanup: true
on:
tags: true
deploy:
provider: pypi
user: "adafruit-travis"
password:
secure: tCjXwD8YeitG0HZLxW1D1QlVv4Xbj8mfRoqW0CM9ikPp3KY1PCz6Axj0PiOcyVwKdnxcUQ0EGRl16wEqwkObrmo9MboYrPuPqN00ULmyCQCRvJa2abIN6jDoLtBuf6bcze88t0XY2LdMOcj2Udv5Iijgf95zUgE+Z6BqT9Rgche78JEOeANJ7BlAJ6nRCA4whDdG7J9s7SmFtIjKWtMxig2J3X+Qy0bZ+Armtfp9/CRvjLJ8juDrcCBSysWLnAYLS4u8e/rbSTh8YwFeoeJ1pp9qSmME5NuwScY18QmfESNSqz8wVVXtAFKdoMOCoN+/CodTxp9aB0QsXX6yOYg74ahDIaci239wgnuUqxSaeLxeSwWkkVCXWdQVuP4vgq3GZwm2yNOQ1ZjfFbXF156yv0uSVw5nuaxv0YblQTinJtL4x9hwOdPDJio3b6UT3H1ue9l1qK0LT2OSkzDgn12WmTnTfRUH3BkU6onsYsdP33PK1YhepeQnfbT1P3ikrRHIwGYb7XqcjOtJh413kid6YezCXRqccl8kAxegnqX+cQG7K9ilpZtWaVYLu4RRBJ37H4vpuOb3SV686Y62sWPUXEbI3MR1OxU+RrRr/9DCH1EFXnlYT9LF986wXFJtWuSc+pbXuxY7qduai0hn5Pft6XH31exyiOwAHBIFeYebnVM=
skip_cleanup: true
on:
tags: true

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)
@ -56,3 +56,20 @@ source .env/bin/activate
pip install circuitpython-build-tools
circuitpython-build-bundles --filename_prefix <output file prefix> --library_location .
```
When making changes to `circuitpython-build-tools` itself, you can test your changes
locally like so:
```shell
cd circuitpython-build-tools # this will be specific to your storage location
python3 -m venv .env
source .env/bin/activate
pip install -e . # '-e' is pip's "development" install feature
circuitpython-build-bundles --filename_prefix <output file prefix> --library_location <library location>
```
## Contributing
Contributions are welcome! Please read our [Code of Conduct]
(https://github.com/adafruit/Adafruit_CircuitPython_adabot/blob/master/CODE_OF_CONDUCT.md)
before contributing to help this project stay welcoming.

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
@ -100,33 +103,52 @@ def _munge_to_temp(original_path, temp_file, library_version):
temp_file.write(line.encode("utf-8") + b"\r\n")
temp_file.flush()
def library(library_path, output_directory, mpy_cross=None, example_bundle=False):
def library(library_path, output_directory, package_folder_prefix,
mpy_cross=None, example_bundle=False):
py_files = []
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) and filename not in ["docs"]:
files = os.listdir(full_path)
files = filter(lambda x: x.endswith(".py") or x.startswith("font5x8.bin"), files)
files = map(lambda x: os.path.join(filename, x), files)
if filename.startswith("examples"):
example_files.extend(files)
else:
if not example_bundle:
package_files.extend(files)
if (filename.endswith(".py") and
filename not in IGNORE_PY and
not example_bundle):
py_files.append(filename)
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:
if not example_bundle:
is_package = False
for prefix in package_folder_prefix:
if file.parts[parent_idx].startswith(prefix):
is_package = True
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", "/"),
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
@ -144,16 +166,20 @@ def library(library_path, output_directory, mpy_cross=None, example_bundle=False
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,
"-o", output_file,
"-s", filename,
temp_file.name])
mpy_success = subprocess.call([
mpy_cross,
"-o", output_file,
"-s", str(filename.relative_to(library_path)),
temp_file.name
])
if mpy_success != 0:
raise RuntimeError("mpy-cross failed on", full_path)
else:
@ -163,24 +189,29 @@ def library(library_path, output_directory, mpy_cross=None, example_bundle=False
full_path = os.path.join(library_path, filename)
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 or
filename.endswith("__init__.py")):
output_file = os.path.join(output_directory, filename)
if not mpy_cross or os.stat(full_path).st_size == 0:
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,
"-o", output_file,
"-s", filename,
temp_file.name])
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", 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

@ -48,7 +48,7 @@ def add_file(bundle, src_file, zip_name):
return file_sector_size
def build_bundle(libs, bundle_version, output_filename,
def build_bundle(libs, bundle_version, output_filename, package_folder_prefix,
build_tools_version="devel", mpy_cross=None, example_bundle=False):
build_dir = "build-" + os.path.basename(output_filename)
top_folder = os.path.basename(output_filename).replace(".zip", "")
@ -69,8 +69,8 @@ def build_bundle(libs, bundle_version, output_filename,
success = True
for library_path in libs:
try:
build.library(library_path, build_lib_dir, mpy_cross=mpy_cross,
example_bundle=example_bundle)
build.library(library_path, build_lib_dir, package_folder_prefix,
mpy_cross=mpy_cross, example_bundle=example_bundle)
except ValueError as e:
print("build.library failure:", library_path)
print(e)
@ -91,7 +91,9 @@ def build_bundle(libs, bundle_version, output_filename,
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")]
@ -135,9 +137,12 @@ def _find_libraries(current_path, depth):
@click.option('--output_directory', default="bundles", help="Output location for the zip files.")
@click.option('--library_location', required=True, help="Location of libraries to bundle.")
@click.option('--library_depth', default=0, help="Depth of library folders. This is useful when multiple libraries are bundled together but are initially in separate subfolders.")
def build_bundles(filename_prefix, output_directory, library_location, library_depth):
@click.option('--package_folder_prefix', default="adafruit_", help="Prefix string used to determine package folders to bundle.")
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)
@ -157,7 +162,7 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
zip_filename = os.path.join(output_directory,
filename_prefix + '-py-{VERSION}.zip'.format(
VERSION=bundle_version))
build_bundle(libs, bundle_version, zip_filename,
build_bundle(libs, bundle_version, zip_filename, package_folder_prefix,
build_tools_version=build_tools_version)
# Build .mpy bundle(s)
@ -174,12 +179,12 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
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_bundle(libs, bundle_version, zip_filename, package_folder_prefix,
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_bundle(libs, bundle_version, zip_filename, package_folder_prefix,
build_tools_version=build_tools_version, example_bundle=True)

View file

@ -25,7 +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": "2.3.1", "name": "2.x"},
{"tag": "3.0.0", "name": "3.x"},
{"tag": "4.0.0-alpha.2", "name": "4.x"},
{"tag": "6.1.0", "name": "6.x"},
]