-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add file type association to Spyder shortcuts on all platforms. #171
Changes from 10 commits
9937076
eb7a43c
ead6868
4cc1cb7
f423944
5ed1118
92ea0b8
af6d6a0
b3eac2c
2b7de75
1daf0b5
a0952b8
0dd6882
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 |
---|---|---|
|
@@ -6,22 +6,32 @@ if errorlevel 1 exit 1 | |
set MENU_DIR=%PREFIX%\Menu | ||
IF NOT EXIST (%MENU_DIR%) mkdir %MENU_DIR% | ||
|
||
rem Copy Spyder's icon | ||
copy %RECIPE_DIR%\spyder.ico %MENU_DIR%\spyder.ico | ||
|
||
rem Replace variables in menu files | ||
for /F "delims=. tokens=1" %%i in ("%PKG_VERSION%") do set PKG_MAJOR_VER=%%i | ||
call :replace spyder-menu.json spyder-menu.json | ||
call :replace spyder-menu-v1.json spyder-menu-v1.json.bak | ||
|
||
for /f "delims=" %%i in (%RECIPE_DIR%\spyder-menu.json) do ( | ||
set s=%%i | ||
set s=!s:__PKG_VERSION__=%PKG_VERSION%! | ||
echo !s:__PKG_MAJOR_VER__=%PKG_MAJOR_VER%!>> %MENU_DIR%\spyder-menu.json | ||
rem Copy GUI executable stub | ||
for /F "tokens=*" %%i in ( | ||
'%CONDA_PYTHON_EXE% -c "import conda_build, pathlib; print(pathlib.Path(conda_build.__file__).parent / 'gui-64.exe')"' | ||
) do ( | ||
set exe_path=%%i | ||
) | ||
copy /y /b %exe_path% %SCRIPTS% | ||
|
||
for /f "delims=" %%i in (%RECIPE_DIR%\spyder-menu-v1.json) do ( | ||
set s=%%i | ||
set s=!s:__PKG_VERSION__=%PKG_VERSION%! | ||
echo !s:__PKG_MAJOR_VER__=%PKG_MAJOR_VER%!>> %MENU_DIR%\spyder-menu-v1.json.bak | ||
) | ||
rem Copy launch script | ||
copy /y %RECIPE_DIR%\spyder-script.pyw %SCRIPTS% | ||
|
||
:exit | ||
exit /b %errorlevel% | ||
|
||
del %SCRIPTS%\spyder_win_post_install.py | ||
del %SCRIPTS%\spyder.bat | ||
del %SCRIPTS%\spyder | ||
Comment on lines
-25
to
-27
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 are not we removing these scripts now? I think they shouldn't be part of the package. 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. I agree that they should not be part of the package. I removed these lines because these files were not being added to the 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, I've confirmed that these files are not in the Scripts directory of the conda package (or anywhere else). Only the following:
|
||
:replace | ||
for /f "delims=" %%i in (%RECIPE_DIR%\%1) do ( | ||
set s=%%i | ||
set s=!s:__PKG_VERSION__=%PKG_VERSION%! | ||
echo !s:__PKG_MAJOR_VER__=%PKG_MAJOR_VER%!>> %MENU_DIR%\%2 | ||
) | ||
goto :eof |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
[[ $(sed --version 2>/dev/null) ]] && opts=("-i" "-E") || opts=("-i" "''" "-E") | ||
[[ $(sed --version 2>/dev/null) ]] && opts=("-i" "-E") || opts=("-i" "" "-E") | ||
menu="${PREFIX}/Menu/spyder-menu.json" | ||
|
||
if [[ -f "${PREFIX}/Menu/conda-based-app" ]]; then | ||
# Installed in installer environment, abridge shortcut name | ||
sed ${opts[@]} "s/ \(\{\{ ENV_NAME \}\}\)//g" $menu | ||
elif [[ -d "${PREFIX}/condabin" && -d "${PREFIX}/envs" ]]; then | ||
# Installed in a base environment, use distribution name | ||
sed ${opts[@]} "s/ENV_NAME/DISTRIBUTION_NAME/g" $menu | ||
sed "${opts[@]}" "s/ \(\{\{ ENV_NAME \}\}\)//g" $menu | ||
fi |
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 is this script necessary now? 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. This is required for Spyder to be listed as an application for file types in context menus. Windows looks at the shortcut executable for this, so when using See: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
# -*- coding: utf-8 -*- | ||
mrclary marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import re | ||
import sys | ||
|
||
from spyder.app.start import main | ||
|
||
if __name__ == '__main__': | ||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) | ||
sys.exit(main()) |
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.
Is this replacement correct? Shouldn't it be replacing a
.bak
file, like in the line just below this one?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.
:replace
reads the lines in the first file and replaces the__PKG_VERSION__
tokens with the major version number, then writes the lines to the second file. The default json file is formenuinst
v2, so we just write back to the same file. Any*.json
file will be executed bymenuinst
, so on the line below we also need to rename thespyder-menu-v1.json
file so thatmenuinst
does not try to execute on it. Thepost-link.bat
script will determine whether v1 or v2 is in the base environment, and swap them if needed.But perhaps it would be clearer to just have both files
spyder-menu-v1.json
andspyder-menu-v2.json
, then letpost-link.bat
add.bak
to the unnecessary file.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.
Actually, the file names in the
Menu
directory should not change on install so that they will all be removed on uninstall. So it will be best to havespyder-menu-v1.json.bak
andspyder-menu.json
. Then copy v1 tospyder-menu.json
(overwriting) only if necessary.