Skip to content

Commit c8a8513

Browse files
committed
mpy_cross: Cache it in the user cache path
.. rather than in a build_deps folder, polluting the repo where it's used this also enables sharing the copy of mpy-cross across multiple repos.
1 parent 90a2341 commit c8a8513

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

circuitpython_build_tools/scripts/build_bundles.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import zipfile
3333

3434
import click
35+
import platformdirs
3536

3637
from circuitpython_build_tools import build
3738
from circuitpython_build_tools import target_versions
@@ -41,6 +42,7 @@
4142
else:
4243
import importlib.metadata as importlib_metadata
4344

45+
mpy_cross_path = platformdirs.user_cache_path("circuitpython-build-tools", ensure_exists=True)
4446

4547
BLINKA_LIBRARIES = [
4648
"adafruit-blinka",
@@ -282,7 +284,7 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
282284
if "mpy" not in ignore:
283285
os.makedirs("build_deps", exist_ok=True)
284286
for version in target_versions.VERSIONS:
285-
mpy_cross = "build_deps/mpy-cross-" + version["name"] + (".exe" * (os.name == "nt"))
287+
mpy_cross = mpy_cross_path / ("mpy-cross-" + version["name"] + (".exe" * (os.name == "nt")))
286288
build.mpy_cross(mpy_cross, version["tag"])
287289
zip_filename = os.path.join(output_directory,
288290
filename_prefix + '-{TAG}-mpy-{VERSION}.zip'.format(

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ requests
33
semver
44
wheel
55
tomli; python_version < "3.11"
6+
platformdirs

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package_data={'circuitpython_build_tools': ['data/mpy-cross-*']},
1515
zip_safe=False,
1616
python_requires='>=3.10',
17-
install_requires=['Click', 'requests', 'semver', 'tomli; python_version < "3.11"'],
17+
install_requires=['Click', 'requests', 'semver', 'tomli; python_version < "3.11"', 'platformdirs'],
1818
entry_points='''
1919
[console_scripts]
2020
circuitpython-build-bundles=circuitpython_build_tools.scripts.build_bundles:build_bundles

0 commit comments

Comments
 (0)