-
Notifications
You must be signed in to change notification settings - Fork 184
Return canonical path when using %APPDATA% on NT #222
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
Conversation
FYI, I found out that Not sure if something needs to change here, but I thought I'd flag a problem I saw with using realpath recently. |
Yes, here is a test with python 3.6 installed via conda-forge:
|
Here is Python 3.7 on Windows:
And it looks like it was fixed in Python 3.8:
|
@jasongrout Thats very interesting, I thought windows wouldn't care about the case when resolving files. I installed python 3.7 from the Microsoft Store and get the same file not found error for (.venv) C:\Users\bussmann\source\florianbussmann\notebook-37>python --version
Python 3.7.9
(.venv) C:\Users\bussmann\source\florianbussmann\notebook-37>jupyter --paths
config:
C:\Users\bussmann\.jupyter
c:\users\bussmann\source\florianbussmann\notebook-37\.venv\etc\jupyter
C:\ProgramData\jupyter
data:
C:\Users\bussmann\AppData\Roaming\jupyter
c:\users\bussmann\source\florianbussmann\notebook-37\.venv\share\jupyter
C:\ProgramData\jupyter
runtime:
C:\Users\bussmann\AppData\Roaming\jupyter\runtime
(.venv) C:\Users\bussmann\source\florianbussmann\notebook-37>python
Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 16:30:00) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> runtime_dir = r'C:\Users\bussmann\AppData\Roaming\jupyter\runtime'
>>> import os
>>> os.path.realpath(runtime_dir)
'C:\\Users\\bussmann\\AppData\\Roaming\\jupyter\\runtime'
>>> from pathlib import Path
>>> Path(runtime_dir).resolve()
WindowsPath('C:/Users/bussmann/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0/LocalCache/Roaming/jupyter/runtime') I would change my fix to str(Path(...).resolve()) as introduced in the mentioned On darwin systems jupyter_core/jupyter_core/paths.py Lines 86 to 89 in e69a436
jupyter_core/jupyter_core/paths.py Lines 35 to 41 in e69a436
|
@florianbussmann - sorry, an update on a linked issue led to this, and I realize you might have been waiting for a reply:
That sounds great. It's been a while - do you still have time to make that change?
I don't know of a difference (off the top of my head) between Path.resolve and realpath on darwin that would affect us (unlike the bug pointed out above for Windows), so I don't think it's necessary in this PR. On the other hand, if you'd like to make that change too to be consistent, I think that would be fine too. |
Note that it's up to the filesystem whether it does or not. In fact current versions of NTFS allow a per-directory flag of case sensitivity. While it's true that some parts of the Win32 subsystem assume case-insensitivity and get confused if that's not the case, it's not universally true that case doesn't matter for Windows. |
Oh, wow. Just wow. Thanks for the info. I wouldn't have imagined that.
Note that the bug we were running into that led to the investigation was a case-sensitive cache of filenames (IIRC, Node's cache), so it didn't matter what Windows behavior was, the key there was that the paths were not normalized, so Node's cache was treating two paths different when they were the same on disk. |
On Python 3.6 and 3.7, realpath does not give the canonical case for drive letters and paths, while Path().resolve() does. See the discussion at jupyter#222 (comment)
a182c27
to
c7e9c5f
Compare
76a8e76
to
f1f82ca
Compare
@florianbussmann - oh right, I forgot about the appdata mocking! Thanks! |
0256d4c
to
d9195a7
Compare
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 looks good to me. Thanks!
@florianbussmann - thanks again for putting this PR in and pushing it forward. Do my changes look okay to you? |
@jasongrout - looks good to me! I also verified this on my windows machine and it still works as expected on my windows-store installations of python. |
This fixes starting jupyter lab and notebook on windows systems when python is installed from the Microsoft Store.
jupyterlab/jupyterlab#9250
jupyter-server/jupyter_server#435
jupyter/notebook#5996
Background
The following runtime dir is not accessible outside of python as shown in jupyterlab/jupyterlab#9250 (comment)
Result
Tested on florianbussmann/notebook@5a3be03 the runtime dir used by jupyter-core in florianbussmann@ad09dbf is accessible
Tests