don't bother building .mpys
This commit is contained in:
parent
2bbb610cc8
commit
d94f705c91
3 changed files with 2 additions and 20 deletions
21
install.py
21
install.py
|
|
@ -2,8 +2,6 @@
|
|||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from circuitpython_build_tools.build import mpy_cross
|
||||
mpy_cross(".venv/bin/mpy-cross", "master")
|
||||
|
||||
def match(dest, content):
|
||||
if not os.path.exists(dest): return False
|
||||
|
|
@ -17,21 +15,10 @@ def copy(destdir, srcdir, name, *, destname=None):
|
|||
with open(src, "rb") as f: content = f.read()
|
||||
put(dest, content)
|
||||
|
||||
def mpy_compile(destdir, srcdir, name, *, destname=None):
|
||||
if destname is None: destname = os.path.splitext(name)[0] + ".mpy"
|
||||
desttemp = os.path.join(destdir, destname + ".tmp")
|
||||
dest = os.path.join(destdir, destname)
|
||||
subprocess.run(['.venv/bin/mpy-cross', "-o", desttemp,
|
||||
os.path.join(srcdir, name)], check=True)
|
||||
with open(desttemp, "rb") as f: newcontent = f.read()
|
||||
if not match(dest, newcontent):
|
||||
os.rename(desttemp, dest)
|
||||
else:
|
||||
os.unlink(desttemp)
|
||||
|
||||
def put(dest, content):
|
||||
if not match(dest, content):
|
||||
with open(dest, "wb") as f: f.write(content)
|
||||
|
||||
SRCPATH = 'src'
|
||||
DSTPATH = 'CIRCUITPY'
|
||||
|
||||
|
|
@ -41,8 +28,4 @@ for dirpath, dirnames, filenames in os.walk('src', followlinks=True):
|
|||
|
||||
for f in filenames:
|
||||
if f.startswith('.'): continue
|
||||
if dirpath == SRCPATH and f in ('code.py', 'main.py'):
|
||||
mpy_compile(outpath, dirpath, f, destname="realmain.mpy")
|
||||
elif f.endswith('.py'): mpy_compile(outpath, dirpath, f)
|
||||
else: copy(outpath, dirpath, f)
|
||||
put("CIRCUITPY/code.py", b"import realmain\n")
|
||||
copy(outpath, dirpath, f)
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
circuitpython-build-tools
|
||||
pylint
|
||||
|
|
|
|||
Loading…
Reference in a new issue