Invoking mpy_cross.run() gives "Permission denied" on Linux
Dear @andrewleech,
thank you so much for bringing the fine tools around MicroPython to the community. We are just getting started using mpy-cross within our MicroPython projects and have been pleased to see that there is the nicely wrapped https://pypi.org/project/mpy-cross/ already.
When using mpy-cross on Linux, we just experienced a minor issue we would like to share with you.
Problem
While everything works as expected on macOS, we are getting this error when installing on Linux:
pip install mpy-cross
.venv3/lib/python3.5/site-packages/mpy_cross/mpy-cross --version
-bash: .venv3/lib/python3.5/site-packages/mpy_cross/mpy-cross: Permission denied
Indeed the permissions on the mpy-cross binary are different compared between macOS and Linux.
Linux
l .venv3/lib/python3.5/site-packages/mpy_cross/mpy-cross
292K -rw-r--r-- 1 root root 288K Jul 28 12:57 .venv3/lib/python3.5/site-packages/mpy_cross/mpy-cross
macOS
l .venv3/lib/python3.7/site-packages/mpy_cross/mpy-cross
-rwxr-xr-x 1 amo staff 370500 Jul 28 03:53 .venv3/lib/python3.7/site-packages/mpy_cross/mpy-cross*
Workaround
We have been able to mitigate the problem by adjusting the permissions after installation.
# Setup mpy-cross, platform-agnostic
pip install mpy-cross
chmod +x "$(dirname $(python -c 'import mpy_cross; print(mpy_cross.__file__)'))/mpy-cross"
# Pre-flight checks
python -m mpy_cross --version
MicroPython v1.11-dirty on 2019-06-01; mpy-cross emitting mpy v4
Thanks already for your efforts looking into this.
With kind regards, Andreas.
Edited by Andreas Motl