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
Cleanup .bat
scripts and ensure dev/start.bat
uses source code's conda_hook.bat
#13837
base: 24.5.x
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #13837 will not alter performanceComparing Summary
|
Review build status
Once it's done, use this command to try it out in a new conda environment:
|
@REM SPDX-License-Identifier: BSD-3-Clause | ||
@CALL "%~dp0..\..\condabin\conda.bat" %* | ||
:: Copyright (C) 2012 Anaconda, Inc | ||
:: SPDX-License-Identifier: BSD-3-Clause |
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.
Yes much tidier ❤️
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.
Looks good.
One thing I can't help but wonder is if there are any linting tools for batch scripts? Maybe this would be something to add to pre-commit? Not necessary for this PR but just a thought.
Nice. This can be maybe made even tidier (and better to read) via the pattern |
If you're going to do this then Line 13, or an equivalent, is critical, https://github.com/conda-forge/ripgrep-feedstock/blob/main/recipe/bld.bat#L13. Without it, all your code paths will dutifully run through the |
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.
This does look better, but OTOH I wish we'd have something like black for batch files.
IF DEFINED CONDA_PS1_BACKUP ( | ||
:: Handle transition from shell activated with conda 4.3 to a subsequent activation | ||
:: after conda updated to 4.4. See issue #6173. | ||
SET "PROMPT=%CONDA_PS1_BACKUP%" | ||
SET CONDA_PS1_BACKUP= | ||
) |
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.
Should we... remove this?
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 love to, if someone updates from an older conda that breaks their prompt they can just restart their shell and should be good to go
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.
Let's leave this as is for now and work to remove it in the future
While testing canary builds I discovered issues with some of these changes, still debugging |
:: skip checking for quotes if there are no arguments | ||
IF [%1]==[] GOTO :SKIP_CHECK | ||
|
||
:: enter localized variable scope | ||
SETLOCAL | ||
|
||
:: Test first character and last character of %1 to see if first character is a " | ||
:: but the last character isn't. | ||
:: This was a bug as described in https://github.com/ContinuumIO/menuinst/issues/60 | ||
:: When Anaconda Prompt has the form | ||
:: %windir%\system32\cmd.exe "/K" "C:\Users\builder\Miniconda3\Scripts\activate.bat" "C:\Users\builder\Miniconda3" | ||
:: Rather than the correct | ||
:: %windir%\system32\cmd.exe /K ""C:\Users\builder\Miniconda3\Scripts\activate.bat" "C:\Users\builder\Miniconda3"" | ||
:: this solution taken from https://stackoverflow.com/a/31359867 | ||
|
||
SET "_ARG=%1" | ||
SET _ARG_FIRST=%_ARG:~0,1% | ||
SET _ARG_LAST=%_ARG:~-1% | ||
SET _ARG_FIRST=%_ARG_FIRST:"=+% | ||
SET _ARG_LAST=%_ARG_LAST:"=+% | ||
|
||
:: if the first character is not a quote we can skip further quote checking | ||
IF NOT [%_ARG_FIRST%]==[+] ENDLOCAL & GOTO :SKIP_CHECK | ||
|
||
:: the first and last characters appear to be matching quotes so we can activate normally | ||
IF [%_ARG_LAST%]==[+] ENDLOCAL & GOTO :SKIP_CHECK | ||
|
||
:: found a quote mismatch, we assume this is a bug in the downstream code | ||
ENDLOCAL & CALL "%~dp0\..\condabin\conda.bat" activate | ||
GOTO :EOF | ||
|
||
:SKIP_CHECK |
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 prefer to remove this special bug handling for Anaconda Prompt/Menuinst
Thoughts @jaimergp @marcoesters
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.
Sorry, I missed the tag. Right now, the target of the shortcut looks like this
%windir%\System32\cmd.exe "/K" C:\Users\<user>\miniconda3\Scripts\activate.bat C:\Users\<user>\miniconda3
So, maybe install console_shortcut_miniconda
or console_shortcut
with the dev version of conda
and see if the workaround is still necessary?
if it is, removing it is tricky because that would render that shortcut unusable when a user updates conda
.
Description
Many small improvements:
rem
/REM
/@rem
/@REM
with the tidier::
%ERRORLEVEL%
checking@IF
clauses to useDEFINED
when possible and to otherwise use[%VAR%]==[value]
DOSKEY conda=
instead ofDEFINED CONDA_SHLVL
dev\start.bat
to use source code'scondabin
&conda_hook.bat
(so we can test bat script edits via our devenv)Checklist - did you ...
Add a file to thenews
directory (using the template) for the next release's release notes?Add / update necessary tests?Add / update outdated documentation?