-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Launcher for Windows #103
base: master
Are you sure you want to change the base?
Launcher for Windows #103
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@if not defined _echo echo off | ||
set "lscp-path=%cd%" | ||
|
||
rem https://stackoverflow.com/questions/22352793/reading-a-registry-value-to-a-batch-variable-handling-spaces-in-value | ||
for /f "usebackq tokens=2,*" %%h in ( | ||
`"reg query "HKLM\SOFTWARE\Kitware\CMake\Packages\pico-sdk-tools" 2>NUL | find /i "SDK""` | ||
) do ( | ||
set "pico-env-for-projGen-path=%%i" | ||
) | ||
|
||
cd /D "%pico-env-for-projGen-path%" | ||
cd .. | ||
set "pico-env-for-projGen-path=" | ||
call pico-env.cmd | ||
|
||
cd /D %lscp-path% | ||
set "lscp-path=" | ||
|
||
REM https://blog.finxter.com/how-to-find-path-where-python-is-installed-on-windows/ | ||
py.exe -c "import os, sys; print(os.path.dirname(sys.executable))" > lspver.tmp | ||
set /p ls-pypath= < lspver.tmp | ||
del lspver.tmp | ||
call "%ls-pypath%\python" pico_project.py --gui | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just using py.exe pico_project.py --gui shows "Python was not found". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the Microsoft docs, when called with arguments, the app execution aliases will return the error about Python not being found. Which means that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange, but I can confirm that it is working on Windows 10 22H2. And so does the similar variant in the enhanced script. The new version does not need the lspver.tmp file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, they fixed the Python for Windows installer at some point to set the 'real' python executables as higher priority than the Windows store aliases. So my own understanding is:
I've also noticed that there is no alias for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TLDR: Shall we use an own implementation of python path discovery or use py?Important note: "Add python.exe to PATH" is not default and I did not use this option before. py.exe -c "import os, sys; print('Python Path ' + os.path.dirname(sys.executable))" But it seems that you are expecting to use the non-default option "Add python.exe to PATH". So, I did: Afterwards checked: The reason, why the py.exe executed script detection is so good: Because of that, it finds the full installation of Python rather than the embedded one in pico-setup-windows. It doesn´t matter if python or pythonw, the path to the full installation can be got from: I have to admit that py.exe may not be present on every system, but on the other hand, it does a great job. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry about the late response. On further testing I see that this approach works for Python distributions installed using the downloaded installer; but does not work for distributions from the Microsoft Store. On a computer with that configuration:
Running the same command with Rolling our own Python path discovery isn't something I would want to add to this project. However we could figure out a way for the project generator to discover installed Pico SDK versions somehow, so if a user launches the project generator themselves, they would not be stuck with the embedded Python distribution with the Pico SDK. |
||
set ls-pypath= | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest that you check the uninstall entry to detect the path of pico-setup-windows, e.g.
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Raspberry Pi Pico SDK v*
, valueInstallPath
.I guess it'll be harder to enumerate keys to find the latest version this way, but maybe consider a PowerShell snippet here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I have changed the script accordingly. I can share if it is of interest.
PowerShell would be nice. I will consider changing the complete script to PowerShell instead of using just a snippet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are interested in the PowerShell version of the launcher: It is available here:
https://github.com/BitRolher/pico-project-generator/tree/BitRolher-WinLauncherPSversion