Skip to content

Settings folder is re-created in WINPYTHON_DIR #262

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
guaguanco opened this issue Feb 24, 2016 · 13 comments
Closed

Settings folder is re-created in WINPYTHON_DIR #262

guaguanco opened this issue Feb 24, 2016 · 13 comments

Comments

@guaguanco
Copy link

As explained on https://github.com/winpython/winpython/wiki/Installation#settings I removed the [WINPYTHON_DIR]\settings directory to enable per user settings. However, every time I start Jupiter the folder is created again with the content:

.
├── nbsignatures.db
├── notebook_secret
└── runtime
    └── notebook_cookie_secret

I'm using WinPython 3.4.4.1Qt5

@guaguanco
Copy link
Author

just to explain how I'm using WinPython, I keep a shared (customised) installation of WinPython for my class on a shared folder. That folder is read only, so runtime files must be created in the user profile directory.

Is there a recommended way of doing this? With a previous version of WinPython (3.4.3.2) I had no problems

@cenano
Copy link

cenano commented Feb 24, 2016

Same issue here (Windows 7, 64 bit, WinPython 3.4.4.1Qt5 and WinPython 3.4.4.1). Additionally, just logged in as a normal user I even can't start "Jupyter Notebook" nor "IPython Qt Console". I'm getting a ... "PermissionError: [WinError5] Access is denied: 'C:\Program Files\WinPython-64bit-3.4.4.1Qt5\settings'" ...

@stonebig
Copy link
Contributor

Hi @guaguanco ,

I optimized Winpython default config to run in inside the %WINPYDIR% directory because:

  • it's one of my target use case,
  • the other one, yours, may generate problems is you have several WinPython installations on the same PC.

Your case is nevertheless important to my eyes, and the two Variables to get right should be

set JUPYTER_DATA_DIR=%WINPYDIR%\..\settings
set HOME=%WINPYDIR%\..\settings

Please try the following:

  • create the following script script ipython_notebook_student.bat in your WinPython 3.4.4.1Qt5\scripts directory
@echo off
call %~dp0env.bat

rem classsic WinPython
rem set JUPYTER_DATA_DIR=%WINPYDIR%\..\settings
rem set HOME=%WINPYDIR%\..\settings

rem Student WinPython
set JUPYTER_DATA_DIR=%HOMEDRIVE%%HOMEPATH%\Documents\WinPython%WINPYVER%
set HOME=%JUPYTER_DATA_DIR%

mkdir %HOME%
mkdir %HOME%\Notebooks

rem ******************
rem make cython use mingwpy part
rem ******************

set pydistutils_cfg=%HOME%\pydistutils.cfg

echo [config]>%pydistutils_cfg%
echo compiler=mingw32>>%pydistutils_cfg%

echo [build]>>%pydistutils_cfg%
echo compiler=mingw32>>%pydistutils_cfg%

echo [build_ext]>>%pydistutils_cfg%
echo compiler=mingw32>>%pydistutils_cfg%

echo cython has been set to use mingw32
echo to remove this, remove file "%pydistutils_cfg%"

rem ******************
rem launch Jupyter for Student
rem ******************

cd %WINPYDIR%\Scripts
%WINPYDIR%\scripts\jupyter-notebook.exe --notebook-dir=%HOME%\Notebooks %*

  • then copy and paste it as a shortcut on your students desktop.
  • make your "test" student click on it

@stonebig
Copy link
Contributor

I updated the script, so that cython should work

@stonebig
Copy link
Contributor

For spyder, it would be spyder_for_student.bat


@echo off
call %~dp0env.bat

rem classsic WinPython
rem set JUPYTER_DATA_DIR=%WINPYDIR%\..\settings
rem set HOME=%WINPYDIR%\..\settings

rem Student WinPython
set JUPYTER_DATA_DIR=%HOMEDRIVE%%HOMEPATH%\Documents\WinPython%WINPYVER%
set HOME=%JUPYTER_DATA_DIR%

if not exist %HOME% mkdir %HOME%
if not exist %HOME%\Notebooks mkdir %HOME%\Notebooks
if not exist %HOME%\.spyder-py3 mkdir %HOME%\.spyder-py3
if not exist %HOME%\.spyder-py3\workingdir echo %HOME%\Notebooks>%HOME%\.spyder-py3\workingdir

