From 7cd8379d01c2b43431e8f3ea66ee857298027c80 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Fri, 15 Dec 2023 21:31:39 -0800 Subject: [PATCH 1/8] addresses #103 --- .../scripts/build_bundles.py | 21 ++++++++++++------- requirements.txt | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/circuitpython_build_tools/scripts/build_bundles.py b/circuitpython_build_tools/scripts/build_bundles.py index 596b7dc..ffa49ea 100755 --- a/circuitpython_build_tools/scripts/build_bundles.py +++ b/circuitpython_build_tools/scripts/build_bundles.py @@ -26,7 +26,6 @@ import os import os.path import re -import shlex import shutil import subprocess import sys @@ -37,7 +36,13 @@ from circuitpython_build_tools import build from circuitpython_build_tools import target_versions -import pkg_resources +import importlib.resources as importlib_resources + +if sys.version_info < (3, 8): + import importlib_metadata +else: + import importlib.metadata as importlib_metadata + BLINKA_LIBRARIES = [ "adafruit-blinka", @@ -244,10 +249,10 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d 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 + try: + build_tools_version = importlib_metadata.version("circuitpython-build-tools") + except importlib_metadata.PackageNotFoundError: + build_tools_version = "devel" build_tools_fn = "z-build_tools_version-{}.ignore".format( build_tools_version) @@ -269,8 +274,8 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d 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"]) + mpy_cross = importlib_resources.files( + target_versions.__name__) / "data/mpy-cross-" + version["name"] else: mpy_cross = "build_deps/mpy-cross-" + version["name"] + (".exe" * (os.name == "nt")) build.mpy_cross(mpy_cross, version["tag"]) diff --git a/requirements.txt b/requirements.txt index 8a3514c..988d40c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ requests semver wheel tomli; python_version < "3.11" +importlib_metadata; python_version < "3.8" From 4d4844451caa25bd691267c08840d3a12564cd11 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Fri, 15 Dec 2023 21:02:52 -0800 Subject: [PATCH 2/8] upgrade github actions to latest major --- .github/workflows/build.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d43b404..7088297 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,14 +16,14 @@ jobs: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - name: Set up Python 3.7 - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: 3.7 - name: Versions run: | python3 --version - name: Checkout Current Repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install requirements run: | sudo apt-get update diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e2aa54..0e54be7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,9 +13,9 @@ jobs: upload-pypi: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: '3.7' - name: Install dependencies From 1e64df5969dfb50222886b63337bd70e099851ca Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Sat, 16 Dec 2023 20:02:27 -0800 Subject: [PATCH 3/8] remove travis CI specific code --- circuitpython_build_tools/scripts/build_bundles.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/circuitpython_build_tools/scripts/build_bundles.py b/circuitpython_build_tools/scripts/build_bundles.py index ffa49ea..6fa472a 100755 --- a/circuitpython_build_tools/scripts/build_bundles.py +++ b/circuitpython_build_tools/scripts/build_bundles.py @@ -36,8 +36,6 @@ from circuitpython_build_tools import build from circuitpython_build_tools import target_versions -import importlib.resources as importlib_resources - if sys.version_info < (3, 8): import importlib_metadata else: @@ -272,13 +270,8 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d if "mpy" not in ignore: 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 = importlib_resources.files( - target_versions.__name__) / "data/mpy-cross-" + version["name"] - else: - mpy_cross = "build_deps/mpy-cross-" + version["name"] + (".exe" * (os.name == "nt")) - build.mpy_cross(mpy_cross, version["tag"]) + mpy_cross = "build_deps/mpy-cross-" + version["name"] + (".exe" * (os.name == "nt")) + build.mpy_cross(mpy_cross, version["tag"]) zip_filename = os.path.join(output_directory, filename_prefix + '-{TAG}-mpy-{VERSION}.zip'.format( TAG=version["name"], From 87ba4b679b82351f60fdb34788fc738ee4354d55 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 Dec 2023 08:04:05 -0600 Subject: [PATCH 4/8] we now recommend github actions as the CI system of choice --- README.md | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index a8dc21d..5b85c43 100644 --- a/README.md +++ b/README.md @@ -4,40 +4,20 @@ 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) -and individual library release zips. Its focused on Travis CI support but will also work locally +and individual library release zips. Its focused on Github Actions support but will also work locally when a gcc compiler is present. -The pip package includes mpy-crosses that run on Travis. When building locally, the scripts will +The scripts will either fetch a pre-built mpy-cross from s3 or automatically clone the [CircuitPython repo](https://github.com/adafruit/circuitpython) and attempt -to build mpy-crosses. You'll need some version of gcc for this to work. +to build mpy-cross. You'll need some version of gcc for this to work. ## Setting up libraries -These build tools are intended for use with [Travis CI](https://travis-ci.org) -to automatically build .mpy files and zip them up for CircuitPython when a new -tagged release is created. To add support to a repo you need to: - - 1. Use the [CircuitPython cookiecutter](https://github.com/adafruit/cookiecutter-adafruit-circuitpython) to generate .travis.yml. - 2. For adafruit repositories, simply give the CircuitPythonLibrarians team - write access to the repo and Adabot will do the rest. - - Otherwise, go to travis-ci.org and find the repository (it needs to be - setup to access your github account, and your github account needs access - to write to the repo). Flip the 'ON' switch on for Travis and the repo, - see the Travis docs for more details: https://docs.travis-ci.com/user/getting-started/ - 3. Get a GitHub 'personal access token' which has at least 'public_repo' or - 'repo' scope: https://help.github.com/articles/creating-an-access-token-for-command-line-use/ - Keep this token safe and secure! Anyone with the token will be able to - access and write to your GitHub repositories. Travis will use the token - to attach the .mpy files to the release. - 4. In the Travis CI settings for the repository that was enabled find the - environment variable editing page: https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings - Add an environment variable named GITHUB_TOKEN and set it to the value - of the GitHub personal access token above. Keep 'Display value in build - log' flipped off. - 5. That's it! Tag a release and Travis should go to work to add zipped .mpy files - to the release. It takes about a 2-3 minutes for a worker to spin up, - build mpy-cross, and add the binaries to the release. +These build tools automatically build .mpy files and zip them up for +CircuitPython when a new tagged release is created. To add support to a repo +you need to use the [CircuitPython +cookiecutter](https://github.com/adafruit/cookiecutter-adafruit-circuitpython) +to generate `.github/workflows/*.yml`. The bundle build will produce one zip file for every major CircuitPython release supported containing compatible mpy files and a zip with human readable py files. @@ -71,5 +51,5 @@ circuitpython-build-bundles --filename_prefix --library_loc ## Contributing Contributions are welcome! Please read our [Code of Conduct] -(https://github.com/adafruit/Adafruit_CircuitPython_adabot/blob/master/CODE_OF_CONDUCT.md) +(https://github.com/adafruit/Adafruit\_CircuitPython\_adabot/blob/master/CODE\_OF\_CONDUCT.md) before contributing to help this project stay welcoming. From e896099f0956fbec23cf135b23b655037d66dc14 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 Dec 2023 08:10:45 -0600 Subject: [PATCH 5/8] bump minimum python version to 3.10 .. this is what is used during the build of the adafruit bundle right now. --- .github/workflows/build.yml | 4 ++-- .github/workflows/release.yml | 2 +- requirements.txt | 1 - setup.py | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7088297..18d7da8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,10 +15,10 @@ jobs: env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - - name: Set up Python 3.7 + - name: Set up Python 3.10 uses: actions/setup-python@v5 with: - python-version: 3.7 + python-version: 3.10 - name: Versions run: | python3 --version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e54be7..5e81de8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.7' + python-version: '3.10' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/requirements.txt b/requirements.txt index 988d40c..8a3514c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,3 @@ requests semver wheel tomli; python_version < "3.11" -importlib_metadata; python_version < "3.8" diff --git a/setup.py b/setup.py index 9b33317..0d2bbc7 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'circuitpython_build_tools.scripts'], package_data={'circuitpython_build_tools': ['data/mpy-cross-*']}, zip_safe=False, - python_requires='>=3.7', + python_requires='>=3.10', install_requires=['Click', 'requests', 'semver', 'tomli; python_version < "3.11"'], entry_points=''' [console_scripts] From 6a4079769f76c701500406e2f93a252a937c199e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 Dec 2023 08:12:48 -0600 Subject: [PATCH 6/8] string vs number --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18d7da8..3c657de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Python 3.10 uses: actions/setup-python@v5 with: - python-version: 3.10 + python-version: "3.10" - name: Versions run: | python3 --version From 7dadcc70aa03271fbd8c15c9ed369981ca13e72d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 17 Dec 2023 08:59:14 -0600 Subject: [PATCH 7/8] ensure tags are present this should fix the message during CI ``` .../setuptools_scm/git.py:163: UserWarning: "/home/runner/work/circuitpython-build-tools/circuitpython-build-tools" is shallow and may cause errors warnings.warn(f'"{wd.path}" is shallow and may cause errors') ``` This may have been introduced when upgrading action/checkout recently, or it might be pre-existing. --- .github/workflows/build.yml | 3 +++ .github/workflows/release.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c657de..a301583 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,9 @@ jobs: python3 --version - name: Checkout Current Repo uses: actions/checkout@v4 + with: + filter: 'blob:none' + depth: 0 - name: Install requirements run: | sudo apt-get update diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e81de8..728ba8e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,6 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + filter: 'blob:none' + depth: 0 - name: Set up Python uses: actions/setup-python@v5 with: From 4f50d277dabb983edc3a5df91d3decb6adfec1af Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 19 Dec 2023 11:23:53 -0600 Subject: [PATCH 8/8] enable standard zip ("deflate") compression This saves ~50% on the main bundle and will save ~85% on the fonts bundle --- circuitpython_build_tools/scripts/build_bundles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circuitpython_build_tools/scripts/build_bundles.py b/circuitpython_build_tools/scripts/build_bundles.py index 6fa472a..e85610e 100755 --- a/circuitpython_build_tools/scripts/build_bundles.py +++ b/circuitpython_build_tools/scripts/build_bundles.py @@ -205,7 +205,7 @@ def build_bundle(libs, bundle_version, output_filename, package_folder_prefix, print() print("Zipping") - with zipfile.ZipFile(output_filename, 'w') as bundle: + with zipfile.ZipFile(output_filename, 'w', compression=zipfile.ZIP_DEFLATED) as bundle: build_metadata = {"build-tools-version": build_tools_version} bundle.comment = json.dumps(build_metadata).encode("utf-8") if multiple_libs: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy