Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Should be possible to move settings to user folder #351

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

Closed
nerdfever opened this issue Jun 28, 2016 · 11 comments
Closed

Should be possible to move settings to user folder #351

nerdfever opened this issue Jun 28, 2016 · 11 comments

Comments

@nerdfever
Copy link

Currently WinPython stores settings in the install folder.

For example: C:\WinPython-64bit-3.4.4.2\settings

The user should be able to move these to the user home folder (%USERPROFILE%).

Reasons:

1 - Usually only user data is backed up
2 - The current location doesn't carry over to updated versions of WinPython
3 - The current location is global (there may be multiple users on one machine)

@hiccup7
Copy link

hiccup7 commented Jul 6, 2016

Additional reason:
4 - Permits use of a Software Restriction Policy because executables can be in C:\Program Files. This security is especially important for schools. See http://www.mechbgon.com/srp/

My experience is that having one settings folder for multiple versions of WinPython creates compatibility problems between versions of Spyder, pylint, matplotlib, etc. Therefore, I create a separate settings folder for each WinPython version in %APPDATA%\WinPython\envW.X.Y.Z

By reverse-engineering the batch files supplied by WinPython, I created my own batch file to launch Spyder. As an example, here is my
C:\Program Files\WinPython-3.4.4.2\spyder_env3.4.4.2.bat:

@echo off
set WINPYDIR=C:\Program Files\WinPython-3.4.4.2\python-3.4.4.amd64
set WINPYVER=3.4.4.2
set HOME=%APPDATA%\WinPython\env3.4.4.2
set PATH=%WINPYDIR%\Lib\site-packages\PyQt4;%WINPYDIR%\;%WINPYDIR%\DLLs;%WINPYDIR%\Scripts;%WINPYDIR%\..\tools;%WINPYDIR%\..\tools\mingw32\bin;%PATH%
cd %WINPYDIR%\Scripts
spyder.exe %*

rem force default Qt kit for Spyder
set QT_API=pyqt

@stonebig
Copy link
Contributor

hi,

since #272 of march 5th, you should have:

  • a "script\make_working_directory_be_not_winpython.bat",
  • and a "make_working_directory_be_winpython.bat"

This is to alternate between a user directory folder and a winpython one.
It may be in recent release you have

@stonebig
Copy link
Contributor

stonebig commented Jul 18, 2016

and the user directory is specific to each version "C:\Users\xxx\Documents\WinPython3.4.4.1" for example.

maybe it's not enough. waiting for comments

https://github.com/winpython/winpython/blob/master/make.py#L592..595

@nerdfever
Copy link
Author

FWIW, at the moment I'm using a variant of @hiccup7 's batch file.

It works OK except that it leaves a DOS window open the whole time I'm using Spyder.

@nerdfever
Copy link
Author

I'd like to re-open this issue.

@hiccup7 's batch file solution not only leaves open a DOS window, worse, it doesn't work with right clicking on "Edit file with Spyder".

If you do that Spyder launches without any of the user's settings (took me a while to figure out this is why it worked OK sometimes, but not other times).

@stonebig stonebig reopened this Oct 1, 2016
@hiccup7
Copy link

hiccup7 commented Nov 27, 2016

I too was annoyed at the DOS window staying open/visible, so I fixed it today. Here is my latest batch file using "start" to invoke Spyder:

@echo off
set WINPYDIR=C:\Program Files\WinPython-3.5.2.3Qt5\python-3.5.2.amd64
set WINPYVER=3.5.2.3Qt5
set HOME=%APPDATA%\WinPython\env3.5.2.3Qt5
set PATH=%WINPYDIR%\Lib\site-packages\PyQt5;%WINPYDIR%\;%WINPYDIR%\DLLs;%WINPYDIR%\Scripts;%WINPYDIR%\..\tools;%PATH%
cd %WINPYDIR%\Scripts
rem force default pyqt5 kit for Spyder
set QT_API=pyqt5
rem Start Spyder with a separate window so this Command Prompt window terminates.
start spyder.exe %*

The Windows Explorer right-click menu is controlled by registry keys. Here is an example.reg file that can be edited for controlling all the WinPython registry keys that I know of:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File]
@="Python File"

[HKEY_CLASSES_ROOT\Python.File\DefaultIcon]
@="C:\\Program Files\\WinPython-3.5.2.1\\python-3.5.2.amd64\\DLLs\\py.ico"

[HKEY_CLASSES_ROOT\Python.File\shell]

[HKEY_CLASSES_ROOT\Python.File\shell\open]