rem ******************
rem make cython use mingwpy part
rem ******************

set pydistutils_cfg=%HOME%\pydistutils.cfg

echo [config]>%pydistutils_cfg%
echo compiler=mingw32>>%pydistutils_cfg%

echo [build]>>%pydistutils_cfg%
echo compiler=mingw32>>%pydistutils_cfg%

echo [build_ext]>>%pydistutils_cfg%
echo compiler=mingw32>>%pydistutils_cfg%

echo cython has been set to use mingw32
echo to remove this, remove file "%pydistutils_cfg%"

rem ******************
rem launch Spyder for Student
rem ******************


cd %HOME%\Notebooks
%WINPYDIR%\python.exe -m spyderlib.start_app %*

@stonebig
Copy link
Contributor

and spyder_reset_for_student.bat:

@echo off
call %~dp0env.bat

rem classsic WinPython
rem set JUPYTER_DATA_DIR=%WINPYDIR%\..\settings
rem set HOME=%WINPYDIR%\..\settings

rem Student WinPython
set JUPYTER_DATA_DIR=%HOMEDRIVE%%HOMEPATH%\Documents\WinPython%WINPYVER%
set HOME=%JUPYTER_DATA_DIR%

if not exist %HOME% mkdir %HOME%
if not exist %HOME%\Notebooks mkdir %HOME%\Notebooks
if not exist %HOME%\.spyder-py3 mkdir %HOME%\.spyder-py3
if not exist %HOME%\.spyder-py3\workingdir echo %HOME%\Notebooks>%HOME%\.spyder-py3\workingdir


rem ******************
rem launch Spyder reset for Student
rem ******************

%WINPYDIR%\python.exe -m spyderlib.start_app --reset %*
echo %HOME%\Notebooks>%HOME%\.spyder-py3\workingdir

let me know if this triple 'student' combination of scripts work, or if it works after you tweaked it a bit more to your taste, so that I may include it in next release.

@stonebig
Copy link
Contributor

after last tweak, it should work ok.

Any help welcomed, there may be some clever adjustment to do based on your on-the-field experience.

@stonebig stonebig added this to the 2016-02 Matplotlib 2.0.0 / Pandas 0.18 milestone Feb 24, 2016
@stonebig
Copy link
Contributor

maybe a simpler approach:
env_for_student.bat

@echo off
rem to have WinPython working in a local account
call %~dp0env.bat

rem ******* Classic WinPython *******
rem set JUPYTER_DATA_DIR=%WINPYDIR%\..\settings
rem set HOME=%WINPYDIR%\..\settings

rem ******* Student WinPython *******
set JUPYTER_DATA_DIR=%HOMEDRIVE%%HOMEPATH%\Documents\WinPython%WINPYVER%
set HOME=%JUPYTER_DATA_DIR%

if not exist "%HOME%" mkdir "%HOME%"
if not exist "%HOME%\Notebooks" mkdir "%HOME%\Notebooks"
if not exist "%HOME%\Notebooks\docs" xcopy /i "%WINPYDIR%\..\Notebooks\docs\*.*" "%HOME%\Notebooks\docs"

if not exist "%HOME%\.spyder-py3"  mkdir "%HOME%\.spyder-py3"
if not exist "%HOME%\.spyder-py3\workingdir" echo %HOME%\Notebooks>"%HOME%\.spyder-py3\workingdir"

rem ******* make cython use mingwpy part *******
set pydistutils_cfg=%HOME%\pydistutils.cfg

if exist "%pydistutils_cfg%"  goto after_mingwpy

echo [config]>%pydistutils_cfg%"
echo compiler=mingw32>>"%pydistutils_cfg%"
echo [build]>>"%pydistutils_cfg%
echo compiler=mingw32>>"%pydistutils_cfg%"
echo [build_ext]>>"%pydistutils_cfg%"
echo compiler=mingw32>>"%pydistutils_cfg%"

:after_mingwpy

spyder_for_student.bat:

@echo off
call "%~dp0env_for_student.bat"
cd/D "%HOME%\Notebooks"
"%WINPYDIR%\python.exe" -m spyderlib.start_app %*

spyder_reset_for_student.bat:

