-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix the fact that spyder_win_post_install.py can't be run from pip #2377
Conversation
* add missing bdist_wininst functions from pywin32_postinstall.py: file_created(), directory_created(), get_root_key(), create_shortcut() and get_special_folder_path() * test for pythoncom and return message "pywin32 required" on ImportError * replace CSIDL_COMMON_PROGRAMS with CSIDL_PROGRAMS to be consistent with desktop shortcut which is in user profile, and so that user doesn't have to elevate rights in order to install spyder * add TODO to remove error message "try running installer as administrator" since it's unnecessary if admin rights not required. * if running spyder_win_post_install.py -install manually after installing with pip, then spyder.ico and spyder_light.ico are in the Python27\Scripts\ folder not in the distribution folder, so check if ico_dir exists and use absolute path to spyder_win_post_install.__file__ * clean up desktop and start menu shortcuts on removal * provide feedback on successful removal of context, desktop and start menu shortcuts Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
73fa06c
to
1ad9e63
Compare
@@ -21,17 +21,95 @@ | |||
KEY_C1 = KEY_C0 + r"\command" | |||
|
|||
|
|||
# ability to run spyder-win-post-install outside of bdist_wininst installer | |||
# copied from pywin32-win-post-install |
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.
Could you post here a link to Github (or Bitbucket, etc) where we can read pywin32-win-post-install
code?
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.
The pywin32 mercurial repository is on sourceforge. The most recent build is tagged as b219. Here's a link to pywin32_postinstall.py
.
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 for not being clear enough :-) Please add the link to the file, below the last line of your comment.
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.
check out 330b0aa
One thing that I'd like to know is if it's possible to tell pip to run this script after install/uninstall steps. I mean, can't we add something to |
That would be very nice if the post install script could be run automatically, although I was thinking of making that a separate feature after this one gets pulled. Another feature I thought would be nice is a post install script for other platforms that does the equivalent for linux and mac osx. IE on linux it could create a desktop file in Back to your question, though, I don't know how to get pip to run the script. I don't if you can add it to Thanks! |
* add link to `pwin32_postinstall.py` in hg repo on sf.net * add comments to explain `file_created()` and `directory_created()` dummy functions, and how to remove shortcuts and startmenu directory using `spyder_win_post_install.py` with `-remove` option Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
def get_root_hkey(): | ||
try: | ||
winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, | ||
root_key_name, 0, winreg.KEY_CREATE_SUB_KEY) |
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.
root_key_name
is not defined anywhere in your PR, so this call is going to fail, right?
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.
@ccordoba12 good catch, on windows this key is hkey_local_machine\Software\Python\PythonCore\2.7
for python installed with msi, however, I don't know what it would be on a windows system that has a bootstrapped Python, eg: WinPython, portable python or any python just unzipped in and executed from a standalone folder.
This is only run by bdist_wininst
and it's sole purpose is to determine if the user has elevated their rights, if so then use hkey_local_machine
and if not then use hkey_current_user
. Therefore even if this call fails, it will just fall back to hkey_current_user
which is what we want anyway, so it doesn't matter. But for those that have installed official python, and have admin rights, then it will use the system registry keys.
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.
Ok, then we can leave it without problems :-)
Please address my other comments :-)
Ok, my final review is done. Sorry for taking so much time to do it :-) Please try to address my comments later today or tomorrow morning, if you want to include this PR in 2.3.5. Else, I'll leave it for 3.0. |
Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
* startmenu items are added to users startmenu not system, so running as admin will not help if install fails
Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
Thanks @ccordoba12 for your review, I have addressed your current comments:
|
CSIDL_LOCAL_APPDATA CSIDL_APPDATA CSIDL_COMMON_DESKTOPDIRECTORY | ||
CSIDL_DESKTOPDIRECTORY CSIDL_COMMON_STARTUP CSIDL_STARTUP | ||
CSIDL_COMMON_PROGRAMS CSIDL_PROGRAMS CSIDL_PROGRAM_FILES_COMMON | ||
CSIDL_PROGRAM_FILES CSIDL_FONTS""".split(): |
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.
Why not creating a list directly instead of splitting a string ?
Performance-wise it won't matter but it would be more obvious to understand. I had to read these lines 3 times to spot the .split()
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.
+1 to this last comment from @Nodd.
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'll do this myself after merging.
@mikofski, thanks for the quick response! I'll merge it tomorrow and backport it to 2.3.5 (which will be released tomorrow too :-) |
Fix the fact that spyder_win_post_install.py can't be run from pip
@mikofski, I tested your work before releasing 2.3.5 and it's working great! Thanks a lot for it. |
That's great news! Glad I could contribute. |
Fixes #2188
bdist_wininst
functions frompywin32_postinstall.py
:file_created()
,directory_created()
,get_root_key()
,create_shortcut()
and
get_special_folder_path()
pythoncom
and return message "pywin32 required" onImportError
CSIDL_COMMON_PROGRAMS
withCSIDL_PROGRAMS
to be consistent withdesktop shortcut which is in user profile, and so that user doesn't have
to elevate rights in order to install Spyder
administrator" since it's unnecessary if admin rights not required.
spyder_win_post_install.py -install
manually after installingwith pip, then
spyder.ico
andspyder_light.ico
are in thePython27\Scripts\
folder not in the distribution folder, so check ifico_dir
exists and use absolute path tospyder_win_post_install.__file__
menu shortcuts
Signed-off-by: Mark Mikofski mark.mikofski@sunpowercorp.com