Skip to content
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

Align path format for windows. #243

Merged
merged 17 commits into from
Nov 9, 2022
Merged

Conversation

specter119
Copy link
Contributor

@specter119 specter119 commented Nov 8, 2022

This PR makes the following modifications.

overall:

  • change str(pathlib.Path) to pathlib.Path.as_posix()
  • convert pathlib.Path / "a" / "b" / "c" to pathlib.Path / "a/b/c"
  • replace parent.parent with parents[1]

for plugins/lab/fps_lab/utils.py:

  • use pathlib.Path.rglob to replace glob.glob(pathlib.Path, recursive=True)
  • check "jupyterlab" in package

With these modifications, the following issues on the windows platform solved:

  • no labextension is found.
  • in the file browser, the path is not separated (displayed as / a\b\c /, and can't enter the parent folder).
  • raise error the package.json without "jupyterlab"

however, the following errors still exist, and I'm not sure they're windows specific:

  • --root-path doesn't change the root folder, and the root folder is still .
  • the pwd is always the root folder and doesn't change following the editing file.

To sum up, the unix like path is more friendly even in the windows platform, but str(pahtlib.Path) will convert the path as the native format.

@welcome
Copy link

welcome bot commented Nov 8, 2022

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Copy link
Collaborator

@davidbrochart davidbrochart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @specter119!
I'm wondering if we should use as_posix() only when passing paths to the front-end, and not use it or forward slashes (/) in the back-end.

@@ -18,7 +18,7 @@

auth_config = get_config(AuthConfig)

jupyter_dir = Path.home() / ".local" / "share" / "jupyter"
jupyter_dir = Path.home() / ".local/share/jupyter"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the hard-coded / going to play well on Windows?

Copy link
Contributor Author

@specter119 specter119 Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, hard-code /, works as excepted.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can read, I think it works because Python does some tricks to convert forward slashes to backslashes if needed when opening files, but the best practice is still to use pathlib's / operator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert these changes.

plugins/kernels/fps_kernels/routes.py Show resolved Hide resolved
@davidbrochart
Copy link
Collaborator

  • --root-path doesn't change the root folder, and the root folder is still .
  • the pwd is always the root folder and doesn't change following the editing file.

We currently don't handle a root directory (see #236), but we definitely need this.

@specter119
Copy link
Contributor Author

I add these changes to my local jupyverse, and it works as excepted. Together, I will actively use jupyverse for a perioid of time. Since the behavior of jupyter-server (maybe related with tornado) break my daily work, and downgrade to tornado 6.1 doesn't help.

@davidbrochart
Copy link
Collaborator

Yes, jupyter-server's dependency on Tornado was one of the reasons to start jupyverse.

Copy link
Collaborator

@davidbrochart davidbrochart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Kyle, just a minor change.

plugins/lab/fps_lab/utils.py Outdated Show resolved Hide resolved
@davidbrochart davidbrochart merged commit 4a24ca1 into jupyter-server:main Nov 9, 2022
@welcome
Copy link

welcome bot commented Nov 9, 2022

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

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

Successfully merging this pull request may close these issues.

2 participants