@echo off
call "%~dp0env_for_student.bat"
cd/D "%HOME%\Notebooks"
"%WINPYDIR%\python.exe" -m spyderlib.start_app --reset %*
echo %HOME%\Notebooks>"%HOME%\.spyder-py3\workingdir"

ipython_notebook_for_student.bat:

@echo off
call "%~dp0env_for_student.bat"
cd/D "%HOME%\Notebooks"
"%WINPYDIR%\scripts\jupyter-notebook.exe" --notebook-dir="%HOME%\Notebooks" %*

idlex_for_student.bat:

@echo off
call "%~dp0env_for_student.bat"
cd/D "%HOME%\Notebooks"
"%WINPYDIR%\python.exe" "%WINPYDIR%\scripts\idlex.pyw" %*

@guaguanco
Copy link
Author

@stonebig, yes changing env.bat is what I'm experimenting with right now. Concerning the default folders, I'll probably use the default locations as specified in http://jupyter.readthedocs.org/en/latest/system.html. I'll report back in this thread.

BTW, the apps in [WINPYTHON_DIR] (e.g. Jupyter Notebook.exe) use those scripts or have environment vars built in?

--sergio

@stonebig
Copy link
Contributor

hi @guaguanco,

The launchers don't use the scripts, it's all wired in the "nsis" launchers:

  • it's the historical way of WinPython.
  • it needs a rewrite and some simplification to better support your use-case, but:
    • the way to do it is not clear yet,
    • the result of your tweakings and remarks is a valuable input, before going further.

@stonebig
Copy link
Contributor

I'm going to experiment a build1:

  • unchanged current icons
  • a series of new (student) icons, which are:
    • launching executables via the .bat in ..\scripts, (where we can change variables)
    • place the end-user environnement in HOME=%HOMEDRIVE%%HOMEPATH%\Documents\WinPython%WINPYVER%
    • end-user layout is:
      - this %HOME% is like "settings" directory of default winpython
      - default script and notebooks are in %HOME%\notebooks
  • you can modify the "student" scripts in ..\scripts to fit your layout

By creating shortcut of these 'students' icons on the 'students' desktop:

  • they should be able to work without having any rights to the WinPython directory
  • these environnements should not interfer with a "system" Python or another WinPython

@stonebig
Copy link
Contributor

hi @guaguanco,

Here is a patch, that should work for any recent WinPython version:

  • unzip attached directory in a temporary directory
  • move icons next to you usual WinPython icons,
  • move scripts to the WinPython\scripts directory
  • eventually, install IDLEX wheel (for the IDLEX icon to work)

suggested usage

  • copy a shortcut of "(student)" icons to student desktop, or make them click the "(student)" icons,
  • these icons merely launch the given scripts:
    • so they are independant of the WinPython version,
    • they will:
      • create a "HOME" directory %USERPROFILE%\Documents\Winpython%WINPYTHONVER%
      • copy sample Notebooks\docs to this %HOME%\Notebook\docs
      • start jupyter/Spyder/IDLEX on default directory %HOME%\Notebook
      • you can modify that as all is setup in "env_for_student.bat" script, accessible for you.

I think this is the best way to patch an existing WinPython.

ww_patch_student.zip

@stonebig
Copy link
Contributor

stonebig commented Mar 5, 2016

solved by #272

Initiall settings files will stay but winPython.ini can be configured so that users do work in their local directories, where new settings will show up:

''''
[debug]
state = disabled
[environment]
HOME = %HOMEDRIVE%%HOMEPATH%\Documents\WinPython%WINPYVER%\settings
JUPYTER_DATA_DIR = %HOME%
WINPYWORKDIR = %HOMEDRIVE%%HOMEPATH%\Documents\WinPython%WINPYVER%\Notebooks
''''

will creates the folowing hierarchy (for WinPython 3.4.4.1Qt5):

%HOMEDRIVE%%HOMEPATH%\Documents\WinPython 3.4.4.1Qt5
├── settings
    └── .matplotlib
    └── .ipython
    └── .pydistutils.cfg
└── Notebooks
    └── docs

two scripts allows the common Winpython directory to behaves the classic way or the new way:

  • make_working_directory_be_not_winpython.bat
  • make_working_directory_be_winpython.bat

(all they do is tweaking winpython.ini file)

@stonebig stonebig closed this as completed Mar 5, 2016
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