Skip to content

Commit 734890c

Browse files
Merge branch 'main' of github.com:adafruit/circuitpython-build-tools into github-actions
2 parents 743c550 + 1b3ea7d commit 734890c

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

circuitpython_build_tools/build.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
# Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
66
# 2018, 2019 Michael Schroeder
7+
# 2021 James Carr
78
#
89
# Permission is hereby granted, free of charge, to any person obtaining a copy
910
# of this software and associated documentation files (the "Software"), to deal
@@ -26,14 +27,17 @@
2627
import os
2728
import os.path
2829
import pathlib
30+
import requests
2931
import semver
3032
import shutil
33+
import stat
3134
import sys
3235
import subprocess
3336
import tempfile
3437

3538
IGNORE_PY = ["setup.py", "conf.py", "__init__.py"]
3639
GLOB_PATTERNS = ["*.py", "font5x8.bin"]
40+
S3_MPY_PREFIX = "https://adafruit-circuit-python.s3.amazonaws.com/bin/mpy-cross/"
3741

3842
def version_string(path=None, *, valid_semver=False):
3943
version = None
@@ -64,6 +68,38 @@ def version_string(path=None, *, valid_semver=False):
6468
def mpy_cross(mpy_cross_filename, circuitpython_tag, quiet=False):
6569
if os.path.isfile(mpy_cross_filename):
6670
return
71+
72+
# Try to pull from S3
73+
uname = os.uname()
74+
s3_url = None
75+
if uname[0] == 'Linux' and uname[4] in ('amd64', 'x86_64'):
76+
s3_url = f"{S3_MPY_PREFIX}mpy-cross.static-amd64-linux-{circuitpython_tag}"
77+
elif uname[0] == 'Linux' and uname[4] == 'armv7l':
78+
s3_url = f"{S3_MPY_PREFIX}mpy-cross.static-raspbian-{circuitpython_tag}"
79+
elif uname[0] == 'Darwin' and uname[4] == 'x86_64':
80+
s3_url = f"{S3_MPY_PREFIX}mpy-cross-macos-catalina-{circuitpython_tag}"
81+
elif not quiet:
82+
print(f"Pre-built mpy-cross not available for sysname='{uname[0]}' release='{uname[2]}' machine='{uname[4]}'.")
83+
84+
if s3_url is not None:
85+
if not quiet:
86+
print(f"Checking S3 for {s3_url}")
87+
try:
88+
r = requests.get(s3_url)
89+
if r.status_code == 200:
90+
with open(mpy_cross_filename, "wb") as f:
91+
f.write(r.content)
92+
# Set the User Execute bit
93+
os.chmod(mpy_cross_filename, os.stat(mpy_cross_filename)[0] | stat.S_IXUSR)
94+
if not quiet:
95+
print(" FOUND")
96+
return
97+
except Exception as e:
98+
if not quiet:
99+
print(f" exception fetching from S3: {e}")
100+
if not quiet:
101+
print(" NOT FOUND")
102+
67103
if not quiet:
68104
title = "Building mpy-cross for circuitpython " + circuitpython_tag
69105
print()

circuitpython_build_tools/scripts/build_bundles.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def get_module_name(library_path):
6464
if repo[-4:] == ".git":
6565
repo = repo[:-4]
6666
module_name = repo.split("/")[-1].replace("_", "-")
67+
68+
# circuitpython org repos are deployed to pypi without "org" in the pypi name
69+
module_name = re.sub(r"^circuitpython-org-", "circuitpython-", module_name)
6770
return module_name, repo
6871

6972
def get_bundle_requirements(directory, package_list):

circuitpython_build_tools/target_versions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
# The tag specifies which version of CircuitPython to use for mpy-cross.
2626
# The name is used when constructing the zip file names.
2727
VERSIONS = [
28-
{"tag": "6.2.0", "name": "6.x"},
29-
{"tag": "7.0.0-alpha.2", "name": "7.x"},
28+
{"tag": "6.3.0", "name": "6.x"},
29+
{"tag": "7.0.0-alpha.3", "name": "7.x"},
3030
]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
Click
2+
requests
23
semver
34
wheel

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
'circuitpython_build_tools.scripts'],
1414
package_data={'circuitpython_build_tools': ['data/mpy-cross-*']},
1515
zip_safe=False,
16-
python_requires='>=3.4',
17-
install_requires=['Click', 'semver'],
16+
python_requires='>=3.7',
17+
install_requires=['Click', 'requests', 'semver'],
1818
entry_points='''
1919
[console_scripts]
2020
circuitpython-build-bundles=circuitpython_build_tools.scripts.build_bundles:build_bundles

0 commit comments

Comments
 (0)