|
| 1 | +Instructions for how to produce a frozen nrfutil executable on MacOS |
| 2 | + |
| 3 | +These instructions describe how to use the cx_freeze tool to generate a |
| 4 | +standalone self-contained (or 'frozen') version of the nrfutil script. This is |
| 5 | +useful for distribution so users don't need to manually install it and deal |
| 6 | +with potential python version headaches and more. |
| 7 | + |
| 8 | +Initial setup (do this once): |
| 9 | +- Get cx_freeze installed for _Python 2.7_. Very important to use Python 2 as |
| 10 | + the nrfutil script doesn't work with Python 3 and cx_freeze will use whichever |
| 11 | + version of Python it's run with to build the exe (i.e. you need to run |
| 12 | + cx_freeze with Python 2.7). Assuming you have homebrew installed: |
| 13 | + - Update python 2 in homebrew to the latest version, and reinstall just to |
| 14 | + fix odd issues like links to old dynamic libraries that might be missing, |
| 15 | + etc. Run: |
| 16 | + brew update |
| 17 | + brew reinstall python |
| 18 | + |
| 19 | + Or if you never had homebrew python2 installed run: |
| 20 | + brew install python |
| 21 | + |
| 22 | + Now just to make sure homebrew python is setup and linked as the 'active' |
| 23 | + python run: |
| 24 | + brew unlink python && brew link python |
| 25 | + - At this point when you run python or pip you should be using homebrew |
| 26 | + python. Do not continue until this is true. |
| 27 | + - Install cx_freeze for homebrew python 2: |
| 28 | + |
| 29 | + pip2 install cx_freeze |
| 30 | + |
| 31 | + Make sure this completes successfully. You should be able to run the |
| 32 | + cxfreeze script and verify it shows usage info: |
| 33 | + |
| 34 | + cxfreeze |
| 35 | +- Install nrfutil dependencies. Be sure to install them into homebrew's python |
| 36 | + 2 as this is what cx_freeze will run from and use to find dependencies. Run |
| 37 | + from this directory: |
| 38 | + |
| 39 | + pip2 install -r requirements.txt |
| 40 | + python setup.py install |
| 41 | +- That's it, you should be setup with cx_freeze on homebrew python 2 and all |
| 42 | + the nrfutil dependencies ready to go. |
| 43 | + |
| 44 | +Generating a frozen nrfutil: |
| 45 | +- You'll run a cxfreeze command to generate the executable and place it in |
| 46 | + the binaries/macos location under the name nrfutil. From this directory run: |
| 47 | + |
| 48 | + cxfreeze ./nordicsemi/__main__.py --target-dir binaries/macos --target-name nrfutil |
| 49 | + |
| 50 | + If it completes without an error message then everything should be good. Try |
| 51 | + running ./binaries/macos/nrfutil to make sure you can get usage info. The |
| 52 | + boards.txt should already be pointing to this file so try using it in Arduino |
| 53 | + to upload to a board. |
0 commit comments