[RSDK-11469] Add Windows support to the CI#17
Conversation
|
Evidence it builds: https://github.com/viam-modules/tensorflow-cpu/actions/runs/16654086812 |
| .setup: setup.sh | ||
| ./setup.sh | ||
|
|
||
| setup: .setup |
There was a problem hiding this comment.
This is confusing. Why are we doing this? Why can't make setup just call the ./setup.sh ? Lmk if I'm missing something.
There was a problem hiding this comment.
This question and the next one have the same answer. When we run setup.sh, the last thing it does if everything else succeeds is create a .setup file in the repo. If that file exists, you don't need to re-run setup.sh every time, because it has already been run in the past. The file starts with a period so that it's normally hidden and you don't have to think about it.
So, line 3 is about how to create the .setup file, and line 6 is syntactic sugar so you can run make setup like you'd expect.
We did the same thing in the duplicate image classifier and blurry image classifier, and IIRC this is how first_run scripts in meta.json work.
I should mark setup as PHONY, so it's clearer that .setup is a real file that gets created but setup is not.
| source $VIRTUAL_ENV/Scripts/activate # Windows | ||
| fi | ||
| pip install --prefer-binary -r requirements.txt -U | ||
|
|
There was a problem hiding this comment.
Also, why are we not doing the Pyinstaller stuff here instead of the Makefile? Like you have to activate the environment again and copy it over twice, etc etc.
There was a problem hiding this comment.
This file is about setup: making sure your machine has everything installed, and only needs to happen once. PyInstaller is about compiling the executable so it can be run, and gets run every time you want to rebuild stuff. It's the same reason that the cloud build section of meta.json has separate "setup" and "build" commands in the cloud build section.
You're right that make setup was previously not only the setup but also built the whole executable. By splitting the two steps out, we can save time not redoing the parts that haven't changed.
Makefile
Outdated
| ACTIVATE = source .venv/bin/activate | ||
| endif | ||
| dist/main: .setup src/* | ||
| $(ACTIVATE) && python -m PyInstaller --onefile --hidden-import="googleapiclient" --add-data="./src:src" src/main.py |
There was a problem hiding this comment.
Khari and I both disliked the duplicated code in here. I think I've made it somewhat better!
- Every line in a recipe is run in its own shell, so we can't have 1 line to activate the venv and another line for Pyinstaller
- The make parser didn't like it when I tried interleaving the if statement with lines ending with
&& \(meaning "and if this line succeeds then as a second part of the current statement run the thing on the next line down"): it would complain about being unable to find theendifstatement. - You can't obviously create variables inside a recipe, but can create them globally outside any recipe. So, create a way to activate the venv globally, and then within the recipe use it and also run PyInstaller.
This was a really good call, thanks! There were multiple bugs around actually uploading the .tar.gz file. The Linux/Mac build still fails its action, but succeeds in uploading entries to the registry. I think I've seen Abe complain that there's a bug in the build action where it mistakenly thinks something has failed even though it succeeded. I'll try to find a Jira ticket for that and ping it again. Tried on |
and other refactoring:
make setup, the script that runs is now calledsetup.sh, and it does setup work.make dist/maintarget that builds the executable.publish.ymlto build and upload on Windows. I've marked the file as one to run onworkflow_dispatchso you can manually run it without creating a release, and have gotten that to work.pip freezegives no output! This happens on both Windows and Linux. So, I gave up on that for the moment.