[HKEY_CLASSES_ROOT\Python.File\shell\open\command]
@="\"C:\\Program Files\\WinPython-3.5.2.1\\python-3.5.2.amd64\\python.exe\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.File\shell\Run in interactive mode]
@=""

[HKEY_CLASSES_ROOT\Python.File\shell\Run in interactive mode\command]
@="\"C:\\Program Files\\WinPython-3.5.2.1\\python-3.5.2.amd64\\python.exe\" \"-i\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.File\shellex]

[HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

[HKEY_CLASSES_ROOT\Python.CompiledFile]
@="Compiled Python File"

[HKEY_CLASSES_ROOT\Python.CompiledFile\DefaultIcon]
@="C:\\Program Files\\WinPython-3.5.2.1\\python-3.5.2.amd64\\DLLs\\pyc.ico"

[HKEY_CLASSES_ROOT\Python.CompiledFile\shell]

[HKEY_CLASSES_ROOT\Python.CompiledFile\shell\open]

[HKEY_CLASSES_ROOT\Python.CompiledFile\shell\open\command]
@="\"C:\\Program Files\\WinPython-3.5.2.1\\python-3.5.2.amd64\\python.exe\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.CompiledFile\shellex]

[HKEY_CLASSES_ROOT\Python.CompiledFile\shellex\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

[HKEY_CLASSES_ROOT\Python.NoConFile]
@="Python File (no console)"

[HKEY_CLASSES_ROOT\Python.NoConFile\DefaultIcon]
@="C:\\Program Files\\WinPython-3.5.2.1\\python-3.5.2.amd64\\DLLs\\py.ico"

[HKEY_CLASSES_ROOT\Python.NoConFile\shell]

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\open]

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\open\command]
@="\"C:\\Program Files\\WinPython-3.5.2.1\\python-3.5.2.amd64\\pythonw.exe\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Run in interactive mode]
@=""

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Run in interactive mode\command]
@="\"C:\\Program Files\\WinPython-3.5.2.1\\python-3.5.2.amd64\\python.exe\" \"-i\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.NoConFile\shellex]

[HKEY_CLASSES_ROOT\Python.NoConFile\shellex\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

[HKEY_CLASSES_ROOT\.py]
@="Python.File"
"Content Type"="text/plain"

[HKEY_CLASSES_ROOT\.pyc]
@="Python.CompiledFile"

[HKEY_CLASSES_ROOT\.pyo]
@="Python.CompiledFile"

[HKEY_CLASSES_ROOT\.pyw]
@="Python.NoConFile"
"Content Type"="text/plain"

@hiccup7
Copy link

hiccup7 commented Nov 27, 2016

Here is another example.reg file for associating *.py files with an editor in the Windows Explorer right-click menu:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File]
@="Python File"

[HKEY_CLASSES_ROOT\Python.File\DefaultIcon]
@="C:\\Program Files\\Python27\\DLLs\\py.ico"

[HKEY_CLASSES_ROOT\Python.File\shell]

[HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE]

[HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command]
@="\"C:\\Program Files\\Python27\\pythonw.exe\" \"C:\\Program Files\\Python27\\Lib\\idlelib\\idle.pyw\" -e \"%1\""

[HKEY_CLASSES_ROOT\Python.File\shell\open]

[HKEY_CLASSES_ROOT\Python.File\shell\open\command]
@="\"C:\\Program Files\\Python27\\python.exe\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.File\shell\Run in interactive mode]
@=""

[HKEY_CLASSES_ROOT\Python.File\shell\Run in interactive mode\command]
@="\"C:\\Program Files\\Python27\\python.exe\" \"-i\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.File\shellex]

[HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

@hiccup7
Copy link

hiccup7 commented Mar 4, 2017

Starting with Spyder v3.1.3, replace "spyder.exe" with "spyder3.exe" in batch files.

@nerdfever
Copy link
Author

Starting with Spyder v3.1.3, replace "spyder.exe" with "spyder3.exe" in batch files.

And that will do...what?

In particular, will it make right-clicking on a .py with "Edit with Spyder" load user preferences?

@hiccup7
Copy link

hiccup7 commented Mar 4, 2017

The name of the executable changed in v3.1.3. Therefore, batch files and, as @nerdfever pointed out, registry entries using the Spyder executable have to change.

I don't have a ready solution for making right-clicking on a .py with "Edit with Spyder" load user preferences. Maybe you could use my regedit script above to understand how to add that functionality, but it would likely involve the registry key pointing to a batch file like the above to set up the environment variables for Spyder.

@stonebig
Copy link
Contributor

stonebig commented May 4, 2025

I suppose the subject is closed, nowodays. reopen if needed

@stonebig stonebig closed this as completed May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants