Open jypeter opened 3 months ago
The shortcuts you mention still use the menuinst v1 syntax. The automatic addition of the environment name has been removed in v2 (see #180 about how I tried to re-introduce it). Here is an example recipe for a menuinst v1 shortcut: https://github.com/AnacondaRecipes/console_shortcut-feedstock/tree/main/recipe
There is an easier way to do it if you don't mind the word base
in your shortcut name by using the {{ ENV_NAME }}
placeholder. So, you would see something like Anaconda Prompt (base)
and Anaconda Prompt (environment)
instead of Anaconda Prompt
and Anaconda Prompt (environment)
.
Version 2 of menuinst can still install v1 shortcuts: https://github.com/conda/menuinst/tree/main/menuinst/_legacy
The placeholders for v1 are defined here: https://github.com/conda/menuinst/blob/main/menuinst/_legacy/win32.py#L103-L119
The syntax for placeholders has changed from v1 to v2, as you noticed, from ${...}
to {{ ... }}
.
You can add a Windows terminal shortcut by adding the terminal_profile
option, but it requires v2. This will create a terminal profile where command
is being executed. I am working on something like that for the console shortcuts, but the package isn't fully fleshed out yet. Note that profiles with the same name are overwritten, so you need to include the {{ ENV_NAME }}
placeholder in the terminal_profile
name if you want something for base and non-base environments.
Please let me know if I missed anything.
Checklist
What happened?
My problem
I have installed miniconda3 on Windows 10 (and on several Linux platforms) and thoroughly documented all the steps, so that our students can understand and replicate this, and can then create their own clean environments, without altering the base environment
After installing miniconda3 on Windows, you end up with a
Miniconda3 (64-bit)
Windows menu, a shortcut to open anAnaconda Powershell Prompt
and one to open anAnaconda Prompt
, both with thebase
environment activatedI had no idea where these convenient shortcuts were coming from, and I wanted to find a clean way to create direct shortcuts to new (non-
base
) environments, on Windows. So that students can directly start a specific environment, without having totype conda activate env
). You've got to make things easy for new users, if you want to get them past notebooks...What I have tried
I have relatively quickly found out about
menuinst
on Google and played a bit (a lot, too much, actually) with in order to understand more about the json config files. I figured that generating and distributing a good json config file to our students would do the trickUnfortunately, I have read and re-read the menuinst documentation (and filled some issues along the way) and got the impression I was running in circles and not getting anywhere near my easy environment initialization goal.
The documentation is not very clear/detailed about using non-base environments. The closest thing I found was Specifying different shortcut names for base and non-base environments. But this seemed like a very convoluted way to get thins done, and I did not really get it working. Maybe I'll fill an issue about that. For selecting a non based environment, I was more expecting something like : use a parameter in the json file to specify the environment name, and then create the shortcuts by calling menuinst in the base environment
I also tried to do some reverse engineering by comparing the content of my json files to the generated
.lnk
and.bat
files but this only got me some severe headaches. I'm mostly a Linux user and I know next to nothing about.bat
files and powershell syntaxWhat seems to work (without using menuinst explicitly...)
I tried to understand where the Windows shortcuts (to
base
) that appeared when I installed miniconda3 were coming from, and I eventually found out that they were provided by thepowershell_shortcut_miniconda
andconsole_shortcut_miniconda
packages bundled with miniconda3 !It is actually trivial to install or uninstall either the
powershell
or theconsole
shortcuts (or both) by just installing or removing thepowershell_shortcut_miniconda
andconsole_shortcut_miniconda
packagesIn the example below, I easily create a Windows menu shortcut to my
spyder_test
environment, from thebase
environmentAfter testing the Windows menu shortcut, I can also easily remove the shortcut, still from the
base
environmentI can also create and remove the shortcuts directly from the non-
base
environment. Note that menuinst is not installed in that environment, but I guess that if conda can be called from this non-base
environment, it can also use menuinst from the base environmentHow do 'powershell_shortcut_miniconda' and 'console_shortcut_miniconda' work ?
I'm glad I found an easy solution to my initial problem, but this raised other questions
I have found the following json files in the packages
C:\Utils\miniconda3_2024-03\pkgs\console_shortcut_miniconda-0.1.1-haa95532_2\Menu\console_shortcut.json
C:\Utils\miniconda3_2024-03\pkgs\powershell_shortcut_miniconda-0.0.1-haa95532_2\Menu\powershell_shortcut.json
My new questions:
${PY_VER}
is giving a better result (3
) than the{{ PY_VER }}
placeholder (N. A.
). See #235My other requirement: Windows Terminal profiles
I would also like to easily create Windows Terminal profiles that would open a Windows terminal using the
base
or a non-base
environment.I understand that this can theoretically be achieved with the
terminal_profile
option, and has been covered by #196 . Can somebody provide a detailed example for both cases (base
and non-base
). I have already spent way tp much time on this and I need to move on to creating actual complex (and non-base
!) environmentsThere are lots of online tutorials to do this, but they may be obsolete or not safe. And I'd like a clean way to do this (distributing a json file would be nice)
Thanks!
Additional Context
No response